Fix fileID mess

A few problems here:
* In e.g. keycodes.c the fileID field of the Info struct was never
  initialized to the id of the appropriate file, so it was always 0.
  There's some code which uses it, mostly for warnings.
* Some of the fileID fields were unsigned char, which overflows several
  times, seeing as the ID in some of our tests can get > 1000 (because
  we reuse the context).
* Some sign mismatches.
* fileID vs file_id.

Hopefully this fixes everything. I doubt this stuff had ever worked as
intended, in xkbcomp or otherwise.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-07-14 15:19:12 +03:00
parent 70683f7deb
commit 43bf4136c9
10 changed files with 70 additions and 76 deletions

View File

@ -37,7 +37,7 @@ struct xkb_context {
darray(char *) includes; darray(char *) includes;
/* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */ /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */
int file_id; unsigned file_id;
struct atom_table *atom_table; struct atom_table *atom_table;
}; };
@ -144,7 +144,7 @@ xkb_context_include_path_get(struct xkb_context *ctx, unsigned int idx)
return darray_item(ctx->includes, idx); return darray_item(ctx->includes, idx);
} }
int unsigned
xkb_context_take_file_id(struct xkb_context *ctx) xkb_context_take_file_id(struct xkb_context *ctx)
{ {
return ctx->file_id++; return ctx->file_id++;

View File

@ -453,7 +453,7 @@ xkb_map_new_from_kccgst(struct xkb_context *ctx,
const struct xkb_component_names *kccgst, const struct xkb_component_names *kccgst,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
extern int extern unsigned
xkb_context_take_file_id(struct xkb_context *ctx); xkb_context_take_file_id(struct xkb_context *ctx);
bool bool

View File

@ -32,7 +32,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
{ {
if (strncmp(new->real, old->real, XkbKeyNameLength) == 0) if (strncmp(new->real, old->real, XkbKeyNameLength) == 0)
{ {
if (((new->def.fileID == old->def.fileID) && (warningLevel > 0)) || if (((new->def.file_id == old->def.file_id) && (warningLevel > 0)) ||
(warningLevel > 9)) (warningLevel > 9))
{ {
WARN("Alias of %s for %s declared more than once\n", WARN("Alias of %s for %s declared more than once\n",
@ -53,7 +53,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
use = new->real; use = new->real;
ignore = old->real; ignore = old->real;
} }
if (((old->def.fileID == new->def.fileID) && (warningLevel > 0)) || if (((old->def.file_id == new->def.file_id) && (warningLevel > 0)) ||
(warningLevel > 9)) (warningLevel > 9))
{ {
WARN("Multiple definitions for alias %s\n", WARN("Multiple definitions for alias %s\n",
@ -64,7 +64,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
if (use != old->real) if (use != old->real)
memcpy(old->real, use, XkbKeyNameLength); memcpy(old->real, use, XkbKeyNameLength);
} }
old->def.fileID = new->def.fileID; old->def.file_id = new->def.file_id;
old->def.merge = new->def.merge; old->def.merge = new->def.merge;
} }
@ -74,7 +74,7 @@ InitAliasInfo(AliasInfo * info,
{ {
memset(info, 0, sizeof(AliasInfo)); memset(info, 0, sizeof(AliasInfo));
info->def.merge = merge; info->def.merge = merge;
info->def.fileID = file_id; info->def.file_id = file_id;
strncpy(info->alias, alias, XkbKeyNameLength); strncpy(info->alias, alias, XkbKeyNameLength);
strncpy(info->real, real, XkbKeyNameLength); strncpy(info->real, real, XkbKeyNameLength);
} }
@ -101,7 +101,7 @@ HandleAliasDef(KeyAliasDef * def,
WSGO("Allocation failure in HandleAliasDef\n"); WSGO("Allocation failure in HandleAliasDef\n");
return false; return false;
} }
info->def.fileID = file_id; info->def.file_id = file_id;
info->def.merge = merge; info->def.merge = merge;
info->def.next = (CommonInfo *) * info_in; info->def.next = (CommonInfo *) * info_in;
memcpy(info->alias, def->alias, XkbKeyNameLength); memcpy(info->alias, def->alias, XkbKeyNameLength);
@ -140,7 +140,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
def.merge = how_merge; def.merge = how_merge;
memcpy(def.alias, tmp->alias, XkbKeyNameLength); memcpy(def.alias, tmp->alias, XkbKeyNameLength);
memcpy(def.real, tmp->real, XkbKeyNameLength); memcpy(def.real, tmp->real, XkbKeyNameLength);
if (!HandleAliasDef(&def, def.merge, tmp->def.fileID, into)) if (!HandleAliasDef(&def, def.merge, tmp->def.file_id, into))
return false; return false;
} }
return true; return true;

View File

@ -44,7 +44,7 @@ typedef struct _SymInterpInfo
typedef struct _GroupCompatInfo typedef struct _GroupCompatInfo
{ {
unsigned char fileID; unsigned file_id;
unsigned char merge; unsigned char merge;
bool defined; bool defined;
unsigned char real_mods; unsigned char real_mods;
@ -54,7 +54,7 @@ typedef struct _GroupCompatInfo
typedef struct _CompatInfo typedef struct _CompatInfo
{ {
char *name; char *name;
unsigned fileID; unsigned file_id;
int errorCount; int errorCount;
int nInterps; int nInterps;
SymInterpInfo *interps; SymInterpInfo *interps;
@ -96,18 +96,18 @@ siText(SymInterpInfo * si, CompatInfo * info)
} }
static void static void
InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap) InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id)
{ {
unsigned int i; unsigned int i;
info->keymap = keymap; info->keymap = keymap;
info->name = NULL; info->name = NULL;
info->fileID = 0; info->file_id = file_id;
info->errorCount = 0; info->errorCount = 0;
info->nInterps = 0; info->nInterps = 0;
info->interps = NULL; info->interps = NULL;
info->act = NULL; info->act = NULL;
info->dflt.defs.fileID = info->fileID; info->dflt.defs.file_id = file_id;
info->dflt.defs.defined = 0; info->dflt.defs.defined = 0;
info->dflt.defs.merge = MERGE_OVERRIDE; info->dflt.defs.merge = MERGE_OVERRIDE;
info->dflt.interp.flags = 0; info->dflt.interp.flags = 0;
@ -116,7 +116,7 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++) for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
info->dflt.interp.act.any.data[i] = 0; info->dflt.interp.act.any.data[i] = 0;
ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt); ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt);
info->ledDflt.defs.fileID = info->fileID; info->ledDflt.defs.file_id = file_id;
info->ledDflt.defs.defined = 0; info->ledDflt.defs.defined = 0;
info->ledDflt.defs.merge = MERGE_OVERRIDE; info->ledDflt.defs.merge = MERGE_OVERRIDE;
memset(&info->groupCompat[0], 0, memset(&info->groupCompat[0], 0,
@ -200,7 +200,7 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
if (new->defs.merge == MERGE_REPLACE) if (new->defs.merge == MERGE_REPLACE)
{ {
SymInterpInfo *next = (SymInterpInfo *) old->defs.next; SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
if (((old->defs.fileID == new->defs.fileID) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Multiple definitions for \"%s\"\n", siText(new, info)); WARN("Multiple definitions for \"%s\"\n", siText(new, info));
@ -266,7 +266,7 @@ AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC)
{ {
return true; return true;
} }
if (((gc->fileID == newGC->fileID) && (warningLevel > 0)) if (((gc->file_id == newGC->file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9))
{ {
WARN("Compat map for group %d redefined\n", group + 1); WARN("Compat map for group %d redefined\n", group + 1);
@ -407,12 +407,9 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn,
&newMerge)) &newMerge))
{ {
InitCompatInfo(&included, keymap); InitCompatInfo(&included, keymap, rtrn->id);
included.fileID = rtrn->id;
included.dflt = info->dflt; included.dflt = info->dflt;
included.dflt.defs.fileID = rtrn->id;
included.dflt.defs.merge = newMerge; included.dflt.defs.merge = newMerge;
included.ledDflt.defs.fileID = rtrn->id;
included.ledDflt.defs.merge = newMerge; included.ledDflt.defs.merge = newMerge;
included.act = info->act; included.act = info->act;
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included); HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included);
@ -448,12 +445,12 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT,
&rtrn, &op)) &rtrn, &op))
{ {
InitCompatInfo(&next_incl, keymap); InitCompatInfo(&next_incl, keymap, rtrn->id);
next_incl.fileID = rtrn->id; next_incl.file_id = rtrn->id;
next_incl.dflt = info->dflt; next_incl.dflt = info->dflt;
next_incl.dflt.defs.fileID = rtrn->id; next_incl.dflt.defs.file_id = rtrn->id;
next_incl.dflt.defs.merge = op; next_incl.dflt.defs.merge = op;
next_incl.ledDflt.defs.fileID = rtrn->id; next_incl.ledDflt.defs.file_id = rtrn->id;
next_incl.ledDflt.defs.merge = op; next_incl.ledDflt.defs.merge = op;
next_incl.act = info->act; next_incl.act = info->act;
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
@ -678,7 +675,7 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
def->group); def->group);
return false; return false;
} }
tmp.fileID = info->fileID; tmp.file_id = info->file_id;
tmp.merge = merge; tmp.merge = merge;
if (!ExprResolveVModMask(def->def, &val, keymap)) if (!ExprResolveVModMask(def->def, &val, keymap))
{ {
@ -785,7 +782,7 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
CompatInfo info; CompatInfo info;
GroupCompatInfo *gcm; GroupCompatInfo *gcm;
InitCompatInfo(&info, keymap); InitCompatInfo(&info, keymap, file->id);
info.dflt.defs.merge = merge; info.dflt.defs.merge = merge;
info.ledDflt.defs.merge = merge; info.ledDflt.defs.merge = merge;
@ -817,7 +814,7 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
} }
for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) { for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) {
if ((gcm->fileID != 0) || (gcm->real_mods != 0) || (gcm->vmods != 0)) { if ((gcm->file_id != 0) || (gcm->real_mods != 0) || (gcm->vmods != 0)) {
keymap->compat->groups[i].mask = gcm->real_mods; keymap->compat->groups[i].mask = gcm->real_mods;
keymap->compat->groups[i].real_mods = gcm->real_mods; keymap->compat->groups[i].real_mods = gcm->real_mods;
keymap->compat->groups[i].vmods = gcm->vmods; keymap->compat->groups[i].vmods = gcm->vmods;

View File

@ -74,7 +74,7 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
if (new->defs.merge == MERGE_REPLACE) if (new->defs.merge == MERGE_REPLACE)
{ {
CommonInfo *next = old->defs.next; CommonInfo *next = old->defs.next;
if (((old->defs.fileID == new->defs.fileID) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Map for indicator %s redefined\n", WARN("Map for indicator %s redefined\n",

View File

@ -63,7 +63,7 @@ typedef struct _KeyNamesInfo
{ {
char *name; /* e.g. evdev+aliases(qwerty) */ char *name; /* e.g. evdev+aliases(qwerty) */
int errorCount; int errorCount;
unsigned fileID; unsigned file_id;
enum merge_mode merge; enum merge_mode merge;
xkb_keycode_t computedMin; /* lowest keycode stored */ xkb_keycode_t computedMin; /* lowest keycode stored */
xkb_keycode_t computedMax; /* highest keycode stored */ xkb_keycode_t computedMax; /* highest keycode stored */
@ -93,7 +93,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{ {
ii->defs.defined = 0; ii->defs.defined = 0;
ii->defs.merge = info->merge; ii->defs.merge = info->merge;
ii->defs.fileID = info->fileID; ii->defs.file_id = info->file_id;
ii->defs.next = NULL; ii->defs.next = NULL;
ii->ndx = 0; ii->ndx = 0;
ii->name = XKB_ATOM_NONE; ii->name = XKB_ATOM_NONE;
@ -163,7 +163,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
old = FindIndicatorByName(info, new->name); old = FindIndicatorByName(info, new->name);
if (old) if (old)
{ {
if (((old->defs.fileID == new->defs.fileID) && (warningLevel > 0)) if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9))
{ {
WARN("Multiple indicators named %s\n", WARN("Multiple indicators named %s\n",
@ -216,7 +216,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
old = FindIndicatorByIndex(info, new->ndx); old = FindIndicatorByIndex(info, new->ndx);
if (old) if (old)
{ {
if (((old->defs.fileID == new->defs.fileID) && (warningLevel > 0)) if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9))
{ {
WARN("Multiple names for indicator %d\n", new->ndx); WARN("Multiple names for indicator %d\n", new->ndx);
@ -286,11 +286,12 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
} }
static void static void
InitKeyNamesInfo(KeyNamesInfo * info) InitKeyNamesInfo(KeyNamesInfo * info, unsigned file_id)
{ {
info->name = NULL; info->name = NULL;
info->leds = NULL; info->leds = NULL;
info->aliases = NULL; info->aliases = NULL;
info->file_id = file_id;
darray_init(info->names); darray_init(info->names);
darray_init(info->files); darray_init(info->files);
ClearKeyNamesInfo(info); ClearKeyNamesInfo(info);
@ -316,8 +317,8 @@ FindKeyByLong(KeyNamesInfo * info, unsigned long name)
*/ */
static bool static bool
AddKeyName(KeyNamesInfo * info, AddKeyName(KeyNamesInfo * info,
xkb_keycode_t kc, xkb_keycode_t kc, char *name, enum merge_mode merge,
char *name, enum merge_mode merge, unsigned fileID, bool reportCollisions) unsigned file_id, bool reportCollisions)
{ {
xkb_keycode_t old; xkb_keycode_t old;
unsigned long lval; unsigned long lval;
@ -334,7 +335,7 @@ AddKeyName(KeyNamesInfo * info,
{ {
reportCollisions = (warningLevel > 7 || reportCollisions = (warningLevel > 7 ||
(warningLevel > 0 && (warningLevel > 0 &&
fileID == darray_item(info->files, kc))); file_id == darray_item(info->files, kc)));
} }
if (darray_item(info->names, kc) != 0) if (darray_item(info->names, kc) != 0)
@ -394,7 +395,7 @@ AddKeyName(KeyNamesInfo * info,
} }
} }
darray_item(info->names, kc) = lval; darray_item(info->names, kc) = lval;
darray_item(info->files, kc) = fileID; darray_item(info->files, kc) = file_id;
return true; return true;
} }
@ -426,7 +427,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
continue; continue;
LongToKeyName(darray_item(from->names, i), buf); LongToKeyName(darray_item(from->names, i), buf);
buf[4] = '\0'; buf[4] = '\0';
if (!AddKeyName(into, i, buf, merge, from->fileID, false)) if (!AddKeyName(into, i, buf, merge, from->file_id, false))
into->errorCount++; into->errorCount++;
} }
if (from->leds) if (from->leds)
@ -492,7 +493,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
&newMerge)) &newMerge))
{ {
InitKeyNamesInfo(&included); InitKeyNamesInfo(&included, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
if (stmt->stmt != NULL) if (stmt->stmt != NULL)
{ {
@ -525,7 +526,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
&rtrn, &op)) &rtrn, &op))
{ {
InitKeyNamesInfo(&next_incl); InitKeyNamesInfo(&next_incl, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
MergeIncludedKeycodes(&included, keymap, &next_incl, op); MergeIncludedKeycodes(&included, keymap, &next_incl, op);
ClearKeyNamesInfo(&next_incl); ClearKeyNamesInfo(&next_incl);
@ -572,7 +573,7 @@ HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
else else
merge = stmt->merge; merge = stmt->merge;
} }
return AddKeyName(info, stmt->value, stmt->name, merge, info->fileID, return AddKeyName(info, stmt->value, stmt->name, merge, info->file_id,
true); true);
} }
@ -745,7 +746,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
info->errorCount++; info->errorCount++;
break; break;
case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */ case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */
if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->fileID, if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->file_id,
&info->aliases)) &info->aliases))
info->errorCount++; info->errorCount++;
break; break;
@ -799,7 +800,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
{ {
KeyNamesInfo info; /* contains all the info after parsing */ KeyNamesInfo info; /* contains all the info after parsing */
InitKeyNamesInfo(&info); InitKeyNamesInfo(&info, file->id);
HandleKeycodesFile(file, keymap, merge, &info); HandleKeycodesFile(file, keymap, merge, &info);

View File

@ -48,7 +48,7 @@ typedef struct _KeyTypeInfo
{ {
CommonInfo defs; CommonInfo defs;
xkb_atom_t name; xkb_atom_t name;
int fileID; unsigned file_id;
unsigned mask; unsigned mask;
unsigned vmask; unsigned vmask;
bool groupInfo; bool groupInfo;
@ -62,7 +62,7 @@ typedef struct _KeyTypesInfo
{ {
char *name; char *name;
int errorCount; int errorCount;
int fileID; unsigned file_id;
unsigned stdPresent; unsigned stdPresent;
unsigned nTypes; unsigned nTypes;
KeyTypeInfo *types; KeyTypeInfo *types;
@ -99,7 +99,7 @@ static xkb_atom_t tok_KEYPAD;
static void static void
InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap, InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
KeyTypesInfo *from) KeyTypesInfo *from, unsigned file_id)
{ {
tok_ONE_LEVEL = xkb_atom_intern(keymap->ctx, "ONE_LEVEL"); tok_ONE_LEVEL = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
tok_TWO_LEVEL = xkb_atom_intern(keymap->ctx, "TWO_LEVEL"); tok_TWO_LEVEL = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
@ -110,8 +110,9 @@ InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
info->stdPresent = 0; info->stdPresent = 0;
info->nTypes = 0; info->nTypes = 0;
info->types = NULL; info->types = NULL;
info->file_id = file_id;
info->dflt.defs.defined = 0; info->dflt.defs.defined = 0;
info->dflt.defs.fileID = 0; info->dflt.defs.file_id = file_id;
info->dflt.defs.merge = MERGE_OVERRIDE; info->dflt.defs.merge = MERGE_OVERRIDE;
info->dflt.defs.next = NULL; info->dflt.defs.next = NULL;
info->dflt.name = XKB_ATOM_NONE; info->dflt.name = XKB_ATOM_NONE;
@ -190,7 +191,7 @@ NextKeyType(KeyTypesInfo * info)
if (type != NULL) if (type != NULL)
{ {
memset(type, 0, sizeof(KeyTypeInfo)); memset(type, 0, sizeof(KeyTypeInfo));
type->defs.fileID = info->fileID; type->defs.file_id = info->file_id;
info->types = AddCommonInfo(&info->types->defs, &type->defs); info->types = AddCommonInfo(&info->types->defs, &type->defs);
info->nTypes++; info->nTypes++;
} }
@ -262,7 +263,7 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
|| (new->defs.merge == MERGE_OVERRIDE)) || (new->defs.merge == MERGE_OVERRIDE))
{ {
KeyTypeInfo *next = (KeyTypeInfo *) old->defs.next; KeyTypeInfo *next = (KeyTypeInfo *) old->defs.next;
if (((old->defs.fileID == new->defs.fileID) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
@ -277,7 +278,7 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
old->defs.next = &next->defs; old->defs.next = &next->defs;
return true; return true;
} }
report = (old->defs.fileID == new->defs.fileID) && (warningLevel > 0); report = (old->defs.file_id == new->defs.file_id) && (warningLevel > 0);
if (report) if (report)
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
@ -349,8 +350,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn,
&newMerge)) &newMerge))
{ {
InitKeyTypesInfo(&included, keymap, info); InitKeyTypesInfo(&included, keymap, info, rtrn->id);
included.fileID = included.dflt.defs.fileID = rtrn->id;
included.dflt.defs.merge = newMerge; included.dflt.defs.merge = newMerge;
HandleKeyTypesFile(rtrn, keymap, newMerge, &included); HandleKeyTypesFile(rtrn, keymap, newMerge, &included);
@ -384,8 +384,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES,
&rtrn, &op)) &rtrn, &op))
{ {
InitKeyTypesInfo(&next_incl, keymap, &included); InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id);
next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id;
next_incl.dflt.defs.merge = op; next_incl.dflt.defs.merge = op;
HandleKeyTypesFile(rtrn, keymap, op, &next_incl); HandleKeyTypesFile(rtrn, keymap, op, &next_incl);
MergeIncludedKeyTypes(&included, &next_incl, op, keymap); MergeIncludedKeyTypes(&included, &next_incl, op, keymap);
@ -857,7 +856,7 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
merge = def->merge; merge = def->merge;
type.defs.defined = 0; type.defs.defined = 0;
type.defs.fileID = info->fileID; type.defs.file_id = info->file_id;
type.defs.merge = merge; type.defs.merge = merge;
type.defs.next = NULL; type.defs.next = NULL;
type.name = def->name; type.name = def->name;
@ -1218,8 +1217,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
KeyTypesInfo info; KeyTypesInfo info;
KeyTypeInfo *def; KeyTypeInfo *def;
InitKeyTypesInfo(&info, keymap, NULL); InitKeyTypesInfo(&info, keymap, NULL, file->id);
info.fileID = file->id;
HandleKeyTypesFile(file, keymap, merge, &info); HandleKeyTypesFile(file, keymap, merge, &info);

View File

@ -164,7 +164,7 @@ UseNewField(unsigned field,
{ {
if (newDefs->defined & field) if (newDefs->defined & field)
{ {
if (((oldDefs->fileID == newDefs->fileID) if (((oldDefs->file_id == newDefs->file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
*pCollide |= field; *pCollide |= field;

View File

@ -90,13 +90,13 @@ typedef struct _KeyInfo
* Init the given key info to sane values. * Init the given key info to sane values.
*/ */
static void static void
InitKeyInfo(KeyInfo * info) InitKeyInfo(KeyInfo * info, unsigned file_id)
{ {
int i; int i;
static const char dflt[4] = "*"; static const char dflt[4] = "*";
info->defs.defined = 0; info->defs.defined = 0;
info->defs.fileID = 0; info->defs.file_id = file_id;
info->defs.merge = MERGE_OVERRIDE; info->defs.merge = MERGE_OVERRIDE;
info->defs.next = NULL; info->defs.next = NULL;
info->name = KeyNameToLong(dflt); info->name = KeyNameToLong(dflt);
@ -127,7 +127,7 @@ FreeKeyInfo(KeyInfo * info)
int i; int i;
info->defs.defined = 0; info->defs.defined = 0;
info->defs.fileID = 0; info->defs.file_id = 0;
info->defs.merge = MERGE_OVERRIDE; info->defs.merge = MERGE_OVERRIDE;
info->defs.next = NULL; info->defs.next = NULL;
info->groupInfo = 0; info->groupInfo = 0;
@ -200,7 +200,7 @@ typedef struct _SymbolsInfo
{ {
char *name; /* e.g. pc+us+inet(evdev) */ char *name; /* e.g. pc+us+inet(evdev) */
int errorCount; int errorCount;
unsigned fileID; unsigned file_id;
enum merge_mode merge; enum merge_mode merge;
unsigned explicit_group; unsigned explicit_group;
darray(KeyInfo) keys; darray(KeyInfo) keys;
@ -214,21 +214,22 @@ typedef struct _SymbolsInfo
} SymbolsInfo; } SymbolsInfo;
static void static void
InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap) InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap,
unsigned file_id)
{ {
int i; int i;
info->name = NULL; info->name = NULL;
info->explicit_group = 0; info->explicit_group = 0;
info->errorCount = 0; info->errorCount = 0;
info->fileID = 0; info->file_id = file_id;
info->merge = MERGE_OVERRIDE; info->merge = MERGE_OVERRIDE;
darray_init(info->keys); darray_init(info->keys);
darray_growalloc(info->keys, 110); darray_growalloc(info->keys, 110);
info->modMap = NULL; info->modMap = NULL;
for (i = 0; i < XkbNumKbdGroups; i++) for (i = 0; i < XkbNumKbdGroups; i++)
info->groupNames[i] = XKB_ATOM_NONE; info->groupNames[i] = XKB_ATOM_NONE;
InitKeyInfo(&info->dflt); InitKeyInfo(&info->dflt, file_id);
InitVModInfo(&info->vmods, keymap); InitVModInfo(&info->vmods, keymap);
info->action = NULL; info->action = NULL;
info->aliases = NULL; info->aliases = NULL;
@ -303,7 +304,7 @@ MergeKeyGroups(SymbolsInfo * info,
clobber = (from->defs.merge != MERGE_AUGMENT); clobber = (from->defs.merge != MERGE_AUGMENT);
report = (warningLevel > 9) || report = (warningLevel > 9) ||
((into->defs.fileID == from->defs.fileID) && (warningLevel > 0)); ((into->defs.file_id == from->defs.file_id) && (warningLevel > 0));
darray_init(resultSyms); darray_init(resultSyms);
@ -533,7 +534,7 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
return true; return true;
} }
report = ((warningLevel > 9) || report = ((warningLevel > 9) ||
((into->defs.fileID == from->defs.fileID) ((into->defs.file_id == from->defs.file_id)
&& (warningLevel > 0))); && (warningLevel > 0)));
for (i = 0; i < XkbNumKbdGroups; i++) for (i = 0; i < XkbNumKbdGroups; i++)
{ {
@ -809,8 +810,7 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_SYMBOLS, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_SYMBOLS, &rtrn,
&newMerge)) &newMerge))
{ {
InitSymbolsInfo(&included, keymap); InitSymbolsInfo(&included, keymap, rtrn->id);
included.fileID = included.dflt.defs.fileID = rtrn->id;
included.merge = included.dflt.defs.merge = MERGE_OVERRIDE; included.merge = included.dflt.defs.merge = MERGE_OVERRIDE;
if (stmt->modifier) if (stmt->modifier)
{ {
@ -851,8 +851,7 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS,
&rtrn, &op)) &rtrn, &op))
{ {
InitSymbolsInfo(&next_incl, keymap); InitSymbolsInfo(&next_incl, keymap, rtrn->id);
next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id;
next_incl.merge = next_incl.dflt.defs.merge = MERGE_OVERRIDE; next_incl.merge = next_incl.dflt.defs.merge = MERGE_OVERRIDE;
if (next->modifier) if (next->modifier)
{ {
@ -1433,7 +1432,7 @@ HandleSymbolsDef(SymbolsDef *stmt, struct xkb_keymap *keymap,
{ {
KeyInfo key; KeyInfo key;
InitKeyInfo(&key); InitKeyInfo(&key, info->file_id);
CopyKeyInfo(&info->dflt, &key, false); CopyKeyInfo(&info->dflt, &key, false);
key.defs.merge = stmt->merge; key.defs.merge = stmt->merge;
key.name = KeyNameToLong(stmt->keyName); key.name = KeyNameToLong(stmt->keyName);
@ -2086,8 +2085,7 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
SymbolsInfo info; SymbolsInfo info;
KeyInfo *key; KeyInfo *key;
InitSymbolsInfo(&info, keymap); InitSymbolsInfo(&info, keymap, file->id);
info.dflt.defs.fileID = file->id;
info.dflt.defs.merge = merge; info.dflt.defs.merge = merge;
HandleSymbolsFile(file, keymap, merge, &info); HandleSymbolsFile(file, keymap, merge, &info);

View File

@ -35,7 +35,7 @@
typedef struct _CommonInfo typedef struct _CommonInfo
{ {
unsigned short defined; unsigned short defined;
unsigned char fileID; unsigned file_id;
unsigned char merge; unsigned char merge;
struct _CommonInfo *next; struct _CommonInfo *next;
} CommonInfo; } CommonInfo;