diff --git a/src/context.c b/src/context.c index 2aaee35..190a1c5 100644 --- a/src/context.c +++ b/src/context.c @@ -35,6 +35,9 @@ struct xkb_context { char **include_paths; int num_include_paths; int size_include_paths; + + /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */ + int file_id; }; /** @@ -149,6 +152,12 @@ xkb_context_include_path_get(struct xkb_context *context, unsigned int idx) return context->include_paths[idx]; } +int +xkb_context_take_file_id(struct xkb_context *context) +{ + return context->file_id++; +} + /** * Take a new reference on the context. */ diff --git a/src/xkb-priv.h b/src/xkb-priv.h index 83af402..518abc1 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -437,6 +437,10 @@ extern unsigned int xkb_key_get_syms_by_level(struct xkb_keymap *keymap, xkb_keycode_t key, unsigned int group, unsigned int level, const xkb_keysym_t **syms_out); + +extern int +xkb_context_take_file_id(struct xkb_context *context); + extern bool XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type, unsigned char *map_rtrn); diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y index 5ed0608..ce775b4 100644 --- a/src/xkbcomp/parser.y +++ b/src/xkbcomp/parser.y @@ -175,7 +175,10 @@ XkbCompMapList : XkbCompMapList XkbCompositeMap XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE XkbMapConfigList CBRACE SEMI - { $$= CreateXKBFile($2,$3,&$5->common,$1); } + { + $$ = CreateXKBFile(param->context, $2, $3, + &$5->common, $1); + } ; XkbCompositeType: XKB_KEYMAP { $$= XkmKeymapFile; } @@ -206,7 +209,7 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE } else { - $$= CreateXKBFile($2,$3,$5,$1); + $$ = CreateXKBFile(param->context, $2, $3, $5, $1); } } ; @@ -221,7 +224,7 @@ XkbConfig : OptFlags FileType OptMapName DeclList } else { - $$= CreateXKBFile($2,$3,$4,$1); + $$ = CreateXKBFile(param->context, $2, $3, $4, $1); } } ; diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 8bfafa4..b22a3d5 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -684,10 +684,10 @@ EnsureSafeMapName(char *name) } XkbFile * -CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags) +CreateXKBFile(struct xkb_context *context, int type, char *name, + ParseCommon *defs, unsigned flags) { XkbFile *file; - static int fileID; file = uTypedAlloc(XkbFile); if (file) @@ -698,7 +698,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags) file->topName = uDupString(name); file->name = name; file->defs = defs; - file->id = fileID++; + file->id = xkb_context_take_file_id(context); file->flags = flags; } return file; diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h index 9bcc9fb..4cf21a7 100644 --- a/src/xkbcomp/parseutils.h +++ b/src/xkbcomp/parseutils.h @@ -120,7 +120,7 @@ extern void CheckDefaultMap(XkbFile *maps, const char *fileName); extern XkbFile * -CreateXKBFile(int type, char *name, +CreateXKBFile(struct xkb_context *context, int type, char *name, ParseCommon *defs, unsigned flags); extern bool diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c index c1b7bd0..0ec97ec 100644 --- a/src/xkbcomp/xkbcomp.c +++ b/src/xkbcomp/xkbcomp.c @@ -34,27 +34,32 @@ unsigned int warningLevel = 0; #define ISEMPTY(str) (!(str) || (strlen(str) == 0)) static XkbFile * -XkbKeymapFileFromComponents(const struct xkb_component_names * ktcsg) +XkbKeymapFileFromComponents(struct xkb_context *context, + const struct xkb_component_names *ktcsg) { XkbFile *keycodes, *types, *compat, *symbols; IncludeStmt *inc; inc = IncludeCreate(ktcsg->keycodes, MergeDefault); - keycodes = CreateXKBFile(XkmKeyNamesIndex, NULL, (ParseCommon *)inc, 0); + keycodes = CreateXKBFile(context, XkmKeyNamesIndex, NULL, + (ParseCommon *)inc, 0); inc = IncludeCreate(ktcsg->types, MergeDefault); - types = CreateXKBFile(XkmTypesIndex, NULL, (ParseCommon *)inc, 0); + types = CreateXKBFile(context, XkmTypesIndex, NULL, + (ParseCommon *)inc, 0); AppendStmt(&keycodes->common, &types->common); inc = IncludeCreate(ktcsg->compat, MergeDefault); - compat = CreateXKBFile(XkmCompatMapIndex, NULL, (ParseCommon *)inc, 0); + compat = CreateXKBFile(context, XkmCompatMapIndex, NULL, + (ParseCommon *)inc, 0); AppendStmt(&keycodes->common, &compat->common); inc = IncludeCreate(ktcsg->symbols, MergeDefault); - symbols = CreateXKBFile(XkmSymbolsIndex, NULL, (ParseCommon *)inc, 0); + symbols = CreateXKBFile(context, XkmSymbolsIndex, NULL, + (ParseCommon *)inc, 0); AppendStmt(&keycodes->common, &symbols->common); - return CreateXKBFile(XkmKeymapFile, + return CreateXKBFile(context, XkmKeymapFile, ktcsg->keymap ? ktcsg->keymap : strdup(""), &keycodes->common, 0); } @@ -249,7 +254,7 @@ xkb_map_new_from_kccgst(struct xkb_context *context, return NULL; } - if (!(file = XkbKeymapFileFromComponents(kccgst))) { + if (!(file = XkbKeymapFileFromComponents(context, kccgst))) { ERROR("failed to generate parsed XKB file from components\n"); return NULL; }