From 43bf4136c976c251e973c28d07b63ea542ef3879 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 14 Jul 2012 15:19:12 +0300 Subject: [PATCH] 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 --- src/context.c | 4 ++-- src/xkb-priv.h | 2 +- src/xkbcomp/alias.c | 12 ++++++------ src/xkbcomp/compat.c | 35 ++++++++++++++++------------------- src/xkbcomp/indicators.c | 2 +- src/xkbcomp/keycodes.c | 31 ++++++++++++++++--------------- src/xkbcomp/keytypes.c | 26 ++++++++++++-------------- src/xkbcomp/misc.c | 2 +- src/xkbcomp/symbols.c | 30 ++++++++++++++---------------- src/xkbcomp/xkbcomp-priv.h | 2 +- 10 files changed, 70 insertions(+), 76 deletions(-) diff --git a/src/context.c b/src/context.c index 1e28911..b283fc4 100644 --- a/src/context.c +++ b/src/context.c @@ -37,7 +37,7 @@ struct xkb_context { darray(char *) includes; /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */ - int file_id; + unsigned file_id; 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); } -int +unsigned xkb_context_take_file_id(struct xkb_context *ctx) { return ctx->file_id++; diff --git a/src/xkb-priv.h b/src/xkb-priv.h index bed35b1..b58ecc1 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -453,7 +453,7 @@ xkb_map_new_from_kccgst(struct xkb_context *ctx, const struct xkb_component_names *kccgst, enum xkb_map_compile_flags flags); -extern int +extern unsigned xkb_context_take_file_id(struct xkb_context *ctx); bool diff --git a/src/xkbcomp/alias.c b/src/xkbcomp/alias.c index c169656..3f09afe 100644 --- a/src/xkbcomp/alias.c +++ b/src/xkbcomp/alias.c @@ -32,7 +32,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new) { 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)) { WARN("Alias of %s for %s declared more than once\n", @@ -53,7 +53,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new) use = new->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)) { WARN("Multiple definitions for alias %s\n", @@ -64,7 +64,7 @@ HandleCollision(AliasInfo * old, AliasInfo * new) if (use != old->real) 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; } @@ -74,7 +74,7 @@ InitAliasInfo(AliasInfo * info, { memset(info, 0, sizeof(AliasInfo)); info->def.merge = merge; - info->def.fileID = file_id; + info->def.file_id = file_id; strncpy(info->alias, alias, XkbKeyNameLength); strncpy(info->real, real, XkbKeyNameLength); } @@ -101,7 +101,7 @@ HandleAliasDef(KeyAliasDef * def, WSGO("Allocation failure in HandleAliasDef\n"); return false; } - info->def.fileID = file_id; + info->def.file_id = file_id; info->def.merge = merge; info->def.next = (CommonInfo *) * info_in; memcpy(info->alias, def->alias, XkbKeyNameLength); @@ -140,7 +140,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge) def.merge = how_merge; memcpy(def.alias, tmp->alias, 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 true; diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 99ed570..758014b 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -44,7 +44,7 @@ typedef struct _SymInterpInfo typedef struct _GroupCompatInfo { - unsigned char fileID; + unsigned file_id; unsigned char merge; bool defined; unsigned char real_mods; @@ -54,7 +54,7 @@ typedef struct _GroupCompatInfo typedef struct _CompatInfo { char *name; - unsigned fileID; + unsigned file_id; int errorCount; int nInterps; SymInterpInfo *interps; @@ -96,18 +96,18 @@ siText(SymInterpInfo * si, CompatInfo * info) } static void -InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap) +InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id) { unsigned int i; info->keymap = keymap; info->name = NULL; - info->fileID = 0; + info->file_id = file_id; info->errorCount = 0; info->nInterps = 0; info->interps = 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.merge = MERGE_OVERRIDE; 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++) info->dflt.interp.act.any.data[i] = 0; 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.merge = MERGE_OVERRIDE; memset(&info->groupCompat[0], 0, @@ -200,7 +200,7 @@ AddInterp(CompatInfo * info, SymInterpInfo * new) if (new->defs.merge == MERGE_REPLACE) { 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)) { WARN("Multiple definitions for \"%s\"\n", siText(new, info)); @@ -266,7 +266,7 @@ AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC) { return true; } - if (((gc->fileID == newGC->fileID) && (warningLevel > 0)) + if (((gc->file_id == newGC->file_id) && (warningLevel > 0)) || (warningLevel > 9)) { 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, &newMerge)) { - InitCompatInfo(&included, keymap); - included.fileID = rtrn->id; + InitCompatInfo(&included, keymap, rtrn->id); included.dflt = info->dflt; - included.dflt.defs.fileID = rtrn->id; included.dflt.defs.merge = newMerge; - included.ledDflt.defs.fileID = rtrn->id; included.ledDflt.defs.merge = newMerge; included.act = info->act; 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, &rtrn, &op)) { - InitCompatInfo(&next_incl, keymap); - next_incl.fileID = rtrn->id; + InitCompatInfo(&next_incl, keymap, rtrn->id); + next_incl.file_id = rtrn->id; 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.ledDflt.defs.fileID = rtrn->id; + next_incl.ledDflt.defs.file_id = rtrn->id; next_incl.ledDflt.defs.merge = op; next_incl.act = info->act; HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); @@ -678,7 +675,7 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap, def->group); return false; } - tmp.fileID = info->fileID; + tmp.file_id = info->file_id; tmp.merge = merge; if (!ExprResolveVModMask(def->def, &val, keymap)) { @@ -785,7 +782,7 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge CompatInfo info; GroupCompatInfo *gcm; - InitCompatInfo(&info, keymap); + InitCompatInfo(&info, keymap, file->id); info.dflt.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++) { - 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].real_mods = gcm->real_mods; keymap->compat->groups[i].vmods = gcm->vmods; diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c index 41b3649..060ed46 100644 --- a/src/xkbcomp/indicators.c +++ b/src/xkbcomp/indicators.c @@ -74,7 +74,7 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new) if (new->defs.merge == MERGE_REPLACE) { 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)) { WARN("Map for indicator %s redefined\n", diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c index 449825b..8751021 100644 --- a/src/xkbcomp/keycodes.c +++ b/src/xkbcomp/keycodes.c @@ -63,7 +63,7 @@ typedef struct _KeyNamesInfo { char *name; /* e.g. evdev+aliases(qwerty) */ int errorCount; - unsigned fileID; + unsigned file_id; enum merge_mode merge; xkb_keycode_t computedMin; /* lowest keycode stored */ xkb_keycode_t computedMax; /* highest keycode stored */ @@ -93,7 +93,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info) { ii->defs.defined = 0; ii->defs.merge = info->merge; - ii->defs.fileID = info->fileID; + ii->defs.file_id = info->file_id; ii->defs.next = NULL; ii->ndx = 0; ii->name = XKB_ATOM_NONE; @@ -163,7 +163,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode old = FindIndicatorByName(info, new->name); if (old) { - if (((old->defs.fileID == new->defs.fileID) && (warningLevel > 0)) + if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0)) || (warningLevel > 9)) { 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); if (old) { - if (((old->defs.fileID == new->defs.fileID) && (warningLevel > 0)) + if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0)) || (warningLevel > 9)) { WARN("Multiple names for indicator %d\n", new->ndx); @@ -286,11 +286,12 @@ ClearKeyNamesInfo(KeyNamesInfo * info) } static void -InitKeyNamesInfo(KeyNamesInfo * info) +InitKeyNamesInfo(KeyNamesInfo * info, unsigned file_id) { info->name = NULL; info->leds = NULL; info->aliases = NULL; + info->file_id = file_id; darray_init(info->names); darray_init(info->files); ClearKeyNamesInfo(info); @@ -316,8 +317,8 @@ FindKeyByLong(KeyNamesInfo * info, unsigned long name) */ static bool AddKeyName(KeyNamesInfo * info, - xkb_keycode_t kc, - char *name, enum merge_mode merge, unsigned fileID, bool reportCollisions) + xkb_keycode_t kc, char *name, enum merge_mode merge, + unsigned file_id, bool reportCollisions) { xkb_keycode_t old; unsigned long lval; @@ -334,7 +335,7 @@ AddKeyName(KeyNamesInfo * info, { reportCollisions = (warningLevel > 7 || (warningLevel > 0 && - fileID == darray_item(info->files, kc))); + file_id == darray_item(info->files, kc))); } if (darray_item(info->names, kc) != 0) @@ -394,7 +395,7 @@ AddKeyName(KeyNamesInfo * info, } } darray_item(info->names, kc) = lval; - darray_item(info->files, kc) = fileID; + darray_item(info->files, kc) = file_id; return true; } @@ -426,7 +427,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap, continue; LongToKeyName(darray_item(from->names, i), buf); buf[4] = '\0'; - if (!AddKeyName(into, i, buf, merge, from->fileID, false)) + if (!AddKeyName(into, i, buf, merge, from->file_id, false)) into->errorCount++; } if (from->leds) @@ -492,7 +493,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn, &newMerge)) { - InitKeyNamesInfo(&included); + InitKeyNamesInfo(&included, rtrn->id); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included); if (stmt->stmt != NULL) { @@ -525,7 +526,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES, &rtrn, &op)) { - InitKeyNamesInfo(&next_incl); + InitKeyNamesInfo(&next_incl, rtrn->id); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); MergeIncludedKeycodes(&included, keymap, &next_incl, op); ClearKeyNamesInfo(&next_incl); @@ -572,7 +573,7 @@ HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info) else 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); } @@ -745,7 +746,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap, info->errorCount++; break; case StmtKeyAliasDef: /* e.g. alias = ; */ - if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->fileID, + if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->file_id, &info->aliases)) info->errorCount++; break; @@ -799,7 +800,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) { KeyNamesInfo info; /* contains all the info after parsing */ - InitKeyNamesInfo(&info); + InitKeyNamesInfo(&info, file->id); HandleKeycodesFile(file, keymap, merge, &info); diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c index c38ac4f..6f83d34 100644 --- a/src/xkbcomp/keytypes.c +++ b/src/xkbcomp/keytypes.c @@ -48,7 +48,7 @@ typedef struct _KeyTypeInfo { CommonInfo defs; xkb_atom_t name; - int fileID; + unsigned file_id; unsigned mask; unsigned vmask; bool groupInfo; @@ -62,7 +62,7 @@ typedef struct _KeyTypesInfo { char *name; int errorCount; - int fileID; + unsigned file_id; unsigned stdPresent; unsigned nTypes; KeyTypeInfo *types; @@ -99,7 +99,7 @@ static xkb_atom_t tok_KEYPAD; static void 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_TWO_LEVEL = xkb_atom_intern(keymap->ctx, "TWO_LEVEL"); @@ -110,8 +110,9 @@ InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap, info->stdPresent = 0; info->nTypes = 0; info->types = NULL; + info->file_id = file_id; 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.next = NULL; info->dflt.name = XKB_ATOM_NONE; @@ -190,7 +191,7 @@ NextKeyType(KeyTypesInfo * info) if (type != NULL) { 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->nTypes++; } @@ -262,7 +263,7 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new) || (new->defs.merge == MERGE_OVERRIDE)) { 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)) { 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; return true; } - report = (old->defs.fileID == new->defs.fileID) && (warningLevel > 0); + report = (old->defs.file_id == new->defs.file_id) && (warningLevel > 0); if (report) { 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, &newMerge)) { - InitKeyTypesInfo(&included, keymap, info); - included.fileID = included.dflt.defs.fileID = rtrn->id; + InitKeyTypesInfo(&included, keymap, info, rtrn->id); included.dflt.defs.merge = newMerge; 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, &rtrn, &op)) { - InitKeyTypesInfo(&next_incl, keymap, &included); - next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id; + InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id); next_incl.dflt.defs.merge = op; HandleKeyTypesFile(rtrn, keymap, op, &next_incl); MergeIncludedKeyTypes(&included, &next_incl, op, keymap); @@ -857,7 +856,7 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap, merge = def->merge; type.defs.defined = 0; - type.defs.fileID = info->fileID; + type.defs.file_id = info->file_id; type.defs.merge = merge; type.defs.next = NULL; type.name = def->name; @@ -1218,8 +1217,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) KeyTypesInfo info; KeyTypeInfo *def; - InitKeyTypesInfo(&info, keymap, NULL); - info.fileID = file->id; + InitKeyTypesInfo(&info, keymap, NULL, file->id); HandleKeyTypesFile(file, keymap, merge, &info); diff --git a/src/xkbcomp/misc.c b/src/xkbcomp/misc.c index 3fcceb1..7f95df2 100644 --- a/src/xkbcomp/misc.c +++ b/src/xkbcomp/misc.c @@ -164,7 +164,7 @@ UseNewField(unsigned field, { if (newDefs->defined & field) { - if (((oldDefs->fileID == newDefs->fileID) + if (((oldDefs->file_id == newDefs->file_id) && (warningLevel > 0)) || (warningLevel > 9)) { *pCollide |= field; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 5d6ad33..ab7f224 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -90,13 +90,13 @@ typedef struct _KeyInfo * Init the given key info to sane values. */ static void -InitKeyInfo(KeyInfo * info) +InitKeyInfo(KeyInfo * info, unsigned file_id) { int i; static const char dflt[4] = "*"; info->defs.defined = 0; - info->defs.fileID = 0; + info->defs.file_id = file_id; info->defs.merge = MERGE_OVERRIDE; info->defs.next = NULL; info->name = KeyNameToLong(dflt); @@ -127,7 +127,7 @@ FreeKeyInfo(KeyInfo * info) int i; info->defs.defined = 0; - info->defs.fileID = 0; + info->defs.file_id = 0; info->defs.merge = MERGE_OVERRIDE; info->defs.next = NULL; info->groupInfo = 0; @@ -200,7 +200,7 @@ typedef struct _SymbolsInfo { char *name; /* e.g. pc+us+inet(evdev) */ int errorCount; - unsigned fileID; + unsigned file_id; enum merge_mode merge; unsigned explicit_group; darray(KeyInfo) keys; @@ -214,21 +214,22 @@ typedef struct _SymbolsInfo } SymbolsInfo; static void -InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap) +InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap, + unsigned file_id) { int i; info->name = NULL; info->explicit_group = 0; info->errorCount = 0; - info->fileID = 0; + info->file_id = file_id; info->merge = MERGE_OVERRIDE; darray_init(info->keys); darray_growalloc(info->keys, 110); info->modMap = NULL; for (i = 0; i < XkbNumKbdGroups; i++) info->groupNames[i] = XKB_ATOM_NONE; - InitKeyInfo(&info->dflt); + InitKeyInfo(&info->dflt, file_id); InitVModInfo(&info->vmods, keymap); info->action = NULL; info->aliases = NULL; @@ -303,7 +304,7 @@ MergeKeyGroups(SymbolsInfo * info, clobber = (from->defs.merge != MERGE_AUGMENT); report = (warningLevel > 9) || - ((into->defs.fileID == from->defs.fileID) && (warningLevel > 0)); + ((into->defs.file_id == from->defs.file_id) && (warningLevel > 0)); darray_init(resultSyms); @@ -533,7 +534,7 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap, return true; } report = ((warningLevel > 9) || - ((into->defs.fileID == from->defs.fileID) + ((into->defs.file_id == from->defs.file_id) && (warningLevel > 0))); 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, &newMerge)) { - InitSymbolsInfo(&included, keymap); - included.fileID = included.dflt.defs.fileID = rtrn->id; + InitSymbolsInfo(&included, keymap, rtrn->id); included.merge = included.dflt.defs.merge = MERGE_OVERRIDE; if (stmt->modifier) { @@ -851,8 +851,7 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS, &rtrn, &op)) { - InitSymbolsInfo(&next_incl, keymap); - next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id; + InitSymbolsInfo(&next_incl, keymap, rtrn->id); next_incl.merge = next_incl.dflt.defs.merge = MERGE_OVERRIDE; if (next->modifier) { @@ -1433,7 +1432,7 @@ HandleSymbolsDef(SymbolsDef *stmt, struct xkb_keymap *keymap, { KeyInfo key; - InitKeyInfo(&key); + InitKeyInfo(&key, info->file_id); CopyKeyInfo(&info->dflt, &key, false); key.defs.merge = stmt->merge; key.name = KeyNameToLong(stmt->keyName); @@ -2086,8 +2085,7 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) SymbolsInfo info; KeyInfo *key; - InitSymbolsInfo(&info, keymap); - info.dflt.defs.fileID = file->id; + InitSymbolsInfo(&info, keymap, file->id); info.dflt.defs.merge = merge; HandleSymbolsFile(file, keymap, merge, &info); diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h index 35d59d4..c7d771a 100644 --- a/src/xkbcomp/xkbcomp-priv.h +++ b/src/xkbcomp/xkbcomp-priv.h @@ -35,7 +35,7 @@ typedef struct _CommonInfo { unsigned short defined; - unsigned char fileID; + unsigned file_id; unsigned char merge; struct _CommonInfo *next; } CommonInfo;