Lines Matching +full:- +full:- +full:info

29 #include "xkbcomp-priv.h"
64 InitAliasInfo(AliasInfo *info, enum merge_mode merge, in InitAliasInfo() argument
67 memset(info, 0, sizeof(*info)); in InitAliasInfo()
68 info->merge = merge; in InitAliasInfo()
69 info->alias = alias; in InitAliasInfo()
70 info->real = real; in InitAliasInfo()
74 FindLedByName(KeyNamesInfo *info, xkb_atom_t name, in FindLedByName() argument
77 for (xkb_led_index_t idx = 0; idx < info->num_led_names; idx++) { in FindLedByName()
78 LedNameInfo *ledi = &info->led_names[idx]; in FindLedByName()
79 if (ledi->name == name) { in FindLedByName()
89 AddLedName(KeyNamesInfo *info, enum merge_mode merge, bool same_file, in AddLedName() argument
94 const int verbosity = xkb_context_get_log_verbosity(info->ctx); in AddLedName()
99 old = FindLedByName(info, new->name, &old_idx); in AddLedName()
102 log_warn(info->ctx, in AddLedName()
105 xkb_atom_text(info->ctx, new->name)); in AddLedName()
112 log_warn(info->ctx, in AddLedName()
114 xkb_atom_text(info->ctx, new->name), use, ignore); in AddLedName()
123 if (new_idx >= info->num_led_names) in AddLedName()
124 info->num_led_names = new_idx + 1; in AddLedName()
127 old = &info->led_names[new_idx]; in AddLedName()
128 if (old->name != XKB_ATOM_NONE) { in AddLedName()
130 const xkb_atom_t use = (replace ? new->name : old->name); in AddLedName()
131 const xkb_atom_t ignore = (replace ? old->name : new->name); in AddLedName()
132 log_warn(info->ctx, "Multiple names for indicator %d; " in AddLedName()
134 xkb_atom_text(info->ctx, use), in AddLedName()
135 xkb_atom_text(info->ctx, ignore)); in AddLedName()
149 ClearKeyNamesInfo(KeyNamesInfo *info) in ClearKeyNamesInfo() argument
151 free(info->name); in ClearKeyNamesInfo()
152 darray_free(info->key_names); in ClearKeyNamesInfo()
153 darray_free(info->aliases); in ClearKeyNamesInfo()
157 InitKeyNamesInfo(KeyNamesInfo *info, struct xkb_context *ctx) in InitKeyNamesInfo() argument
159 memset(info, 0, sizeof(*info)); in InitKeyNamesInfo()
160 info->ctx = ctx; in InitKeyNamesInfo()
161 info->min_key_code = XKB_KEYCODE_INVALID; in InitKeyNamesInfo()
168 FindKeyByName(KeyNamesInfo *info, xkb_atom_t name) in FindKeyByName() argument
172 for (i = info->min_key_code; i <= info->max_key_code; i++) in FindKeyByName()
173 if (darray_item(info->key_names, i) == name) in FindKeyByName()
180 AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, in AddKeyName() argument
185 const int verbosity = xkb_context_get_log_verbosity(info->ctx); in AddKeyName()
189 if (kc >= darray_size(info->key_names)) in AddKeyName()
190 darray_resize0(info->key_names, kc + 1); in AddKeyName()
192 info->min_key_code = MIN(info->min_key_code, kc); in AddKeyName()
193 info->max_key_code = MAX(info->max_key_code, kc); in AddKeyName()
196 old_name = darray_item(info->key_names, kc); in AddKeyName()
198 const char *lname = KeyNameText(info->ctx, old_name); in AddKeyName()
199 const char *kname = KeyNameText(info->ctx, name); in AddKeyName()
203 log_warn(info->ctx, in AddKeyName()
211 log_warn(info->ctx, in AddKeyName()
218 log_warn(info->ctx, in AddKeyName()
221 darray_item(info->key_names, kc) = XKB_ATOM_NONE; in AddKeyName()
226 old_kc = FindKeyByName(info, name); in AddKeyName()
228 const char *kname = KeyNameText(info->ctx, name); in AddKeyName()
231 darray_item(info->key_names, old_kc) = XKB_ATOM_NONE; in AddKeyName()
233 log_warn(info->ctx, in AddKeyName()
239 log_vrb(info->ctx, 3, in AddKeyName()
246 darray_item(info->key_names, kc) = name; in AddKeyName()
253 HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge);
259 if (from->errorCount > 0) { in MergeIncludedKeycodes()
260 into->errorCount += from->errorCount; in MergeIncludedKeycodes()
264 if (into->name == NULL) { in MergeIncludedKeycodes()
265 into->name = from->name; in MergeIncludedKeycodes()
266 from->name = NULL; in MergeIncludedKeycodes()
270 if (darray_empty(into->key_names)) { in MergeIncludedKeycodes()
271 into->key_names = from->key_names; in MergeIncludedKeycodes()
272 darray_init(from->key_names); in MergeIncludedKeycodes()
273 into->min_key_code = from->min_key_code; in MergeIncludedKeycodes()
274 into->max_key_code = from->max_key_code; in MergeIncludedKeycodes()
277 if (darray_size(into->key_names) < darray_size(from->key_names)) in MergeIncludedKeycodes()
278 darray_resize0(into->key_names, darray_size(from->key_names)); in MergeIncludedKeycodes()
280 for (unsigned i = from->min_key_code; i <= from->max_key_code; i++) { in MergeIncludedKeycodes()
281 xkb_atom_t name = darray_item(from->key_names, i); in MergeIncludedKeycodes()
286 into->errorCount++; in MergeIncludedKeycodes()
291 if (darray_empty(into->aliases)) { in MergeIncludedKeycodes()
292 into->aliases = from->aliases; in MergeIncludedKeycodes()
293 darray_init(from->aliases); in MergeIncludedKeycodes()
298 darray_foreach(alias, from->aliases) { in MergeIncludedKeycodes()
301 def.merge = (merge == MERGE_DEFAULT ? alias->merge : merge); in MergeIncludedKeycodes()
302 def.alias = alias->alias; in MergeIncludedKeycodes()
303 def.real = alias->real; in MergeIncludedKeycodes()
306 into->errorCount++; in MergeIncludedKeycodes()
311 if (into->num_led_names == 0) { in MergeIncludedKeycodes()
312 memcpy(into->led_names, from->led_names, in MergeIncludedKeycodes()
313 sizeof(*from->led_names) * from->num_led_names); in MergeIncludedKeycodes()
314 into->num_led_names = from->num_led_names; in MergeIncludedKeycodes()
315 from->num_led_names = 0; in MergeIncludedKeycodes()
318 for (xkb_led_index_t idx = 0; idx < from->num_led_names; idx++) { in MergeIncludedKeycodes()
319 LedNameInfo *ledi = &from->led_names[idx]; in MergeIncludedKeycodes()
321 if (ledi->name == XKB_ATOM_NONE) in MergeIncludedKeycodes()
324 ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge); in MergeIncludedKeycodes()
325 if (!AddLedName(into, ledi->merge, false, ledi, idx)) in MergeIncludedKeycodes()
326 into->errorCount++; in MergeIncludedKeycodes()
332 HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge);
335 HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *include) in HandleIncludeKeycodes() argument
339 InitKeyNamesInfo(&included, info->ctx); in HandleIncludeKeycodes()
340 included.name = include->stmt; in HandleIncludeKeycodes()
341 include->stmt = NULL; in HandleIncludeKeycodes()
343 for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) { in HandleIncludeKeycodes()
347 file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_KEYCODES); in HandleIncludeKeycodes()
349 info->errorCount += 10; in HandleIncludeKeycodes()
354 InitKeyNamesInfo(&next_incl, info->ctx); in HandleIncludeKeycodes()
358 MergeIncludedKeycodes(&included, &next_incl, stmt->merge); in HandleIncludeKeycodes()
364 MergeIncludedKeycodes(info, &included, include->merge); in HandleIncludeKeycodes()
367 return (info->errorCount == 0); in HandleIncludeKeycodes()
371 HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge) in HandleKeycodeDef() argument
373 if (stmt->merge != MERGE_DEFAULT) { in HandleKeycodeDef()
374 if (stmt->merge == MERGE_REPLACE) in HandleKeycodeDef()
377 merge = stmt->merge; in HandleKeycodeDef()
380 if (stmt->value < 0 || stmt->value > XKB_KEYCODE_MAX) { in HandleKeycodeDef()
381 log_err(info->ctx, in HandleKeycodeDef()
383 "Key ignored\n", (long long) stmt->value, XKB_KEYCODE_MAX); in HandleKeycodeDef()
387 return AddKeyName(info, (xkb_keycode_t) stmt->value, in HandleKeycodeDef()
388 stmt->name, merge, false, true); in HandleKeycodeDef()
392 HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) in HandleAliasDef() argument
396 darray_foreach(old, info->aliases) { in HandleAliasDef()
397 if (old->alias == def->alias) { in HandleAliasDef()
398 if (def->real == old->real) { in HandleAliasDef()
399 log_vrb(info->ctx, 1, in HandleAliasDef()
402 KeyNameText(info->ctx, def->alias), in HandleAliasDef()
403 KeyNameText(info->ctx, def->real)); in HandleAliasDef()
408 use = (merge == MERGE_AUGMENT ? old->real : def->real); in HandleAliasDef()
409 ignore = (merge == MERGE_AUGMENT ? def->real : old->real); in HandleAliasDef()
411 log_warn(info->ctx, in HandleAliasDef()
414 KeyNameText(info->ctx, old->alias), in HandleAliasDef()
415 KeyNameText(info->ctx, use), in HandleAliasDef()
416 KeyNameText(info->ctx, ignore)); in HandleAliasDef()
418 old->real = use; in HandleAliasDef()
421 old->merge = merge; in HandleAliasDef()
426 InitAliasInfo(&new, merge, def->alias, def->real); in HandleAliasDef()
427 darray_append(info->aliases, new); in HandleAliasDef()
432 HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt) in HandleKeyNameVar() argument
437 if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &arrayNdx)) in HandleKeyNameVar()
441 log_err(info->ctx, "Unknown element %s encountered; " in HandleKeyNameVar()
447 log_err(info->ctx, "Unknown field encountered; " in HandleKeyNameVar()
457 HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def, in HandleLedNameDef() argument
463 if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) { in HandleLedNameDef()
464 info->errorCount++; in HandleLedNameDef()
465 log_err(info->ctx, in HandleLedNameDef()
467 "Ignored\n", def->ndx, XKB_MAX_LEDS); in HandleLedNameDef()
471 if (!ExprResolveString(info->ctx, def->name, &name)) { in HandleLedNameDef()
473 snprintf(buf, sizeof(buf), "%u", def->ndx); in HandleLedNameDef()
474 info->errorCount++; in HandleLedNameDef()
475 return ReportBadType(info->ctx, "indicator", "name", buf, "string"); in HandleLedNameDef()
480 return AddLedName(info, merge, true, &ledi, def->ndx - 1); in HandleLedNameDef()
484 HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge) in HandleKeycodesFile() argument
488 free(info->name); in HandleKeycodesFile()
489 info->name = strdup_safe(file->name); in HandleKeycodesFile()
491 for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) { in HandleKeycodesFile()
492 switch (stmt->type) { in HandleKeycodesFile()
494 ok = HandleIncludeKeycodes(info, (IncludeStmt *) stmt); in HandleKeycodesFile()
497 ok = HandleKeycodeDef(info, (KeycodeDef *) stmt, merge); in HandleKeycodesFile()
500 ok = HandleAliasDef(info, (KeyAliasDef *) stmt, merge); in HandleKeycodesFile()
503 ok = HandleKeyNameVar(info, (VarDef *) stmt); in HandleKeycodesFile()
506 ok = HandleLedNameDef(info, (LedNameDef *) stmt, merge); in HandleKeycodesFile()
509 log_err(info->ctx, in HandleKeycodesFile()
511 "Ignoring %s\n", stmt_type_to_string(stmt->type)); in HandleKeycodesFile()
517 info->errorCount++; in HandleKeycodesFile()
519 if (info->errorCount > 10) { in HandleKeycodesFile()
520 log_err(info->ctx, "Abandoning keycodes file \"%s\"\n", in HandleKeycodesFile()
521 file->name); in HandleKeycodesFile()
530 CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) in CopyKeyNamesToKeymap() argument
535 min_key_code = info->min_key_code; in CopyKeyNamesToKeymap()
536 max_key_code = info->max_key_code; in CopyKeyNamesToKeymap()
550 for (kc = info->min_key_code; kc <= info->max_key_code; kc++) in CopyKeyNamesToKeymap()
551 keys[kc].name = darray_item(info->key_names, kc); in CopyKeyNamesToKeymap()
553 keymap->min_key_code = min_key_code; in CopyKeyNamesToKeymap()
554 keymap->max_key_code = max_key_code; in CopyKeyNamesToKeymap()
555 keymap->keys = keys; in CopyKeyNamesToKeymap()
560 CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) in CopyKeyAliasesToKeymap() argument
568 * because keys and their aliases may be added out-of-order. in CopyKeyAliasesToKeymap()
571 darray_foreach(alias, info->aliases) { in CopyKeyAliasesToKeymap()
572 /* Check that ->real is a key. */ in CopyKeyAliasesToKeymap()
573 if (!XkbKeyByName(keymap, alias->real, false)) { in CopyKeyAliasesToKeymap()
574 log_vrb(info->ctx, 5, in CopyKeyAliasesToKeymap()
575 "Attempt to alias %s to non-existent key %s; Ignored\n", in CopyKeyAliasesToKeymap()
576 KeyNameText(info->ctx, alias->alias), in CopyKeyAliasesToKeymap()
577 KeyNameText(info->ctx, alias->real)); in CopyKeyAliasesToKeymap()
578 alias->real = XKB_ATOM_NONE; in CopyKeyAliasesToKeymap()
582 /* Check that ->alias is not a key. */ in CopyKeyAliasesToKeymap()
583 if (XkbKeyByName(keymap, alias->alias, false)) { in CopyKeyAliasesToKeymap()
584 log_vrb(info->ctx, 5, in CopyKeyAliasesToKeymap()
587 KeyNameText(info->ctx, alias->alias), in CopyKeyAliasesToKeymap()
588 KeyNameText(info->ctx, alias->real)); in CopyKeyAliasesToKeymap()
589 alias->real = XKB_ATOM_NONE; in CopyKeyAliasesToKeymap()
604 darray_foreach(alias, info->aliases) { in CopyKeyAliasesToKeymap()
605 if (alias->real != XKB_ATOM_NONE) { in CopyKeyAliasesToKeymap()
606 key_aliases[i].alias = alias->alias; in CopyKeyAliasesToKeymap()
607 key_aliases[i].real = alias->real; in CopyKeyAliasesToKeymap()
613 keymap->num_key_aliases = num_key_aliases; in CopyKeyAliasesToKeymap()
614 keymap->key_aliases = key_aliases; in CopyKeyAliasesToKeymap()
619 CopyLedNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) in CopyLedNamesToKeymap() argument
621 keymap->num_leds = info->num_led_names; in CopyLedNamesToKeymap()
622 for (xkb_led_index_t idx = 0; idx < info->num_led_names; idx++) { in CopyLedNamesToKeymap()
623 LedNameInfo *ledi = &info->led_names[idx]; in CopyLedNamesToKeymap()
625 if (ledi->name == XKB_ATOM_NONE) in CopyLedNamesToKeymap()
628 keymap->leds[idx].name = ledi->name; in CopyLedNamesToKeymap()
635 CopyKeyNamesInfoToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) in CopyKeyNamesInfoToKeymap() argument
638 if (!CopyKeyNamesToKeymap(keymap, info) || in CopyKeyNamesInfoToKeymap()
639 !CopyKeyAliasesToKeymap(keymap, info) || in CopyKeyNamesInfoToKeymap()
640 !CopyLedNamesToKeymap(keymap, info)) in CopyKeyNamesInfoToKeymap()
643 keymap->keycodes_section_name = strdup_safe(info->name); in CopyKeyNamesInfoToKeymap()
644 XkbEscapeMapName(keymap->keycodes_section_name); in CopyKeyNamesInfoToKeymap()
654 KeyNamesInfo info; in CompileKeycodes() local
656 InitKeyNamesInfo(&info, keymap->ctx); in CompileKeycodes()
658 HandleKeycodesFile(&info, file, merge); in CompileKeycodes()
659 if (info.errorCount != 0) in CompileKeycodes()
662 if (!CopyKeyNamesInfoToKeymap(keymap, &info)) in CompileKeycodes()
665 ClearKeyNamesInfo(&info); in CompileKeycodes()
669 ClearKeyNamesInfo(&info); in CompileKeycodes()