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>
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
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 <MENU> = <COMP>; */
- 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;