Make the context available for XkbcAtomGetString In preparation of contextualizing atom handling. Since we touch every function call, we also rename the function to xkb_atom_strdup to match xkb_atom_intern, and be more descriptive. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
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 628
diff --git a/src/atom.c b/src/atom.c
index 0a49ac3..5d785d9 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -101,7 +101,7 @@ XkbcAtomText(xkb_atom_t atom)
}
char *
-XkbcAtomGetString(xkb_atom_t atom)
+xkb_atom_strdup(struct xkb_context *context, xkb_atom_t atom)
{
const char *ret = XkbcAtomText(atom);
return ret ? strdup(ret) : NULL;
diff --git a/src/atom.h b/src/atom.h
index bd80b41..117e82d 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -37,7 +37,7 @@ extern xkb_atom_t
xkb_atom_intern(struct xkb_context *context, const char *string);
extern char *
-XkbcAtomGetString(xkb_atom_t atom);
+xkb_atom_strdup(struct xkb_context *context, xkb_atom_t atom);
extern const char *
XkbcAtomText(xkb_atom_t atm);
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index e5cd6e5..1081f4d 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -791,7 +791,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Data:
if (array_ndx == NULL)
{
- if (!ExprResolveString(value, &rtrn))
+ if (!ExprResolveString(keymap, value, &rtrn))
return ReportMismatch(action->type, field, "string");
else
{
@@ -991,7 +991,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Data:
if (array_ndx == NULL)
{
- if (!ExprResolveString(value, &rtrn))
+ if (!ExprResolveString(keymap, value, &rtrn))
return ReportMismatch(action->type, field, "string");
else
{
@@ -1097,7 +1097,7 @@ HandleActionDef(ExprDef * def,
unsigned tmp, hndlrType;
if (!actionsInitialized)
- ActionsInit(xkb->context);
+ ActionsInit(keymap->context);
if (def->op != ExprActionDecl)
{
@@ -1153,17 +1153,17 @@ HandleActionDef(ExprDef * def,
if ((arg->op == OpNot) || (arg->op == OpInvert))
{
field = arg->value.child;
- constFalse.value.str = xkb_atom_intern(xkb->context, "false");
+ constFalse.value.str = xkb_atom_intern(keymap->context, "false");
value = &constFalse;
}
else
{
field = arg;
- constTrue.value.str = xkb_atom_intern(xkb->context, "true");
+ constTrue.value.str = xkb_atom_intern(keymap->context, "true");
value = &constTrue;
}
}
- if (!ExprResolveLhs(field, &elemRtrn, &fieldRtrn, &arrayRtrn))
+ if (!ExprResolveLhs(keymap, field, &elemRtrn, &fieldRtrn, &arrayRtrn))
return false; /* internal error -- already reported */
if (elemRtrn.str != NULL)
@@ -1202,7 +1202,7 @@ SetActionField(struct xkb_keymap *keymap,
ActionInfo *new, *old;
if (!actionsInitialized)
- ActionsInit(xkb->context);
+ ActionsInit(keymap->context);
new = uTypedAlloc(ActionInfo);
if (new == NULL)
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 78d5771..53214ea 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -115,7 +115,7 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
info->dflt.interp.act.type = XkbSA_NoAction;
for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
info->dflt.interp.act.any.data[i] = 0;
- ClearIndicatorMapInfo(xkb->context, &info->ledDflt);
+ ClearIndicatorMapInfo(keymap->context, &info->ledDflt);
info->ledDflt.defs.fileID = info->fileID;
info->ledDflt.defs.defined = 0;
info->ledDflt.defs.merge = MergeOverride;
@@ -140,7 +140,7 @@ ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
info->dflt.interp.act.type = XkbSA_NoAction;
for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
info->dflt.interp.act.any.data[i] = 0;
- ClearIndicatorMapInfo(xkb->context, &info->ledDflt);
+ ClearIndicatorMapInfo(keymap->context, &info->ledDflt);
info->nInterps = 0;
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
memset(&info->groupCompat[0], 0,
@@ -579,7 +579,7 @@ HandleInterpVar(VarDef * stmt, struct xkb_keymap *keymap, CompatInfo * info)
ExprDef *ndx;
int ret;
- if (ExprResolveLhs(stmt->name, &elem, &field, &ndx) == 0)
+ if (ExprResolveLhs(keymap, stmt->name, &elem, &field, &ndx) == 0)
ret = 0; /* internal error, already reported */
else if (elem.str && (strcasecmp(elem.str, "interpret") == 0))
ret = SetInterpField(&info->dflt, keymap, field.str, ndx, stmt->value,
@@ -610,7 +610,7 @@ HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
ok = HandleInterpVar(def, keymap, info);
continue;
}
- ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
+ ok = ExprResolveLhs(keymap, def->name, &tmp, &field, &arrayNdx);
if (ok) {
ok = SetInterpField(si, keymap, field.str, arrayNdx, def->value,
info);
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index c1626d2..a7740b3 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -128,25 +128,30 @@ exprTypeText(unsigned type)
}
int
-ExprResolveLhs(ExprDef * expr,
- ExprResult * elem_rtrn,
- ExprResult * field_rtrn, ExprDef ** index_rtrn)
+ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
+ ExprResult *elem_rtrn, ExprResult *field_rtrn,
+ ExprDef **index_rtrn)
{
switch (expr->op)
{
case ExprIdent:
elem_rtrn->str = NULL;
- field_rtrn->str = XkbcAtomGetString(expr->value.str);
+ field_rtrn->str = xkb_atom_strdup(keymap->context,
+ expr->value.str);
*index_rtrn = NULL;
return true;
case ExprFieldRef:
- elem_rtrn->str = XkbcAtomGetString(expr->value.field.element);
- field_rtrn->str = XkbcAtomGetString(expr->value.field.field);
+ elem_rtrn->str = xkb_atom_strdup(keymap->context,
+ expr->value.field.element);
+ field_rtrn->str = xkb_atom_strdup(keymap->context,
+ expr->value.field.field);
*index_rtrn = NULL;
return true;
case ExprArrayRef:
- elem_rtrn->str = XkbcAtomGetString(expr->value.array.element);
- field_rtrn->str = XkbcAtomGetString(expr->value.array.field);
+ elem_rtrn->str = xkb_atom_strdup(keymap->context,
+ expr->value.array.element);
+ field_rtrn->str = xkb_atom_strdup(keymap->context,
+ expr->value.array.field);
*index_rtrn = expr->value.array.entry;
return true;
}
@@ -668,8 +673,8 @@ ExprResolveButton(ExprDef * expr,
}
int
-ExprResolveString(ExprDef * expr,
- ExprResult * val_rtrn)
+ExprResolveString(struct xkb_keymap *keymap, ExprDef *expr,
+ ExprResult *val_rtrn)
{
ExprResult leftRtrn, rightRtrn;
ExprDef *left;
@@ -685,7 +690,7 @@ ExprResolveString(ExprDef * expr,
exprTypeText(expr->type));
return false;
}
- val_rtrn->str = XkbcAtomGetString(expr->value.str);
+ val_rtrn->str = xkb_atom_strdup(keymap->context, expr->value.str);
if (val_rtrn->str == NULL)
val_rtrn->str = strdup("");
return true;
@@ -701,8 +706,8 @@ ExprResolveString(ExprDef * expr,
case OpAdd:
left = expr->value.binary.left;
right = expr->value.binary.right;
- if (ExprResolveString(left, &leftRtrn) &&
- ExprResolveString(right, &rightRtrn))
+ if (ExprResolveString(keymap, left, &leftRtrn) &&
+ ExprResolveString(keymap, right, &rightRtrn))
{
int len;
char *new;
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 1f77314..fa115c7 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -38,7 +38,8 @@ typedef union _ExprResult
} ExprResult;
extern int
-ExprResolveLhs(ExprDef *expr, ExprResult *elem_rtrn, ExprResult *field_rtrn,
+ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
+ ExprResult *elem_rtrn, ExprResult *field_rtrn,
ExprDef **index_rtrn);
typedef struct _LookupEntry
@@ -92,7 +93,8 @@ extern int
ExprResolveFloat(ExprDef *expr, ExprResult *val_rtrn);
extern int
-ExprResolveString(ExprDef *expr, ExprResult *val_rtrn);
+ExprResolveString(struct xkb_keymap *keymap, ExprDef *expr,
+ ExprResult *val_rtrn);
extern int
ExprResolveKeyName(ExprDef *expr, ExprResult *val_rtrn);
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index 231fb2f..cbc5669 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -329,7 +329,7 @@ HandleIndicatorMapDef(IndicatorMapDef *def, struct xkb_keymap *keymap,
{
ExprResult elem, field;
ExprDef *arrayNdx;
- if (!ExprResolveLhs(var->name, &elem, &field, &arrayNdx))
+ if (!ExprResolveLhs(keymap, var->name, &elem, &field, &arrayNdx))
{
ok = false;
continue;
@@ -418,7 +418,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
{
free(UNCONSTIFY(keymap->names->indicators[led->indicator - 1]));
keymap->names->indicators[led->indicator-1] =
- XkbcAtomGetString(led->name);
+ xkb_atom_strdup(keymap->context, led->name);
}
free(led);
}
@@ -466,7 +466,7 @@ BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
if (keymap->names->indicators[i] == NULL)
{
keymap->names->indicators[i] =
- XkbcAtomGetString(led->name);
+ xkb_atom_strdup(keymap->context, led->name);
led->indicator = i + 1;
break;
}
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index f05cf1c..a2f6d1f 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -660,13 +660,13 @@ HandleKeycodeDef(KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
* @return 1 on success, 0 otherwise.
*/
static int
-HandleKeyNameVar(VarDef *stmt, KeyNamesInfo *info)
+HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
{
ExprResult tmp, field;
ExprDef *arrayNdx;
int which;
- if (ExprResolveLhs(stmt->name, &tmp, &field, &arrayNdx) == 0)
+ if (ExprResolveLhs(keymap, stmt->name, &tmp, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */
if (tmp.str != NULL)
@@ -754,7 +754,7 @@ err_out:
}
static int
-HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *xkb,
+HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
KeyNamesInfo *info)
{
IndicatorNameInfo ii;
@@ -769,14 +769,14 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *xkb,
}
InitIndicatorNameInfo(&ii, info);
ii.ndx = def->ndx;
- if (!ExprResolveString(def->name, &tmp))
+ if (!ExprResolveString(keymap, def->name, &tmp))
{
char buf[20];
snprintf(buf, sizeof(buf), "%d", def->ndx);
info->errorCount++;
return ReportBadType("indicator", "name", buf, "string");
}
- ii.name = xkb_atom_intern(xkb->context, tmp.str);
+ ii.name = xkb_atom_intern(keymap->context, tmp.str);
free(tmp.str);
ii.virtual = def->virtual;
if (!AddIndicatorName(info, &ii))
@@ -824,7 +824,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
info->errorCount++;
break;
case StmtVarDef: /* e.g. minimum, maximum */
- if (!HandleKeyNameVar((VarDef *) stmt, info))
+ if (!HandleKeyNameVar((VarDef *) stmt, keymap, info))
info->errorCount++;
break;
case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
@@ -910,7 +910,8 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
for (ii = info.leds; ii; ii = (IndicatorNameInfo *)ii->defs.next) {
free(UNCONSTIFY(keymap->names->indicators[ii->ndx - 1]));
- keymap->names->indicators[ii->ndx - 1] = XkbcAtomGetString(ii->name);
+ keymap->names->indicators[ii->ndx - 1] =
+ xkb_atom_strdup(keymap->context, ii->name);
}
}
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 7867d9a..bee7685 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -104,10 +104,10 @@ static void
InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
KeyTypesInfo *from)
{
- tok_ONE_LEVEL = xkb_atom_intern(xkb->context, "ONE_LEVEL");
- tok_TWO_LEVEL = xkb_atom_intern(xkb->context, "TWO_LEVEL");
- tok_ALPHABETIC = xkb_atom_intern(xkb->context, "ALPHABETIC");
- tok_KEYPAD = xkb_atom_intern(xkb->context, "KEYPAD");
+ tok_ONE_LEVEL = xkb_atom_intern(keymap->context, "ONE_LEVEL");
+ tok_TWO_LEVEL = xkb_atom_intern(keymap->context, "TWO_LEVEL");
+ tok_ALPHABETIC = xkb_atom_intern(keymap->context, "ALPHABETIC");
+ tok_KEYPAD = xkb_atom_intern(keymap->context, "KEYPAD");
info->name = strdup("default");
info->errorCount = 0;
info->stdPresent = 0;
@@ -775,7 +775,7 @@ AddLevelName(KeyTypeInfo *type, unsigned level, xkb_atom_t name, bool clobber)
}
static bool
-SetLevelName(KeyTypeInfo *type, struct xkb_keymap *xkb, ExprDef *arrayNdx,
+SetLevelName(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
ExprDef *value)
{
ExprResult rtrn;
@@ -787,14 +787,14 @@ SetLevelName(KeyTypeInfo *type, struct xkb_keymap *xkb, ExprDef *arrayNdx,
if (!ExprResolveLevel(arrayNdx, &rtrn))
return ReportTypeBadType(type, "level name", "integer");
level = rtrn.ival - 1;
- if (!ExprResolveString(value, &rtrn))
+ if (!ExprResolveString(keymap, value, &rtrn))
{
ERROR("Non-string name for level %d in key type %s\n", level + 1,
XkbcAtomText(type->name));
ACTION("Ignoring illegal level name definition\n");
return false;
}
- level_name = xkb_atom_intern(xkb->context, rtrn.str);
+ level_name = xkb_atom_intern(keymap->context, rtrn.str);
free(rtrn.str);
return AddLevelName(type, level, level_name, true);
}
@@ -857,7 +857,7 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
(strcasecmp(field, "level_name") == 0))
{
type->defs.defined |= _KT_LevelNames;
- return SetLevelName(type, xkb, arrayNdx, value);
+ return SetLevelName(type, keymap, arrayNdx, value);
}
ERROR("Unknown field %s in key type %s\n", field, TypeTxt(type));
ACTION("Definition ignored\n");
@@ -870,7 +870,7 @@ HandleKeyTypeVar(VarDef *stmt, struct xkb_keymap *keymap, KeyTypesInfo *info)
ExprResult elem, field;
ExprDef *arrayNdx;
- if (!ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx))
+ if (!ExprResolveLhs(keymap, stmt->name, &elem, &field, &arrayNdx))
return false; /* internal error, already reported */
if (elem.str && (strcasecmp(elem.str, "type") == 0))
return SetKeyTypeField(&info->dflt, keymap, field.str, arrayNdx,
@@ -904,7 +904,7 @@ HandleKeyTypeBody(VarDef *def, struct xkb_keymap *keymap,
ok = HandleKeyTypeVar(def, keymap, info);
continue;
}
- ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
+ ok = ExprResolveLhs(keymap, def->name, &tmp, &field, &arrayNdx);
if (ok) {
ok = SetKeyTypeField(type, keymap, field.str, arrayNdx,
def->value, info);
@@ -1113,7 +1113,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
}
else
type->preserve = NULL;
- type->name = XkbcAtomGetString(def->name);
+ type->name = xkb_atom_strdup(keymap->context, def->name);
if (def->szNames > 0)
{
type->level_names = uTypedCalloc(def->numLevels, const char *);
@@ -1121,7 +1121,8 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
/* assert def->szNames<=def->numLevels */
for (i = 0; i < def->szNames; i++)
{
- type->level_names[i] = XkbcAtomGetString(def->lvlNames[i]);
+ type->level_names[i] = xkb_atom_strdup(keymap->context,
+ def->lvlNames[i]);
}
}
else
@@ -1180,16 +1181,16 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
if (missing & XkbOneLevelMask)
keymap->map->types[XkbOneLevelIndex].name =
- XkbcAtomGetString(tok_ONE_LEVEL);
+ xkb_atom_strdup(keymap->context, tok_ONE_LEVEL);
if (missing & XkbTwoLevelMask)
keymap->map->types[XkbTwoLevelIndex].name =
- XkbcAtomGetString(tok_TWO_LEVEL);
+ xkb_atom_strdup(keymap->context, tok_TWO_LEVEL);
if (missing & XkbAlphabeticMask)
keymap->map->types[XkbAlphabeticIndex].name =
- XkbcAtomGetString(tok_ALPHABETIC);
+ xkb_atom_strdup(keymap->context, tok_ALPHABETIC);
if (missing & XkbKeypadMask)
keymap->map->types[XkbKeypadIndex].name =
- XkbcAtomGetString(tok_KEYPAD);
+ xkb_atom_strdup(keymap->context, tok_KEYPAD);
}
next = &keymap->map->types[XkbLastRequiredType + 1];
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index 4cf21a7..ed706c5 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -128,7 +128,7 @@ XKBParseFile(struct xkb_context *context, FILE *file,
const char *file_name, XkbFile **out);
extern bool
-XKBParseString(struct xkb_context *contex, const char *string,
+XKBParseString(struct xkb_context *context, const char *string,
const char *file_name, XkbFile **out);
extern void
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 4b62f41..f2b3e22 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1180,7 +1180,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
if (strcasecmp(field, "type") == 0)
{
ExprResult ndx;
- if ((!ExprResolveString(value, &tmp))
+ if ((!ExprResolveString(keymap, value, &tmp))
&& (warningLevel > 0))
{
WARN("The type field of a key symbol map must be a string\n");
@@ -1188,7 +1188,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
}
if (arrayNdx == NULL)
{
- key->dfltType = xkb_atom_intern(xkb->context, tmp.str);
+ key->dfltType = xkb_atom_intern(keymap->context, tmp.str);
key->defs.defined |= _Key_Type_Dflt;
}
else if (!ExprResolveGroup(arrayNdx, &ndx))
@@ -1201,7 +1201,8 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
}
else
{
- key->types[ndx.uval - 1] = xkb_atom_intern(xkb->context, tmp.str);
+ key->types[ndx.uval - 1] = xkb_atom_intern(keymap->context,
+ tmp.str);
key->typesDefined |= (1 << (ndx.uval - 1));
}
free(tmp.str);
@@ -1324,7 +1325,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
}
static int
-SetGroupName(SymbolsInfo *info, struct xkb_keymap *xkb, ExprDef *arrayNdx,
+SetGroupName(SymbolsInfo *info, struct xkb_keymap *keymap, ExprDef *arrayNdx,
ExprDef *value)
{
ExprResult tmp, name;
@@ -1341,14 +1342,14 @@ SetGroupName(SymbolsInfo *info, struct xkb_keymap *xkb, ExprDef *arrayNdx,
ACTION("Definition with non-integer array index ignored\n");
return false;
}
- if (!ExprResolveString(value, &name))
+ if (!ExprResolveString(keymap, value, &name))
{
ERROR("Group name must be a string\n");
ACTION("Illegal name for group %d ignored\n", tmp.uval);
return false;
}
info->groupNames[tmp.uval - 1 + info->explicit_group] =
- xkb_atom_intern(xkb->context, name.str);
+ xkb_atom_intern(keymap->context, name.str);
free(name.str);
return true;
@@ -1361,7 +1362,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
ExprDef *arrayNdx;
bool ret;
- if (ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx) == 0)
+ if (ExprResolveLhs(keymap, stmt->name, &elem, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */
if (elem.str && (strcasecmp(elem.str, "key") == 0))
{
@@ -1372,7 +1373,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
(strcasecmp(field.str, "groupname") ==
0)))
{
- ret = SetGroupName(info, xkb, arrayNdx, stmt->value);
+ ret = SetGroupName(info, keymap, arrayNdx, stmt->value);
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupswrap") == 0) ||
@@ -1470,7 +1471,8 @@ HandleSymbolsBody(VarDef *def, struct xkb_keymap *keymap, KeyInfo *key,
}
else
{
- ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
+ ok = ExprResolveLhs(keymap, def->name, &tmp, &field,
+ &arrayNdx);
}
if (ok)
ok = SetSymbolsField(key, keymap, field.str, arrayNdx,
@@ -1729,29 +1731,29 @@ FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn)
* @returns true if a type could be found, false otherwise.
*/
static bool
-FindAutomaticType(struct xkb_keymap *xkb, int width, xkb_keysym_t *syms,
+FindAutomaticType(struct xkb_keymap *keymap, int width, xkb_keysym_t *syms,
xkb_atom_t *typeNameRtrn, bool *autoType)
{
*autoType = false;
if ((width == 1) || (width == 0))
{
- *typeNameRtrn = xkb_atom_intern(xkb->context, "ONE_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "ONE_LEVEL");
*autoType = true;
}
else if (width == 2)
{
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
{
- *typeNameRtrn = xkb_atom_intern(xkb->context, "ALPHABETIC");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "ALPHABETIC");
}
else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
{
- *typeNameRtrn = xkb_atom_intern(xkb->context, "KEYPAD");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "KEYPAD");
*autoType = true;
}
else
{
- *typeNameRtrn = xkb_atom_intern(xkb->context, "TWO_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "TWO_LEVEL");
*autoType = true;
}
}
@@ -1760,15 +1762,15 @@ FindAutomaticType(struct xkb_keymap *xkb, int width, xkb_keysym_t *syms,
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
if (XkbcKSIsLower(syms[2]) && XkbcKSIsUpper(syms[3]))
*typeNameRtrn =
- xkb_atom_intern(xkb->context, "FOUR_LEVEL_ALPHABETIC");
+ xkb_atom_intern(keymap->context, "FOUR_LEVEL_ALPHABETIC");
else
- *typeNameRtrn = xkb_atom_intern(xkb->context,
+ *typeNameRtrn = xkb_atom_intern(keymap->context,
"FOUR_LEVEL_SEMIALPHABETIC");
else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
- *typeNameRtrn = xkb_atom_intern(xkb->context, "FOUR_LEVEL_KEYPAD");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "FOUR_LEVEL_KEYPAD");
else
- *typeNameRtrn = xkb_atom_intern(xkb->context, "FOUR_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(keymap->context, "FOUR_LEVEL");
/* XXX: why not set autoType here? */
}
return ((width >= 0) && (width <= 4));
@@ -1971,7 +1973,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
{
if (key->dfltType != XKB_ATOM_NONE)
key->types[i] = key->dfltType;
- else if (FindAutomaticType(xkb, key->numLevels[i], key->syms[i],
+ else if (FindAutomaticType(keymap, key->numLevels[i], key->syms[i],
&key->types[i], &autoType))
{
}
@@ -2220,7 +2222,8 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
for (i = 0; i < XkbNumKbdGroups; i++) {
if (info.groupNames[i] != XKB_ATOM_NONE) {
free(UNCONSTIFY(keymap->names->groups[i]));
- keymap->names->groups[i] = XkbcAtomGetString(info.groupNames[i]);
+ keymap->names->groups[i] = xkb_atom_strdup(keymap->context,
+ info.groupNames[i]);
}
}
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index f9a08f1..61d16d5 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -127,7 +127,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree);
- names->vmods[nextFree] = XkbcAtomGetString(stmt->name);
+ names->vmods[nextFree] = xkb_atom_strdup(keymap->context, stmt->name);
if (stmt->value == NULL)
return true;
if (ExprResolveModMask(stmt->value, &mod))
@@ -211,7 +211,7 @@ FindKeypadVMod(struct xkb_keymap *keymap)
xkb_atom_t name;
ExprResult rtrn;
- name = xkb_intern_atom(keymap->context, "NumLock");
+ name = xkb_atom_intern(keymap->context, "NumLock");
if (keymap && LookupVModIndex(keymap, name, TypeInt, &rtrn))
{
return rtrn.ival;