1 /************************************************************
2 * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of Silicon Graphics not be
10 * used in advertising or publicity pertaining to distribution
11 * of the software without specific prior written permission.
12 * Silicon Graphics makes no representation about the suitability
13 * of this software for any purpose. It is provided "as is"
14 * without any express or implied warranty.
16 * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 * THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
29 #include "parseutils.h"
32 longText(unsigned long val)
36 LongToKeyName(val, buf);
37 return XkbcKeyNameText(buf);
40 /***====================================================================***/
43 LongToKeyName(unsigned long val, char *name)
45 name[0] = ((val >> 24) & 0xff);
46 name[1] = ((val >> 16) & 0xff);
47 name[2] = ((val >> 8) & 0xff);
48 name[3] = (val & 0xff);
51 /***====================================================================***/
53 typedef struct _AliasInfo {
54 enum merge_mode merge;
58 char alias[XkbKeyNameLength + 1];
59 char real[XkbKeyNameLength + 1];
62 typedef struct _IndicatorNameInfo {
69 typedef struct _KeyNamesInfo {
70 char *name; /* e.g. evdev+aliases(qwerty) */
73 enum merge_mode merge;
74 xkb_keycode_t computedMin; /* lowest keycode stored */
75 xkb_keycode_t computedMax; /* highest keycode stored */
76 xkb_keycode_t explicitMin;
77 xkb_keycode_t explicitMax;
78 darray(unsigned long) names;
79 darray(unsigned int) files;
80 IndicatorNameInfo *leds;
85 HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
86 enum merge_mode merge,
90 ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
92 if (newMax < darray_size(info->names))
95 darray_resize0(info->names, newMax + 1);
96 darray_resize0(info->files, newMax + 1);
100 InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
101 char *alias, char *real)
103 memset(info, 0, sizeof(*info));
105 info->file_id = file_id;
106 strncpy(info->alias, alias, XkbKeyNameLength);
107 strncpy(info->real, real, XkbKeyNameLength);
111 InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
113 ii->defs.defined = 0;
114 ii->defs.merge = info->merge;
115 ii->defs.file_id = info->file_id;
116 ii->defs.next = NULL;
118 ii->name = XKB_ATOM_NONE;
123 ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
125 if (ii == info->leds) {
126 ClearCommonInfo(&ii->defs);
131 static IndicatorNameInfo *
132 NextIndicatorName(KeyNamesInfo * info)
134 IndicatorNameInfo *ii;
136 ii = uTypedAlloc(IndicatorNameInfo);
138 InitIndicatorNameInfo(ii, info);
139 info->leds = AddCommonInfo(&info->leds->defs, &ii->defs);
144 static IndicatorNameInfo *
145 FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
147 IndicatorNameInfo *old;
149 for (old = info->leds; old != NULL;
150 old = (IndicatorNameInfo *) old->defs.next) {
157 static IndicatorNameInfo *
158 FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
160 IndicatorNameInfo *old;
162 for (old = info->leds; old != NULL;
163 old = (IndicatorNameInfo *) old->defs.next) {
164 if (old->name == name)
171 AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
172 enum merge_mode merge,
173 IndicatorNameInfo *new)
175 IndicatorNameInfo *old;
178 replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
179 old = FindIndicatorByName(info, new->name);
181 if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
182 || (warningLevel > 9)) {
183 WARN("Multiple indicators named %s\n",
184 xkb_atom_text(keymap->ctx, new->name));
185 if (old->ndx == new->ndx) {
186 if (old->virtual != new->virtual) {
188 old->virtual = new->virtual;
189 ACTION("Using %s instead of %s\n",
190 (old->virtual ? "virtual" : "real"),
191 (old->virtual ? "real" : "virtual"));
194 ACTION("Identical definitions ignored\n");
200 ACTION("Ignoring %d, using %d\n", old->ndx, new->ndx);
202 ACTION("Using %d, ignoring %d\n", old->ndx, new->ndx);
205 if (info->leds == old)
206 info->leds = (IndicatorNameInfo *) old->defs.next;
208 IndicatorNameInfo *tmp;
211 tmp = (IndicatorNameInfo *) tmp->defs.next) {
212 if (tmp->defs.next == (CommonInfo *) old) {
213 tmp->defs.next = old->defs.next;
222 old = FindIndicatorByIndex(info, new->ndx);
224 if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
225 || (warningLevel > 9)) {
226 WARN("Multiple names for indicator %d\n", new->ndx);
227 if ((old->name == new->name) && (old->virtual == new->virtual))
228 ACTION("Identical definitions ignored\n");
230 const char *oldType, *newType;
231 xkb_atom_t using, ignoring;
233 oldType = "virtual indicator";
235 oldType = "real indicator";
237 newType = "virtual indicator";
239 newType = "real indicator";
242 ignoring = old->name;
246 ignoring = new->name;
248 ACTION("Using %s %s, ignoring %s %s\n",
249 oldType, xkb_atom_text(keymap->ctx, using),
250 newType, xkb_atom_text(keymap->ctx, ignoring));
254 old->name = new->name;
255 old->virtual = new->virtual;
260 new = NextIndicatorName(info);
262 WSGO("Couldn't allocate name for indicator %d\n", old->ndx);
266 new->name = old->name;
268 new->virtual = old->virtual;
273 ClearKeyNamesInfo(KeyNamesInfo * info)
275 AliasInfo *alias, *next_alias;
279 info->computedMax = info->explicitMax = info->explicitMin = 0;
280 info->computedMin = XKB_KEYCODE_MAX;
281 darray_free(info->names);
282 darray_free(info->files);
284 ClearIndicatorNameInfo(info->leds, info);
285 list_foreach_safe(alias, next_alias, &info->aliases, entry)
290 InitKeyNamesInfo(KeyNamesInfo * info, unsigned file_id)
294 list_init(&info->aliases);
295 info->file_id = file_id;
296 darray_init(info->names);
297 darray_init(info->files);
298 ClearKeyNamesInfo(info);
299 info->errorCount = 0;
303 FindKeyByLong(KeyNamesInfo * info, unsigned long name)
307 for (i = info->computedMin; i <= info->computedMax; i++)
308 if (darray_item(info->names, i) == name)
315 * Store the name of the key as a long in the info struct under the given
316 * keycode. If the same keys is referred to twice, print a warning.
317 * Note that the key's name is stored as a long, the keycode is the index.
320 AddKeyName(KeyNamesInfo * info,
321 xkb_keycode_t kc, char *name, enum merge_mode merge,
322 unsigned file_id, bool reportCollisions)
327 ResizeKeyNameArrays(info, kc);
329 if (kc < info->computedMin)
330 info->computedMin = kc;
331 if (kc > info->computedMax)
332 info->computedMax = kc;
333 lval = KeyNameToLong(name);
335 if (reportCollisions) {
336 reportCollisions = (warningLevel > 7 ||
338 file_id == darray_item(info->files, kc)));
341 if (darray_item(info->names, kc) != 0) {
344 LongToKeyName(darray_item(info->names, kc), buf);
346 if (darray_item(info->names, kc) == lval && reportCollisions) {
347 WARN("Multiple identical key name definitions\n");
348 ACTION("Later occurences of \"<%s> = %d\" ignored\n",
352 if (merge == MERGE_AUGMENT) {
353 if (reportCollisions) {
354 WARN("Multiple names for keycode %d\n", kc);
355 ACTION("Using <%s>, ignoring <%s>\n", buf, name);
360 if (reportCollisions) {
361 WARN("Multiple names for keycode %d\n", kc);
362 ACTION("Using <%s>, ignoring <%s>\n", name, buf);
364 darray_item(info->names, kc) = 0;
365 darray_item(info->files, kc) = 0;
368 old = FindKeyByLong(info, lval);
369 if ((old != 0) && (old != kc)) {
370 if (merge == MERGE_OVERRIDE) {
371 darray_item(info->names, old) = 0;
372 darray_item(info->files, old) = 0;
373 if (reportCollisions) {
374 WARN("Key name <%s> assigned to multiple keys\n", name);
375 ACTION("Using %d, ignoring %d\n", kc, old);
379 if ((reportCollisions) && (warningLevel > 3)) {
380 WARN("Key name <%s> assigned to multiple keys\n", name);
381 ACTION("Using %d, ignoring %d\n", old, kc);
386 darray_item(info->names, kc) = lval;
387 darray_item(info->files, kc) = file_id;
391 /***====================================================================***/
394 HandleAliasDef(KeyAliasDef *def, enum merge_mode merge, unsigned file_id,
398 MergeAliases(KeyNamesInfo *into, KeyNamesInfo *from, enum merge_mode merge)
400 AliasInfo *alias, *next;
403 if (list_empty(&from->aliases))
406 if (list_empty(&into->aliases)) {
407 list_replace(&from->aliases, &into->aliases);
408 list_init(&from->aliases);
412 memset(&def, 0, sizeof(def));
414 list_foreach_safe(alias, next, &from->aliases, entry) {
415 def.merge = (merge == MERGE_DEFAULT) ? alias->merge : merge;
416 memcpy(def.alias, alias->alias, XkbKeyNameLength);
417 memcpy(def.real, alias->real, XkbKeyNameLength);
419 if (!HandleAliasDef(&def, def.merge, alias->file_id, into))
427 MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
428 KeyNamesInfo *from, enum merge_mode merge)
433 if (from->errorCount > 0) {
434 into->errorCount += from->errorCount;
437 if (into->name == NULL) {
438 into->name = from->name;
442 ResizeKeyNameArrays(into, from->computedMax);
444 for (i = from->computedMin; i <= from->computedMax; i++) {
445 if (darray_item(from->names, i) == 0)
447 LongToKeyName(darray_item(from->names, i), buf);
449 if (!AddKeyName(into, i, buf, merge, from->file_id, false))
453 IndicatorNameInfo *led, *next;
454 for (led = from->leds; led != NULL; led = next) {
455 if (merge != MERGE_DEFAULT)
456 led->defs.merge = merge;
457 if (!AddIndicatorName(into, keymap, led->defs.merge, led))
459 next = (IndicatorNameInfo *) led->defs.next;
463 if (!MergeAliases(into, from, merge))
465 if (from->explicitMin != 0) {
466 if ((into->explicitMin == 0)
467 || (into->explicitMin > from->explicitMin))
468 into->explicitMin = from->explicitMin;
470 if (from->explicitMax > 0) {
471 if ((into->explicitMax == 0)
472 || (into->explicitMax < from->explicitMax))
473 into->explicitMax = from->explicitMax;
478 * Handle the given include statement (e.g. "include "evdev+aliases(qwerty)").
480 * @param stmt The include statement from the keymap file.
481 * @param keymap Unused for all but the keymap->flags.
482 * @param info Struct to store the key info in.
485 HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
488 enum merge_mode newMerge;
490 KeyNamesInfo included;
493 memset(&included, 0, sizeof(included));
496 if ((stmt->file == NULL) && (stmt->map == NULL)) {
499 memset(info, 0, sizeof(KeyNamesInfo));
501 else if (stmt->file && strcmp(stmt->file, "computed") == 0) {
502 keymap->flags |= AutoKeyNames;
503 info->explicitMin = 0;
504 info->explicitMax = XKB_KEYCODE_MAX;
505 return (info->errorCount == 0);
506 } /* parse file, store returned info in the xkb struct */
507 else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
509 InitKeyNamesInfo(&included, rtrn->id);
510 HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
511 if (stmt->stmt != NULL) {
513 included.name = stmt->stmt;
519 info->errorCount += 10; /* XXX: why 10?? */
522 /* Do we have more than one include statement? */
523 if ((stmt->next != NULL) && (included.errorCount < 1)) {
526 KeyNamesInfo next_incl;
528 for (next = stmt->next; next != NULL; next = next->next) {
529 if ((next->file == NULL) && (next->map == NULL)) {
531 MergeIncludedKeycodes(&included, keymap, info, next->merge);
532 ClearKeyNamesInfo(info);
534 else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
536 InitKeyNamesInfo(&next_incl, rtrn->id);
537 HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
538 MergeIncludedKeycodes(&included, keymap, &next_incl, op);
539 ClearKeyNamesInfo(&next_incl);
543 info->errorCount += 10; /* XXX: Why 10?? */
544 ClearKeyNamesInfo(&included);
552 MergeIncludedKeycodes(info, keymap, &included, newMerge);
553 ClearKeyNamesInfo(&included);
555 return (info->errorCount == 0);
559 * Parse the given statement and store the output in the info struct.
563 HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
565 if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
566 (info->explicitMax != 0 && stmt->value > info->explicitMax)) {
567 ERROR("Illegal keycode %lu for name <%s>\n", stmt->value, stmt->name);
568 ACTION("Must be in the range %d-%d inclusive\n",
570 info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
573 if (stmt->merge != MERGE_DEFAULT) {
574 if (stmt->merge == MERGE_REPLACE)
575 merge = MERGE_OVERRIDE;
579 return AddKeyName(info, stmt->value, stmt->name, merge, info->file_id,
584 HandleAliasCollision(AliasInfo *old, AliasInfo *new)
586 if (strncmp(new->real, old->real, XkbKeyNameLength) == 0) {
587 if ((new->file_id == old->file_id && warningLevel > 0) ||
589 WARN("Alias of %s for %s declared more than once\n",
590 XkbcKeyNameText(new->alias), XkbcKeyNameText(new->real));
591 ACTION("First definition ignored\n");
597 if (new->merge == MERGE_AUGMENT) {
606 if ((old->file_id == new->file_id && warningLevel > 0) ||
608 WARN("Multiple definitions for alias %s\n",
609 XkbcKeyNameText(old->alias));
610 ACTION("Using %s, ignoring %s\n",
611 XkbcKeyNameText(use), XkbcKeyNameText(ignore));
614 if (use != old->real)
615 memcpy(old->real, use, XkbKeyNameLength);
618 old->file_id = new->file_id;
619 old->merge = new->merge;
623 HandleAliasDef(KeyAliasDef *def, enum merge_mode merge, unsigned file_id,
628 list_foreach(alias, &info->aliases, entry) {
629 if (strncmp(alias->alias, def->alias, XkbKeyNameLength) == 0) {
631 InitAliasInfo(&new, merge, file_id, def->alias, def->real);
632 HandleAliasCollision(alias, &new);
637 alias = calloc(1, sizeof(*alias));
639 WSGO("Allocation failure in HandleAliasDef\n");
643 alias->file_id = file_id;
644 alias->merge = merge;
645 memcpy(alias->alias, def->alias, XkbKeyNameLength);
646 memcpy(alias->real, def->real, XkbKeyNameLength);
647 list_append(&alias->entry, &info->aliases);
652 #define MIN_KEYCODE_DEF 0
653 #define MAX_KEYCODE_DEF 1
656 * Handle the minimum/maximum statement of the xkb file.
657 * Sets explicitMin/Max of the info struct.
659 * @return 1 on success, 0 otherwise.
662 HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
664 ExprResult tmp, field;
668 if (ExprResolveLhs(keymap, stmt->name, &tmp, &field, &arrayNdx) == 0)
669 return 0; /* internal error, already reported */
671 if (tmp.str != NULL) {
672 ERROR("Unknown element %s encountered\n", tmp.str);
673 ACTION("Default for field %s ignored\n", field.str);
676 if (strcasecmp(field.str, "minimum") == 0)
677 which = MIN_KEYCODE_DEF;
678 else if (strcasecmp(field.str, "maximum") == 0)
679 which = MAX_KEYCODE_DEF;
681 ERROR("Unknown field encountered\n");
682 ACTION("Assigment to field %s ignored\n", field.str);
685 if (arrayNdx != NULL) {
686 ERROR("The %s setting is not an array\n", field.str);
687 ACTION("Illegal array reference ignored\n");
691 if (ExprResolveKeyCode(keymap->ctx, stmt->value, &tmp) == 0) {
692 ACTION("Assignment to field %s ignored\n", field.str);
695 if (tmp.uval > XKB_KEYCODE_MAX) {
697 ("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
698 tmp.uval, 0, XKB_KEYCODE_MAX);
699 ACTION("Value of \"%s\" not changed\n", field.str);
702 if (which == MIN_KEYCODE_DEF) {
703 if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval)) {
705 ("Minimum key code (%d) must be <= maximum key code (%d)\n",
706 tmp.uval, info->explicitMax);
707 ACTION("Minimum key code value not changed\n");
710 if ((info->computedMax > 0) && (info->computedMin < tmp.uval)) {
712 ("Minimum key code (%d) must be <= lowest defined key (%d)\n",
713 tmp.uval, info->computedMin);
714 ACTION("Minimum key code value not changed\n");
717 info->explicitMin = tmp.uval;
719 if (which == MAX_KEYCODE_DEF) {
720 if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval)) {
721 ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
722 tmp.uval, info->explicitMin);
723 ACTION("Maximum code value not changed\n");
726 if ((info->computedMax > 0) && (info->computedMax > tmp.uval)) {
728 ("Maximum code (%d) must be >= highest defined key (%d)\n",
729 tmp.uval, info->computedMax);
730 ACTION("Maximum code value not changed\n");
733 info->explicitMax = tmp.uval;
745 HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
746 enum merge_mode merge, KeyNamesInfo *info)
748 IndicatorNameInfo ii;
751 if ((def->ndx < 1) || (def->ndx > XkbNumIndicators)) {
753 ERROR("Name specified for illegal indicator index %d\n", def->ndx);
757 InitIndicatorNameInfo(&ii, info);
759 if (!ExprResolveString(keymap->ctx, def->name, &tmp)) {
761 snprintf(buf, sizeof(buf), "%d", def->ndx);
763 return ReportBadType("indicator", "name", buf, "string");
765 ii.name = xkb_atom_intern(keymap->ctx, tmp.str);
767 ii.virtual = def->virtual;
768 if (!AddIndicatorName(info, keymap, merge, &ii))
774 * Handle the xkb_keycodes section of a xkb file.
775 * All information about parsed keys is stored in the info struct.
777 * Such a section may have include statements, in which case this function is
778 * semi-recursive (it calls HandleIncludeKeycodes, which may call
779 * HandleKeycodesFile again).
781 * @param file The input file (parsed xkb_keycodes section)
782 * @param xkb Necessary to pass down, may have flags changed.
783 * @param merge Merge strategy (MERGE_OVERRIDE, etc.)
784 * @param info Struct to contain the fully parsed key information.
787 HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
788 enum merge_mode merge, KeyNamesInfo *info)
793 info->name = uDupString(file->name);
797 switch (stmt->stmtType) {
798 case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
799 if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info))
802 case StmtKeycodeDef: /* e.g. <ESC> = 9; */
803 if (!HandleKeycodeDef((KeycodeDef *) stmt, merge, info))
806 case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */
807 if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->file_id,
811 case StmtVarDef: /* e.g. minimum, maximum */
812 if (!HandleKeyNameVar((VarDef *) stmt, keymap, info))
815 case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
816 if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap,
822 ERROR("Keycode files may define key and indicator names only\n");
823 ACTION("Ignoring definition of %s\n",
825 StmtInterpDef) ? "a symbol interpretation" :
826 "virtual modifiers"));
830 WSGO("Unexpected statement type %d in HandleKeycodesFile\n",
835 if (info->errorCount > 10) {
837 ERROR("Too many errors\n");
839 ACTION("Abandoning keycodes file \"%s\"\n", file->topName);
846 ApplyAliases(struct xkb_keymap *keymap, KeyNamesInfo *info)
850 struct xkb_key_alias *old, *a;
851 AliasInfo *alias, *next;
854 nOld = darray_size(keymap->key_aliases);
855 old = &darray_item(keymap->key_aliases, 0);
857 list_foreach(alias, &info->aliases, entry) {
860 lname = KeyNameToLong(alias->real);
861 key = FindNamedKey(keymap, lname, false, CreateKeyNames(keymap), 0);
863 if (warningLevel > 4) {
864 WARN("Attempt to alias %s to non-existent key %s\n",
865 XkbcKeyNameText(alias->alias),
866 XkbcKeyNameText(alias->real));
869 alias->alias[0] = '\0';
873 lname = KeyNameToLong(alias->alias);
874 key = FindNamedKey(keymap, lname, false, false, 0);
876 if (warningLevel > 4) {
877 WARN("Attempt to create alias with the name of a real key\n");
878 ACTION("Alias \"%s = %s\" ignored\n",
879 XkbcKeyNameText(alias->alias),
880 XkbcKeyNameText(alias->real));
882 alias->alias[0] = '\0';
891 for (i = 0, a = old; i < nOld; i++, a++) {
894 if (strncmp(a->alias, alias->alias, XkbKeyNameLength) != 0)
897 InitAliasInfo(&old_alias, MERGE_AUGMENT, 0, a->alias, a->real);
898 HandleAliasCollision(&old_alias, alias);
899 memcpy(old_alias.real, a->real, XkbKeyNameLength);
900 alias->alias[0] = '\0';
909 darray_resize0(keymap->key_aliases, nOld + nNew);
911 a = &darray_item(keymap->key_aliases, nOld);
912 list_foreach(alias, &info->aliases, entry) {
913 if (alias->alias[0] != '\0') {
914 strncpy(a->alias, alias->alias, XkbKeyNameLength);
915 strncpy(a->real, alias->real, XkbKeyNameLength);
921 list_foreach_safe(alias, next, &info->aliases, entry)
923 list_init(&info->aliases);
928 * Compile the xkb_keycodes section, parse it's output, return the results.
930 * @param file The parsed XKB file (may have include statements requiring
932 * @param result The effective keycodes, as gathered from the file.
933 * @param merge Merge strategy.
935 * @return true on success, false otherwise.
938 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
939 enum merge_mode merge)
942 KeyNamesInfo info; /* contains all the info after parsing */
944 InitKeyNamesInfo(&info, file->id);
946 HandleKeycodesFile(file, keymap, merge, &info);
948 /* all the keys are now stored in info */
950 if (info.errorCount != 0)
953 if (info.explicitMin > 0) /* if "minimum" statement was present */
954 keymap->min_key_code = info.explicitMin;
956 keymap->min_key_code = info.computedMin;
958 if (info.explicitMax > 0) /* if "maximum" statement was present */
959 keymap->max_key_code = info.explicitMax;
961 keymap->max_key_code = info.computedMax;
963 darray_resize0(keymap->keys, keymap->max_key_code + 1);
964 for (kc = info.computedMin; kc <= info.computedMax; kc++)
965 LongToKeyName(darray_item(info.names, kc),
966 XkbKey(keymap, kc)->name);
969 keymap->keycodes_section_name = strdup(info.name);
972 IndicatorNameInfo *ii;
974 for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
975 free(keymap->indicator_names[ii->ndx - 1]);
976 keymap->indicator_names[ii->ndx - 1] =
977 xkb_atom_strdup(keymap->ctx, ii->name);
981 ApplyAliases(keymap, &info);
983 ClearKeyNamesInfo(&info);
987 ClearKeyNamesInfo(&info);