rules: remove unused struct fields and use size_t Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
diff --git a/src/rules.c b/src/rules.c
index 76f74b3..b0d4d2f 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -45,8 +45,7 @@
#define DFLT_LINE_SIZE 128
typedef struct {
- int line_num;
- int sz_line;
+ size_t sz_line;
int num_line;
char buf[DFLT_LINE_SIZE];
char * line;
@@ -55,7 +54,6 @@ typedef struct {
static void
InitInputLine(InputLine *line)
{
- line->line_num= 1;
line->num_line= 0;
line->sz_line= DFLT_LINE_SIZE;
line->line= line->buf;
@@ -66,7 +64,6 @@ FreeInputLine(InputLine *line)
{
if (line->line!=line->buf)
free(line->line);
- line->line_num= 1;
line->num_line= 0;
line->sz_line= DFLT_LINE_SIZE;
line->line= line->buf;
@@ -109,7 +106,6 @@ GetInputLine(FILE *file,InputLine *line,bool checkbang)
if (ch=='\n') {
inComment= false;
ch= ' ';
- line->line_num++;
}
}
if (inComment)
@@ -193,7 +189,7 @@ static const char * cname[MAX_WORDS] = {
typedef struct _RemapSpec {
int number;
- int num_remap;
+ size_t num_remap;
struct {
int word;
int index;
@@ -739,6 +735,9 @@ XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
size_t len;
int ndx;
+ if (!name)
+ return NULL;
+
orig= name;
str= strchr(name,'%');
if (str==NULL)
@@ -846,16 +845,11 @@ XkbcRF_GetComponents( XkbRF_RulesPtr rules,
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option);
XkbRF_ApplyPartialMatches(rules, names);
- if (names->keycodes)
- names->keycodes= XkbRF_SubstituteVars(names->keycodes, &mdefs);
- if (names->symbols)
- names->symbols= XkbRF_SubstituteVars(names->symbols, &mdefs);
- if (names->types)
- names->types= XkbRF_SubstituteVars(names->types, &mdefs);
- if (names->compat)
- names->compat= XkbRF_SubstituteVars(names->compat, &mdefs);
- if (names->keymap)
- names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs);
+ names->keycodes = XkbRF_SubstituteVars(names->keycodes, &mdefs);
+ names->symbols = XkbRF_SubstituteVars(names->symbols, &mdefs);
+ names->types = XkbRF_SubstituteVars(names->types, &mdefs);
+ names->compat = XkbRF_SubstituteVars(names->compat, &mdefs);
+ names->keymap = XkbRF_SubstituteVars(names->keymap, &mdefs);
FreeMultiDefs(&mdefs);
return (names->keycodes && names->symbols && names->types &&
@@ -877,9 +871,6 @@ XkbcRF_AddRule(XkbRF_RulesPtr rules)
}
if (!rules->rules) {
rules->sz_rules= rules->num_rules= 0;
-#ifdef DEBUG
- fprintf(stderr,"Allocation failure in XkbcRF_AddRule\n");
-#endif
return NULL;
}
memset(&rules->rules[rules->num_rules], 0, sizeof(XkbRF_RuleRec));
@@ -968,12 +959,7 @@ XkbcRF_Free(XkbRF_RulesPtr rules)
XkbRF_ClearVarDescriptions(&rules->layouts);
XkbRF_ClearVarDescriptions(&rules->variants);
XkbRF_ClearVarDescriptions(&rules->options);
- if (rules->extra) {
- for (i = 0; i < rules->num_extra; i++) {
- XkbRF_ClearVarDescriptions(&rules->extra[i]);
- }
- free(rules->extra);
- }
+
for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
free(rule->model);
free(rule->layout);
diff --git a/src/rules.h b/src/rules.h
index 15e93fe..ecc66aa 100644
--- a/src/rules.h
+++ b/src/rules.h
@@ -38,10 +38,6 @@ typedef struct _XkbRF_VarDefs {
const char * layout;
const char * variant;
const char * options;
- unsigned short sz_extra;
- unsigned short num_extra;
- char * extra_names;
- char ** extra_values;
} XkbRF_VarDefsRec,*XkbRF_VarDefsPtr;
typedef struct _XkbRF_VarDesc {
@@ -50,8 +46,8 @@ typedef struct _XkbRF_VarDesc {
} XkbRF_VarDescRec, *XkbRF_VarDescPtr;
typedef struct _XkbRF_DescribeVars {
- int sz_desc;
- int num_desc;
+ size_t sz_desc;
+ size_t num_desc;
XkbRF_VarDescPtr desc;
} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr;
@@ -89,14 +85,12 @@ typedef struct _XkbRF_Rules {
XkbRF_DescribeVarsRec layouts;
XkbRF_DescribeVarsRec variants;
XkbRF_DescribeVarsRec options;
- unsigned short num_extra;
- XkbRF_DescribeVarsPtr extra;
- unsigned short sz_rules;
- unsigned short num_rules;
+ size_t sz_rules;
+ size_t num_rules;
XkbRF_RulePtr rules;
- unsigned short sz_groups;
- unsigned short num_groups;
+ size_t sz_groups;
+ size_t num_groups;
XkbRF_GroupPtr groups;
} XkbRF_RulesRec, *XkbRF_RulesPtr;