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 {
55 char alias[XkbKeyNameLength + 1];
56 char real[XkbKeyNameLength + 1];
59 typedef struct _IndicatorNameInfo {
66 typedef struct _KeyNamesInfo {
67 char *name; /* e.g. evdev+aliases(qwerty) */
70 enum merge_mode merge;
71 xkb_keycode_t computedMin; /* lowest keycode stored */
72 xkb_keycode_t computedMax; /* highest keycode stored */
73 xkb_keycode_t explicitMin;
74 xkb_keycode_t explicitMax;
75 darray(unsigned long) names;
76 darray(unsigned int) files;
77 IndicatorNameInfo *leds;
82 HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
83 enum merge_mode merge,
87 ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
89 if (newMax < darray_size(info->names))
92 darray_resize0(info->names, newMax + 1);
93 darray_resize0(info->files, newMax + 1);
97 InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
98 char *alias, char *real)
100 memset(info, 0, sizeof(*info));
101 info->def.merge = merge;
102 info->def.file_id = file_id;
103 strncpy(info->alias, alias, XkbKeyNameLength);
104 strncpy(info->real, real, XkbKeyNameLength);
108 InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
110 ii->defs.defined = 0;
111 ii->defs.merge = info->merge;
112 ii->defs.file_id = info->file_id;
113 ii->defs.next = NULL;
115 ii->name = XKB_ATOM_NONE;
120 ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
122 if (ii == info->leds) {
123 ClearCommonInfo(&ii->defs);
128 static IndicatorNameInfo *
129 NextIndicatorName(KeyNamesInfo * info)
131 IndicatorNameInfo *ii;
133 ii = uTypedAlloc(IndicatorNameInfo);
135 InitIndicatorNameInfo(ii, info);
136 info->leds = AddCommonInfo(&info->leds->defs, &ii->defs);
141 static IndicatorNameInfo *
142 FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
144 IndicatorNameInfo *old;
146 for (old = info->leds; old != NULL;
147 old = (IndicatorNameInfo *) old->defs.next) {
154 static IndicatorNameInfo *
155 FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
157 IndicatorNameInfo *old;
159 for (old = info->leds; old != NULL;
160 old = (IndicatorNameInfo *) old->defs.next) {
161 if (old->name == name)
168 AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
169 enum merge_mode merge,
170 IndicatorNameInfo *new)
172 IndicatorNameInfo *old;
175 replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
176 old = FindIndicatorByName(info, new->name);
178 if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
179 || (warningLevel > 9)) {
180 WARN("Multiple indicators named %s\n",
181 xkb_atom_text(keymap->ctx, new->name));
182 if (old->ndx == new->ndx) {
183 if (old->virtual != new->virtual) {
185 old->virtual = new->virtual;
186 ACTION("Using %s instead of %s\n",
187 (old->virtual ? "virtual" : "real"),
188 (old->virtual ? "real" : "virtual"));
191 ACTION("Identical definitions ignored\n");
197 ACTION("Ignoring %d, using %d\n", old->ndx, new->ndx);
199 ACTION("Using %d, ignoring %d\n", old->ndx, new->ndx);
202 if (info->leds == old)
203 info->leds = (IndicatorNameInfo *) old->defs.next;
205 IndicatorNameInfo *tmp;
208 tmp = (IndicatorNameInfo *) tmp->defs.next) {
209 if (tmp->defs.next == (CommonInfo *) old) {
210 tmp->defs.next = old->defs.next;
219 old = FindIndicatorByIndex(info, new->ndx);
221 if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
222 || (warningLevel > 9)) {
223 WARN("Multiple names for indicator %d\n", new->ndx);
224 if ((old->name == new->name) && (old->virtual == new->virtual))
225 ACTION("Identical definitions ignored\n");
227 const char *oldType, *newType;
228 xkb_atom_t using, ignoring;
230 oldType = "virtual indicator";
232 oldType = "real indicator";
234 newType = "virtual indicator";
236 newType = "real indicator";
239 ignoring = old->name;
243 ignoring = new->name;
245 ACTION("Using %s %s, ignoring %s %s\n",
246 oldType, xkb_atom_text(keymap->ctx, using),
247 newType, xkb_atom_text(keymap->ctx, ignoring));
251 old->name = new->name;
252 old->virtual = new->virtual;
257 new = NextIndicatorName(info);
259 WSGO("Couldn't allocate name for indicator %d\n", old->ndx);
263 new->name = old->name;
265 new->virtual = old->virtual;
270 ClearAliases(AliasInfo **info_in)
272 if (info_in && *info_in)
273 ClearCommonInfo(&(*info_in)->def);
277 ClearKeyNamesInfo(KeyNamesInfo * info)
281 info->computedMax = info->explicitMax = info->explicitMin = 0;
282 info->computedMin = XKB_KEYCODE_MAX;
283 darray_free(info->names);
284 darray_free(info->files);
286 ClearIndicatorNameInfo(info->leds, info);
288 ClearAliases(&info->aliases);
292 InitKeyNamesInfo(KeyNamesInfo * info, unsigned file_id)
296 info->aliases = NULL;
297 info->file_id = file_id;
298 darray_init(info->names);
299 darray_init(info->files);
300 ClearKeyNamesInfo(info);
301 info->errorCount = 0;
305 FindKeyByLong(KeyNamesInfo * info, unsigned long name)
309 for (i = info->computedMin; i <= info->computedMax; i++)
310 if (darray_item(info->names, i) == name)
317 * Store the name of the key as a long in the info struct under the given
318 * keycode. If the same keys is referred to twice, print a warning.
319 * Note that the key's name is stored as a long, the keycode is the index.
322 AddKeyName(KeyNamesInfo * info,
323 xkb_keycode_t kc, char *name, enum merge_mode merge,
324 unsigned file_id, bool reportCollisions)
329 ResizeKeyNameArrays(info, kc);
331 if (kc < info->computedMin)
332 info->computedMin = kc;
333 if (kc > info->computedMax)
334 info->computedMax = kc;
335 lval = KeyNameToLong(name);
337 if (reportCollisions) {
338 reportCollisions = (warningLevel > 7 ||
340 file_id == darray_item(info->files, kc)));
343 if (darray_item(info->names, kc) != 0) {
346 LongToKeyName(darray_item(info->names, kc), buf);
348 if (darray_item(info->names, kc) == lval && reportCollisions) {
349 WARN("Multiple identical key name definitions\n");
350 ACTION("Later occurences of \"<%s> = %d\" ignored\n",
354 if (merge == MERGE_AUGMENT) {
355 if (reportCollisions) {
356 WARN("Multiple names for keycode %d\n", kc);
357 ACTION("Using <%s>, ignoring <%s>\n", buf, name);
362 if (reportCollisions) {
363 WARN("Multiple names for keycode %d\n", kc);
364 ACTION("Using <%s>, ignoring <%s>\n", name, buf);
366 darray_item(info->names, kc) = 0;
367 darray_item(info->files, kc) = 0;
370 old = FindKeyByLong(info, lval);
371 if ((old != 0) && (old != kc)) {
372 if (merge == MERGE_OVERRIDE) {
373 darray_item(info->names, old) = 0;
374 darray_item(info->files, old) = 0;
375 if (reportCollisions) {
376 WARN("Key name <%s> assigned to multiple keys\n", name);
377 ACTION("Using %d, ignoring %d\n", kc, old);
381 if ((reportCollisions) && (warningLevel > 3)) {
382 WARN("Key name <%s> assigned to multiple keys\n", name);
383 ACTION("Using %d, ignoring %d\n", old, kc);
388 darray_item(info->names, kc) = lval;
389 darray_item(info->files, kc) = file_id;
393 /***====================================================================***/
396 HandleAliasDef(KeyAliasDef *def, enum merge_mode merge, unsigned file_id,
397 AliasInfo **info_in);
400 MergeAliases(AliasInfo **into, AliasInfo **merge,
401 enum merge_mode how_merge)
415 memset(&def, 0, sizeof(def));
417 for (tmp = *merge; tmp; tmp = (AliasInfo *) tmp->def.next) {
418 if (how_merge == MERGE_DEFAULT)
419 def.merge = tmp->def.merge;
421 def.merge = how_merge;
423 memcpy(def.alias, tmp->alias, XkbKeyNameLength);
424 memcpy(def.real, tmp->real, XkbKeyNameLength);
426 if (!HandleAliasDef(&def, def.merge, tmp->def.file_id, into))
434 MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
435 KeyNamesInfo *from, enum merge_mode merge)
440 if (from->errorCount > 0) {
441 into->errorCount += from->errorCount;
444 if (into->name == NULL) {
445 into->name = from->name;
449 ResizeKeyNameArrays(into, from->computedMax);
451 for (i = from->computedMin; i <= from->computedMax; i++) {
452 if (darray_item(from->names, i) == 0)
454 LongToKeyName(darray_item(from->names, i), buf);
456 if (!AddKeyName(into, i, buf, merge, from->file_id, false))
460 IndicatorNameInfo *led, *next;
461 for (led = from->leds; led != NULL; led = next) {
462 if (merge != MERGE_DEFAULT)
463 led->defs.merge = merge;
464 if (!AddIndicatorName(into, keymap, led->defs.merge, led))
466 next = (IndicatorNameInfo *) led->defs.next;
469 if (!MergeAliases(&into->aliases, &from->aliases, merge))
471 if (from->explicitMin != 0) {
472 if ((into->explicitMin == 0)
473 || (into->explicitMin > from->explicitMin))
474 into->explicitMin = from->explicitMin;
476 if (from->explicitMax > 0) {
477 if ((into->explicitMax == 0)
478 || (into->explicitMax < from->explicitMax))
479 into->explicitMax = from->explicitMax;
484 * Handle the given include statement (e.g. "include "evdev+aliases(qwerty)").
486 * @param stmt The include statement from the keymap file.
487 * @param keymap Unused for all but the keymap->flags.
488 * @param info Struct to store the key info in.
491 HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
494 enum merge_mode newMerge;
496 KeyNamesInfo included;
499 memset(&included, 0, sizeof(included));
502 if ((stmt->file == NULL) && (stmt->map == NULL)) {
505 memset(info, 0, sizeof(KeyNamesInfo));
507 else if (stmt->file && strcmp(stmt->file, "computed") == 0) {
508 keymap->flags |= AutoKeyNames;
509 info->explicitMin = 0;
510 info->explicitMax = XKB_KEYCODE_MAX;
511 return (info->errorCount == 0);
512 } /* parse file, store returned info in the xkb struct */
513 else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
515 InitKeyNamesInfo(&included, rtrn->id);
516 HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
517 if (stmt->stmt != NULL) {
519 included.name = stmt->stmt;
525 info->errorCount += 10; /* XXX: why 10?? */
528 /* Do we have more than one include statement? */
529 if ((stmt->next != NULL) && (included.errorCount < 1)) {
532 KeyNamesInfo next_incl;
534 for (next = stmt->next; next != NULL; next = next->next) {
535 if ((next->file == NULL) && (next->map == NULL)) {
537 MergeIncludedKeycodes(&included, keymap, info, next->merge);
538 ClearKeyNamesInfo(info);
540 else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
542 InitKeyNamesInfo(&next_incl, rtrn->id);
543 HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
544 MergeIncludedKeycodes(&included, keymap, &next_incl, op);
545 ClearKeyNamesInfo(&next_incl);
549 info->errorCount += 10; /* XXX: Why 10?? */
550 ClearKeyNamesInfo(&included);
558 MergeIncludedKeycodes(info, keymap, &included, newMerge);
559 ClearKeyNamesInfo(&included);
561 return (info->errorCount == 0);
565 * Parse the given statement and store the output in the info struct.
569 HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
571 if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
572 (info->explicitMax != 0 && stmt->value > info->explicitMax)) {
573 ERROR("Illegal keycode %lu for name <%s>\n", stmt->value, stmt->name);
574 ACTION("Must be in the range %d-%d inclusive\n",
576 info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
579 if (stmt->merge != MERGE_DEFAULT) {
580 if (stmt->merge == MERGE_REPLACE)
581 merge = MERGE_OVERRIDE;
585 return AddKeyName(info, stmt->value, stmt->name, merge, info->file_id,
590 HandleAliasCollision(AliasInfo *old, AliasInfo *new)
592 if (strncmp(new->real, old->real, XkbKeyNameLength) == 0) {
593 if ((new->def.file_id == old->def.file_id && warningLevel > 0) ||
595 WARN("Alias of %s for %s declared more than once\n",
596 XkbcKeyNameText(new->alias), XkbcKeyNameText(new->real));
597 ACTION("First definition ignored\n");
603 if (new->def.merge == MERGE_AUGMENT) {
612 if ((old->def.file_id == new->def.file_id && warningLevel > 0) ||
614 WARN("Multiple definitions for alias %s\n",
615 XkbcKeyNameText(old->alias));
616 ACTION("Using %s, ignoring %s\n",
617 XkbcKeyNameText(use), XkbcKeyNameText(ignore));
620 if (use != old->real)
621 memcpy(old->real, use, XkbKeyNameLength);
624 old->def.file_id = new->def.file_id;
625 old->def.merge = new->def.merge;
629 HandleAliasDef(KeyAliasDef *def, enum merge_mode merge, unsigned file_id,
634 for (info = *info_in; info; info = (AliasInfo *) info->def.next) {
635 if (strncmp(info->alias, def->alias, XkbKeyNameLength) == 0) {
637 InitAliasInfo(&new, merge, file_id, def->alias, def->real);
638 HandleAliasCollision(info, &new);
643 info = calloc(1, sizeof(*info));
645 WSGO("Allocation failure in HandleAliasDef\n");
649 info->def.file_id = file_id;
650 info->def.merge = merge;
651 info->def.next = (CommonInfo *) *info_in;
652 memcpy(info->alias, def->alias, XkbKeyNameLength);
653 memcpy(info->real, def->real, XkbKeyNameLength);
654 *info_in = AddCommonInfo(&(*info_in)->def, &info->def);
659 #define MIN_KEYCODE_DEF 0
660 #define MAX_KEYCODE_DEF 1
663 * Handle the minimum/maximum statement of the xkb file.
664 * Sets explicitMin/Max of the info struct.
666 * @return 1 on success, 0 otherwise.
669 HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
671 ExprResult tmp, field;
675 if (ExprResolveLhs(keymap, stmt->name, &tmp, &field, &arrayNdx) == 0)
676 return 0; /* internal error, already reported */
678 if (tmp.str != NULL) {
679 ERROR("Unknown element %s encountered\n", tmp.str);
680 ACTION("Default for field %s ignored\n", field.str);
683 if (strcasecmp(field.str, "minimum") == 0)
684 which = MIN_KEYCODE_DEF;
685 else if (strcasecmp(field.str, "maximum") == 0)
686 which = MAX_KEYCODE_DEF;
688 ERROR("Unknown field encountered\n");
689 ACTION("Assigment to field %s ignored\n", field.str);
692 if (arrayNdx != NULL) {
693 ERROR("The %s setting is not an array\n", field.str);
694 ACTION("Illegal array reference ignored\n");
698 if (ExprResolveKeyCode(keymap->ctx, stmt->value, &tmp) == 0) {
699 ACTION("Assignment to field %s ignored\n", field.str);
702 if (tmp.uval > XKB_KEYCODE_MAX) {
704 ("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
705 tmp.uval, 0, XKB_KEYCODE_MAX);
706 ACTION("Value of \"%s\" not changed\n", field.str);
709 if (which == MIN_KEYCODE_DEF) {
710 if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval)) {
712 ("Minimum key code (%d) must be <= maximum key code (%d)\n",
713 tmp.uval, info->explicitMax);
714 ACTION("Minimum key code value not changed\n");
717 if ((info->computedMax > 0) && (info->computedMin < tmp.uval)) {
719 ("Minimum key code (%d) must be <= lowest defined key (%d)\n",
720 tmp.uval, info->computedMin);
721 ACTION("Minimum key code value not changed\n");
724 info->explicitMin = tmp.uval;
726 if (which == MAX_KEYCODE_DEF) {
727 if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval)) {
728 ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
729 tmp.uval, info->explicitMin);
730 ACTION("Maximum code value not changed\n");
733 if ((info->computedMax > 0) && (info->computedMax > tmp.uval)) {
735 ("Maximum code (%d) must be >= highest defined key (%d)\n",
736 tmp.uval, info->computedMax);
737 ACTION("Maximum code value not changed\n");
740 info->explicitMax = tmp.uval;
752 HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
753 enum merge_mode merge, KeyNamesInfo *info)
755 IndicatorNameInfo ii;
758 if ((def->ndx < 1) || (def->ndx > XkbNumIndicators)) {
760 ERROR("Name specified for illegal indicator index %d\n", def->ndx);
764 InitIndicatorNameInfo(&ii, info);
766 if (!ExprResolveString(keymap->ctx, def->name, &tmp)) {
768 snprintf(buf, sizeof(buf), "%d", def->ndx);
770 return ReportBadType("indicator", "name", buf, "string");
772 ii.name = xkb_atom_intern(keymap->ctx, tmp.str);
774 ii.virtual = def->virtual;
775 if (!AddIndicatorName(info, keymap, merge, &ii))
781 * Handle the xkb_keycodes section of a xkb file.
782 * All information about parsed keys is stored in the info struct.
784 * Such a section may have include statements, in which case this function is
785 * semi-recursive (it calls HandleIncludeKeycodes, which may call
786 * HandleKeycodesFile again).
788 * @param file The input file (parsed xkb_keycodes section)
789 * @param xkb Necessary to pass down, may have flags changed.
790 * @param merge Merge strategy (MERGE_OVERRIDE, etc.)
791 * @param info Struct to contain the fully parsed key information.
794 HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
795 enum merge_mode merge, KeyNamesInfo *info)
800 info->name = uDupString(file->name);
804 switch (stmt->stmtType) {
805 case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
806 if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info))
809 case StmtKeycodeDef: /* e.g. <ESC> = 9; */
810 if (!HandleKeycodeDef((KeycodeDef *) stmt, merge, info))
813 case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */
814 if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->file_id,
818 case StmtVarDef: /* e.g. minimum, maximum */
819 if (!HandleKeyNameVar((VarDef *) stmt, keymap, info))
822 case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
823 if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap,
829 ERROR("Keycode files may define key and indicator names only\n");
830 ACTION("Ignoring definition of %s\n",
832 StmtInterpDef) ? "a symbol interpretation" :
833 "virtual modifiers"));
837 WSGO("Unexpected statement type %d in HandleKeycodesFile\n",
842 if (info->errorCount > 10) {
844 ERROR("Too many errors\n");
846 ACTION("Abandoning keycodes file \"%s\"\n", file->topName);
853 ApplyAliases(struct xkb_keymap *keymap, AliasInfo **info_in)
857 struct xkb_key_alias *old, *a;
861 nOld = darray_size(keymap->key_aliases);
862 old = &darray_item(keymap->key_aliases, 0);
864 for (nNew = 0, info = *info_in; info;
865 info = (AliasInfo *) info->def.next) {
868 lname = KeyNameToLong(info->real);
869 key = FindNamedKey(keymap, lname, false, CreateKeyNames(keymap), 0);
871 if (warningLevel > 4) {
872 WARN("Attempt to alias %s to non-existent key %s\n",
873 XkbcKeyNameText(info->alias),
874 XkbcKeyNameText(info->real));
877 info->alias[0] = '\0';
881 lname = KeyNameToLong(info->alias);
882 key = FindNamedKey(keymap, lname, false, false, 0);
884 if (warningLevel > 4) {
885 WARN("Attempt to create alias with the name of a real key\n");
886 ACTION("Alias \"%s = %s\" ignored\n",
887 XkbcKeyNameText(info->alias),
888 XkbcKeyNameText(info->real));
890 info->alias[0] = '\0';
899 for (i = 0, a = old; i < nOld; i++, a++) {
902 if (strncmp(a->alias, info->alias, XkbKeyNameLength) != 0)
905 InitAliasInfo(&old_info, MERGE_AUGMENT, 0, a->alias, a->real);
906 HandleAliasCollision(&old_info, info);
907 memcpy(old_info.real, a->real, XkbKeyNameLength);
908 info->alias[0] = '\0';
917 darray_resize0(keymap->key_aliases, nOld + nNew);
919 a = &darray_item(keymap->key_aliases, nOld);
920 for (info = *info_in; info; info = (AliasInfo *)info->def.next) {
921 if (info->alias[0] != '\0') {
922 strncpy(a->alias, info->alias, XkbKeyNameLength);
923 strncpy(a->real, info->real, XkbKeyNameLength);
929 ClearCommonInfo(&(*info_in)->def);
935 * Compile the xkb_keycodes section, parse it's output, return the results.
937 * @param file The parsed XKB file (may have include statements requiring
939 * @param result The effective keycodes, as gathered from the file.
940 * @param merge Merge strategy.
942 * @return true on success, false otherwise.
945 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
946 enum merge_mode merge)
949 KeyNamesInfo info; /* contains all the info after parsing */
951 InitKeyNamesInfo(&info, file->id);
953 HandleKeycodesFile(file, keymap, merge, &info);
955 /* all the keys are now stored in info */
957 if (info.errorCount != 0)
960 if (info.explicitMin > 0) /* if "minimum" statement was present */
961 keymap->min_key_code = info.explicitMin;
963 keymap->min_key_code = info.computedMin;
965 if (info.explicitMax > 0) /* if "maximum" statement was present */
966 keymap->max_key_code = info.explicitMax;
968 keymap->max_key_code = info.computedMax;
970 darray_resize0(keymap->keys, keymap->max_key_code + 1);
971 for (kc = info.computedMin; kc <= info.computedMax; kc++)
972 LongToKeyName(darray_item(info.names, kc),
973 XkbKey(keymap, kc)->name);
976 keymap->keycodes_section_name = strdup(info.name);
979 IndicatorNameInfo *ii;
981 for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
982 free(keymap->indicator_names[ii->ndx - 1]);
983 keymap->indicator_names[ii->ndx - 1] =
984 xkb_atom_strdup(keymap->ctx, ii->name);
988 ApplyAliases(keymap, &info.aliases);
990 ClearKeyNamesInfo(&info);
994 ClearKeyNamesInfo(&info);