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 ********************************************************/
28 * Copyright © 2012 Intel Corporation
29 * Copyright © 2012 Ran Benita <ran234@gmail.com>
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
38 * The above copyright notice and this permission notice (including the next
39 * paragraph) shall be included in all copies or substantial portions of the
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48 * DEALINGS IN THE SOFTWARE.
50 * Author: Daniel Stone <daniel@fooishbar.org>
51 * Ran Benita <ran234@gmail.com>
56 #include "xkbcomp-priv.h"
66 KEY_REPEAT_UNDEFINED = 0,
72 GROUP_FIELD_SYMS = (1 << 0),
73 GROUP_FIELD_ACTS = (1 << 1),
74 GROUP_FIELD_TYPE = (1 << 2),
78 KEY_FIELD_REPEAT = (1 << 0),
79 KEY_FIELD_DEFAULT_TYPE = (1 << 1),
80 KEY_FIELD_GROUPINFO = (1 << 2),
81 KEY_FIELD_VMODMAP = (1 << 3),
85 enum group_field defined;
86 darray(struct xkb_level) levels;
91 enum key_field defined;
92 enum merge_mode merge;
96 darray(GroupInfo) groups;
98 enum key_repeat repeat;
99 xkb_mod_mask_t vmodmap;
100 xkb_atom_t default_type;
102 enum xkb_range_exceed_type out_of_range_group_action;
103 xkb_layout_index_t out_of_range_group_number;
107 ClearLevelInfo(struct xkb_level *leveli)
109 if (leveli->num_syms > 1)
110 free(leveli->u.syms);
114 InitGroupInfo(GroupInfo *groupi)
116 memset(groupi, 0, sizeof(*groupi));
120 ClearGroupInfo(GroupInfo *groupi)
122 struct xkb_level *leveli;
123 darray_foreach(leveli, groupi->levels)
124 ClearLevelInfo(leveli);
125 darray_free(groupi->levels);
129 CopyGroupInfo(GroupInfo *to, const GroupInfo *from)
131 to->defined = from->defined;
132 to->type = from->type;
133 darray_init(to->levels);
134 darray_copy(to->levels, from->levels);
135 for (xkb_level_index_t j = 0; j < darray_size(to->levels); j++)
136 if (darray_item(from->levels, j).num_syms > 1)
137 darray_item(to->levels, j).u.syms =
138 memdup(darray_item(from->levels, j).u.syms,
139 darray_item(from->levels, j).num_syms,
140 sizeof(xkb_keysym_t));
144 InitKeyInfo(struct xkb_context *ctx, KeyInfo *keyi)
146 memset(keyi, 0, sizeof(*keyi));
147 keyi->merge = MERGE_OVERRIDE;
148 keyi->name = xkb_atom_intern_literal(ctx, "*");
149 keyi->out_of_range_group_action = RANGE_WRAP;
153 ClearKeyInfo(KeyInfo *keyi)
156 darray_foreach(groupi, keyi->groups)
157 ClearGroupInfo(groupi);
158 darray_free(keyi->groups);
161 /***====================================================================***/
164 enum merge_mode merge;
166 // NOTE: Can also be XKB_MOD_NONE, meaning
167 // “don’t add a modifier to the modmap”.
168 xkb_mod_index_t modifier;
176 char *name; /* e.g. pc+us+inet(evdev) */
178 enum merge_mode merge;
179 xkb_layout_index_t explicit_group;
180 darray(KeyInfo) keys;
182 ActionsInfo *actions;
183 darray(xkb_atom_t) group_names;
184 darray(ModMapEntry) modmaps;
185 struct xkb_mod_set mods;
187 struct xkb_context *ctx;
188 /* Needed for AddKeySymbols. */
189 const struct xkb_keymap *keymap;
193 InitSymbolsInfo(SymbolsInfo *info, const struct xkb_keymap *keymap,
194 ActionsInfo *actions, const struct xkb_mod_set *mods)
196 memset(info, 0, sizeof(*info));
197 info->ctx = keymap->ctx;
198 info->keymap = keymap;
199 info->merge = MERGE_OVERRIDE;
200 InitKeyInfo(keymap->ctx, &info->default_key);
201 info->actions = actions;
203 info->explicit_group = XKB_LAYOUT_INVALID;
207 ClearSymbolsInfo(SymbolsInfo *info)
211 darray_foreach(keyi, info->keys)
213 darray_free(info->keys);
214 darray_free(info->group_names);
215 darray_free(info->modmaps);
216 ClearKeyInfo(&info->default_key);
220 KeyInfoText(SymbolsInfo *info, KeyInfo *keyi)
222 return KeyNameText(info->ctx, keyi->name);
226 MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
227 bool report, xkb_layout_index_t group, xkb_atom_t key_name)
229 xkb_level_index_t i, levels_in_both;
230 struct xkb_level *level;
232 /* First find the type of the merged group. */
233 if (into->type != from->type) {
234 if (from->type == XKB_ATOM_NONE) {
235 /* it's empty for consistency with other comparisons */
237 else if (into->type == XKB_ATOM_NONE) {
238 into->type = from->type;
241 xkb_atom_t use = (clobber ? from->type : into->type);
242 xkb_atom_t ignore = (clobber ? into->type : from->type);
246 XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS,
247 "Multiple definitions for group %d type of key %s; "
248 "Using %s, ignoring %s\n",
249 group + 1, KeyNameText(info->ctx, key_name),
250 xkb_atom_text(info->ctx, use),
251 xkb_atom_text(info->ctx, ignore));
257 into->defined |= (from->defined & GROUP_FIELD_TYPE);
259 /* Now look at the levels. */
261 if (darray_empty(from->levels)) {
266 if (darray_empty(into->levels)) {
267 from->type = into->type;
273 /* Merge the actions and syms. */
274 levels_in_both = MIN(darray_size(into->levels), darray_size(from->levels));
275 for (i = 0; i < levels_in_both; i++) {
276 struct xkb_level *intoLevel = &darray_item(into->levels, i);
277 struct xkb_level *fromLevel = &darray_item(from->levels, i);
279 if (fromLevel->action.type == ACTION_TYPE_NONE) {
280 /* it's empty for consistency with other comparisons */
282 else if (intoLevel->action.type == ACTION_TYPE_NONE) {
283 intoLevel->action = fromLevel->action;
286 union xkb_action *use, *ignore;
287 use = (clobber ? &fromLevel->action : &intoLevel->action);
288 ignore = (clobber ? &intoLevel->action : &fromLevel->action);
292 XKB_WARNING_CONFLICTING_KEY_ACTION,
293 "Multiple actions for level %d/group %u on key %s; "
294 "Using %s, ignoring %s\n",
295 i + 1, group + 1, KeyNameText(info->ctx, key_name),
296 ActionTypeText(use->type),
297 ActionTypeText(ignore->type));
300 intoLevel->action = *use;
303 if (fromLevel->num_syms == 0) {
304 /* it's empty for consistency with other comparisons */
306 else if (intoLevel->num_syms == 0) {
307 intoLevel->num_syms = fromLevel->num_syms;
308 if (fromLevel->num_syms > 1)
309 intoLevel->u.syms = fromLevel->u.syms;
311 intoLevel->u.sym = fromLevel->u.sym;
312 fromLevel->num_syms = 0;
314 else if (!XkbLevelsSameSyms(fromLevel, intoLevel)) {
317 XKB_WARNING_CONFLICTING_KEY_SYMBOL,
318 "Multiple symbols for level %d/group %u on key %s; "
319 "Using %s, ignoring %s\n",
320 i + 1, group + 1, KeyNameText(info->ctx, key_name),
321 (clobber ? "from" : "to"),
322 (clobber ? "to" : "from"));
326 ClearLevelInfo(intoLevel);
327 intoLevel->num_syms = fromLevel->num_syms;
328 if (fromLevel->num_syms > 1)
329 intoLevel->u.syms = fromLevel->u.syms;
331 intoLevel->u.sym = fromLevel->u.sym;
332 fromLevel->num_syms = 0;
336 /* If @from has extra levels, get them as well. */
337 darray_foreach_from(level, from->levels, levels_in_both) {
338 darray_append(into->levels, *level);
341 into->defined |= (from->defined & GROUP_FIELD_ACTS);
342 into->defined |= (from->defined & GROUP_FIELD_SYMS);
348 UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
349 bool clobber, bool report, enum key_field *collide)
352 return (new & field);
366 MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from, bool same_file)
368 xkb_layout_index_t i;
369 xkb_layout_index_t groups_in_both;
370 enum key_field collide = 0;
371 const int verbosity = xkb_context_get_log_verbosity(info->ctx);
372 const bool clobber = (from->merge != MERGE_AUGMENT);
373 const bool report = (same_file && verbosity > 0) || verbosity > 9;
375 if (from->merge == MERGE_REPLACE) {
378 InitKeyInfo(info->ctx, from);
382 groups_in_both = MIN(darray_size(into->groups), darray_size(from->groups));
383 for (i = 0; i < groups_in_both; i++)
385 &darray_item(into->groups, i),
386 &darray_item(from->groups, i),
387 clobber, report, i, into->name);
388 /* If @from has extra groups, just move them to @into. */
389 for (i = groups_in_both; i < darray_size(from->groups); i++) {
390 darray_append(into->groups, darray_item(from->groups, i));
391 InitGroupInfo(&darray_item(from->groups, i));
394 if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
395 clobber, report, &collide)) {
396 into->vmodmap = from->vmodmap;
397 into->defined |= KEY_FIELD_VMODMAP;
399 if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
400 clobber, report, &collide)) {
401 into->repeat = from->repeat;
402 into->defined |= KEY_FIELD_REPEAT;
404 if (UseNewKeyField(KEY_FIELD_DEFAULT_TYPE, into->defined, from->defined,
405 clobber, report, &collide)) {
406 into->default_type = from->default_type;
407 into->defined |= KEY_FIELD_DEFAULT_TYPE;
409 if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
410 clobber, report, &collide)) {
411 into->out_of_range_group_action = from->out_of_range_group_action;
412 into->out_of_range_group_number = from->out_of_range_group_number;
413 into->defined |= KEY_FIELD_GROUPINFO;
418 XKB_WARNING_CONFLICTING_KEY_FIELDS,
419 "Symbol map for key %s redefined; "
420 "Using %s definition for conflicting fields\n",
421 KeyNameText(info->ctx, into->name),
422 (clobber ? "first" : "last"));
426 InitKeyInfo(info->ctx, from);
430 /* TODO: Make it so this function doesn't need the entire keymap. */
432 AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi, bool same_file)
434 xkb_atom_t real_name;
438 * Don't keep aliases in the keys array; this guarantees that
439 * searching for keys to merge with by straight comparison (see the
440 * following loop) is enough, and we won't get multiple KeyInfo's
441 * for the same key because of aliases.
443 real_name = XkbResolveKeyAlias(info->keymap, keyi->name);
444 if (real_name != XKB_ATOM_NONE)
445 keyi->name = real_name;
447 darray_foreach(iter, info->keys)
448 if (iter->name == keyi->name)
449 return MergeKeys(info, iter, keyi, same_file);
451 darray_append(info->keys, *keyi);
452 InitKeyInfo(info->ctx, keyi);
457 AddModMapEntry(SymbolsInfo *info, ModMapEntry *new)
460 bool clobber = (new->merge != MERGE_AUGMENT);
462 darray_foreach(old, info->modmaps) {
463 xkb_mod_index_t use, ignore;
465 if ((new->haveSymbol != old->haveSymbol) ||
466 (new->haveSymbol && new->u.keySym != old->u.keySym) ||
467 (!new->haveSymbol && new->u.keyName != old->u.keyName))
470 if (new->modifier == old->modifier)
473 use = (clobber ? new->modifier : old->modifier);
474 ignore = (clobber ? old->modifier : new->modifier);
476 if (new->haveSymbol) {
478 XKB_WARNING_CONFLICTING_MODMAP,
479 "Symbol \"%s\" added to modifier map for multiple modifiers; "
480 "Using %s, ignoring %s\n",
481 KeysymText(info->ctx, new->u.keySym),
482 ModIndexText(info->ctx, &info->mods, use),
483 ModIndexText(info->ctx, &info->mods, ignore));
486 XKB_WARNING_CONFLICTING_MODMAP,
487 "Key \"%s\" added to modifier map for multiple modifiers; "
488 "Using %s, ignoring %s\n",
489 KeyNameText(info->ctx, new->u.keyName),
490 ModIndexText(info->ctx, &info->mods, use),
491 ModIndexText(info->ctx, &info->mods, ignore));
497 darray_append(info->modmaps, *new);
501 /***====================================================================***/
504 MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
505 enum merge_mode merge)
507 xkb_atom_t *group_name;
508 xkb_layout_index_t group_names_in_both;
510 if (from->errorCount > 0) {
511 into->errorCount += from->errorCount;
515 into->mods = from->mods;
517 if (into->name == NULL) {
518 into->name = from->name;
522 group_names_in_both = MIN(darray_size(into->group_names),
523 darray_size(from->group_names));
524 for (xkb_layout_index_t i = 0; i < group_names_in_both; i++) {
525 if (!darray_item(from->group_names, i))
528 if (merge == MERGE_AUGMENT && darray_item(into->group_names, i))
531 darray_item(into->group_names, i) = darray_item(from->group_names, i);
533 /* If @from has more, get them as well. */
534 darray_foreach_from(group_name, from->group_names, group_names_in_both)
535 darray_append(into->group_names, *group_name);
537 if (darray_empty(into->keys)) {
538 into->keys = from->keys;
539 darray_init(from->keys);
543 darray_foreach(keyi, from->keys) {
544 keyi->merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
545 if (!AddKeySymbols(into, keyi, false))
550 if (darray_empty(into->modmaps)) {
551 into->modmaps = from->modmaps;
552 darray_init(from->modmaps);
556 darray_foreach(mm, from->modmaps) {
557 mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
558 if (!AddModMapEntry(into, mm))
565 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge);
568 HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include)
570 SymbolsInfo included;
572 InitSymbolsInfo(&included, info->keymap, info->actions, &info->mods);
573 included.name = include->stmt;
574 include->stmt = NULL;
576 for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) {
577 SymbolsInfo next_incl;
580 file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_SYMBOLS);
582 info->errorCount += 10;
583 ClearSymbolsInfo(&included);
587 InitSymbolsInfo(&next_incl, info->keymap, info->actions,
589 if (stmt->modifier) {
590 next_incl.explicit_group = atoi(stmt->modifier) - 1;
591 if (next_incl.explicit_group >= XKB_MAX_GROUPS) {
593 XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
594 "Cannot set explicit group to %d - must be between 1..%d; "
595 "Ignoring group number\n",
596 next_incl.explicit_group + 1, XKB_MAX_GROUPS);
597 next_incl.explicit_group = info->explicit_group;
601 next_incl.explicit_group = info->explicit_group;
604 HandleSymbolsFile(&next_incl, file, MERGE_OVERRIDE);
606 MergeIncludedSymbols(&included, &next_incl, stmt->merge);
608 ClearSymbolsInfo(&next_incl);
612 MergeIncludedSymbols(info, &included, include->merge);
613 ClearSymbolsInfo(&included);
615 return (info->errorCount == 0);
622 GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
623 unsigned what, xkb_layout_index_t *ndx_rtrn)
625 const char *name = (what == SYMBOLS ? "symbols" : "actions");
627 if (arrayNdx == NULL) {
628 xkb_layout_index_t i;
630 enum group_field field = (what == SYMBOLS ?
631 GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
633 darray_enumerate(i, groupi, keyi->groups) {
634 if (!(groupi->defined & field)) {
640 if (i >= XKB_MAX_GROUPS) {
642 XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
643 "Too many groups of %s for key %s (max %u); "
644 "Ignoring %s defined for extra groups\n",
645 name, KeyInfoText(info, keyi), XKB_MAX_GROUPS, name);
649 darray_resize0(keyi->groups, darray_size(keyi->groups) + 1);
650 *ndx_rtrn = darray_size(keyi->groups) - 1;
654 if (!ExprResolveGroup(info->ctx, arrayNdx, ndx_rtrn)) {
655 log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
656 "Illegal group index for %s of key %s\n"
657 "Definition with non-integer array index ignored\n",
658 name, KeyInfoText(info, keyi));
663 if (*ndx_rtrn >= darray_size(keyi->groups))
664 darray_resize0(keyi->groups, *ndx_rtrn + 1);
670 AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
673 xkb_layout_index_t ndx;
675 xkb_level_index_t nLevels;
677 if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
680 groupi = &darray_item(keyi->groups, ndx);
683 groupi->defined |= GROUP_FIELD_SYMS;
687 if (value->expr.op != EXPR_KEYSYM_LIST) {
689 XKB_ERROR_WRONG_FIELD_TYPE,
690 "Expected a list of symbols, found %s; "
691 "Ignoring symbols for group %u of %s\n",
692 expr_op_type_to_string(value->expr.op), ndx + 1,
693 KeyInfoText(info, keyi));
697 if (groupi->defined & GROUP_FIELD_SYMS) {
699 XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY,
700 "Symbols for key %s, group %u already defined; "
701 "Ignoring duplicate definition\n",
702 KeyInfoText(info, keyi), ndx + 1);
706 nLevels = darray_size(value->keysym_list.symsMapIndex);
707 if (darray_size(groupi->levels) < nLevels)
708 darray_resize0(groupi->levels, nLevels);
710 groupi->defined |= GROUP_FIELD_SYMS;
712 for (xkb_level_index_t i = 0; i < nLevels; i++) {
713 unsigned int sym_index;
714 struct xkb_level *leveli = &darray_item(groupi->levels, i);
716 sym_index = darray_item(value->keysym_list.symsMapIndex, i);
717 leveli->num_syms = darray_item(value->keysym_list.symsNumEntries, i);
718 if (leveli->num_syms > 1) {
719 leveli->u.syms = calloc(leveli->num_syms, sizeof(*leveli->u.syms));
720 if (!leveli->u.syms) {
721 log_err(info->ctx, "Failed to allocate memory for leveli->u.syms\n");
726 for (unsigned j = 0; j < leveli->num_syms; j++) {
727 xkb_keysym_t keysym = darray_item(value->keysym_list.syms,
730 if (leveli->num_syms == 1) {
731 if (keysym == XKB_KEY_NoSymbol)
732 leveli->num_syms = 0;
734 leveli->u.sym = keysym;
736 else if (leveli->num_syms > 1) {
737 leveli->u.syms[j] = keysym;
746 AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
749 xkb_layout_index_t ndx;
754 if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
757 groupi = &darray_item(keyi->groups, ndx);
760 groupi->defined |= GROUP_FIELD_ACTS;
764 if (value->expr.op != EXPR_ACTION_LIST) {
765 log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
766 "Bad expression type (%d) for action list value; "
767 "Ignoring actions for group %u of %s\n",
768 value->expr.op, ndx, KeyInfoText(info, keyi));
772 if (groupi->defined & GROUP_FIELD_ACTS) {
773 log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
774 "Actions for key %s, group %u already defined\n",
775 KeyInfoText(info, keyi), ndx);
780 for (act = value->actions.actions; act; act = (ExprDef *) act->common.next)
783 if (darray_size(groupi->levels) < nActs)
784 darray_resize0(groupi->levels, nActs);
786 groupi->defined |= GROUP_FIELD_ACTS;
788 act = value->actions.actions;
789 for (unsigned i = 0; i < nActs; i++) {
790 union xkb_action *toAct = &darray_item(groupi->levels, i).action;
792 if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct))
794 XKB_ERROR_INVALID_VALUE,
795 "Illegal action definition for %s; "
796 "Action for group %u/level %u ignored\n",
797 KeyInfoText(info, keyi), ndx + 1, i + 1);
799 act = (ExprDef *) act->common.next;
805 static const LookupEntry repeatEntries[] = {
806 { "true", KEY_REPEAT_YES },
807 { "yes", KEY_REPEAT_YES },
808 { "on", KEY_REPEAT_YES },
809 { "false", KEY_REPEAT_NO },
810 { "no", KEY_REPEAT_NO },
811 { "off", KEY_REPEAT_NO },
812 { "default", KEY_REPEAT_UNDEFINED },
817 SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
818 ExprDef *arrayNdx, ExprDef *value)
820 if (istreq(field, "type")) {
821 xkb_layout_index_t ndx;
824 if (!ExprResolveString(info->ctx, value, &val)) {
826 XKB_ERROR_WRONG_FIELD_TYPE,
827 "The type field of a key symbol map must be a string; "
828 "Ignoring illegal type definition\n");
833 keyi->default_type = val;
834 keyi->defined |= KEY_FIELD_DEFAULT_TYPE;
836 else if (!ExprResolveGroup(info->ctx, arrayNdx, &ndx)) {
837 log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
838 "Illegal group index for type of key %s; "
839 "Definition with non-integer array index ignored\n",
840 KeyInfoText(info, keyi));
845 if (ndx >= darray_size(keyi->groups))
846 darray_resize0(keyi->groups, ndx + 1);
847 darray_item(keyi->groups, ndx).type = val;
848 darray_item(keyi->groups, ndx).defined |= GROUP_FIELD_TYPE;
851 else if (istreq(field, "symbols")) {
852 return AddSymbolsToKey(info, keyi, arrayNdx, value);
854 else if (istreq(field, "actions")) {
855 return AddActionsToKey(info, keyi, arrayNdx, value);
857 else if (istreq(field, "vmods") ||
858 istreq(field, "virtualmods") ||
859 istreq(field, "virtualmodifiers")) {
862 if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods,
865 XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
866 "Expected a virtual modifier mask, found %s; "
867 "Ignoring virtual modifiers definition for key %s\n",
868 expr_op_type_to_string(value->expr.op),
869 KeyInfoText(info, keyi));
873 keyi->vmodmap = mask;
874 keyi->defined |= KEY_FIELD_VMODMAP;
876 else if (istreq(field, "locking") ||
877 istreq(field, "lock") ||
878 istreq(field, "locks")) {
879 log_vrb(info->ctx, 1,
880 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
881 "Key behaviors not supported; "
882 "Ignoring locking specification for key %s\n",
883 KeyInfoText(info, keyi));
885 else if (istreq(field, "radiogroup") ||
886 istreq(field, "permanentradiogroup") ||
887 istreq(field, "allownone")) {
888 log_vrb(info->ctx, 1,
889 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
890 "Radio groups not supported; "
891 "Ignoring radio group specification for key %s\n",
892 KeyInfoText(info, keyi));
894 else if (istreq_prefix("overlay", field) ||
895 istreq_prefix("permanentoverlay", field)) {
896 log_vrb(info->ctx, 1,
897 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
898 "Overlays not supported; "
899 "Ignoring overlay specification for key %s\n",
900 KeyInfoText(info, keyi));
902 else if (istreq(field, "repeating") ||
903 istreq(field, "repeats") ||
904 istreq(field, "repeat")) {
907 if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) {
909 XKB_ERROR_INVALID_VALUE,
910 "Illegal repeat setting for %s; "
911 "Non-boolean repeat setting ignored\n",
912 KeyInfoText(info, keyi));
917 keyi->defined |= KEY_FIELD_REPEAT;
919 else if (istreq(field, "groupswrap") ||
920 istreq(field, "wrapgroups")) {
923 if (!ExprResolveBoolean(info->ctx, value, &set)) {
925 XKB_ERROR_INVALID_VALUE,
926 "Illegal groupsWrap setting for %s; "
927 "Non-boolean value ignored\n",
928 KeyInfoText(info, keyi));
932 keyi->out_of_range_group_action = (set ? RANGE_WRAP : RANGE_SATURATE);
933 keyi->defined |= KEY_FIELD_GROUPINFO;
935 else if (istreq(field, "groupsclamp") ||
936 istreq(field, "clampgroups")) {
939 if (!ExprResolveBoolean(info->ctx, value, &set)) {
941 XKB_ERROR_INVALID_VALUE,
942 "Illegal groupsClamp setting for %s; "
943 "Non-boolean value ignored\n",
944 KeyInfoText(info, keyi));
948 keyi->out_of_range_group_action = (set ? RANGE_SATURATE : RANGE_WRAP);
949 keyi->defined |= KEY_FIELD_GROUPINFO;
951 else if (istreq(field, "groupsredirect") ||
952 istreq(field, "redirectgroups")) {
953 xkb_layout_index_t grp;
955 if (!ExprResolveGroup(info->ctx, value, &grp)) {
956 log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
957 "Illegal group index for redirect of key %s; "
958 "Definition with non-integer group ignored\n",
959 KeyInfoText(info, keyi));
963 keyi->out_of_range_group_action = RANGE_REDIRECT;
964 keyi->out_of_range_group_number = grp - 1;
965 keyi->defined |= KEY_FIELD_GROUPINFO;
969 XKB_ERROR_UNKNOWN_FIELD,
970 "Unknown field %s in a symbol interpretation; "
971 "Definition ignored\n",
980 SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
982 xkb_layout_index_t group, group_to_use;
986 log_vrb(info->ctx, 1,
987 XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX,
988 "You must specify an index when specifying a group name; "
989 "Group name definition without array subscript ignored\n");
993 if (!ExprResolveGroup(info->ctx, arrayNdx, &group)) {
994 log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
995 "Illegal index in group name definition; "
996 "Definition with non-integer array index ignored\n");
1000 if (!ExprResolveString(info->ctx, value, &name)) {
1002 XKB_ERROR_WRONG_FIELD_TYPE,
1003 "Group name must be a string; "
1004 "Illegal name for group %d ignored\n", group);
1008 if (info->explicit_group == XKB_LAYOUT_INVALID) {
1009 group_to_use = group - 1;
1011 else if (group - 1 == 0) {
1012 group_to_use = info->explicit_group;
1016 XKB_WARNING_NON_BASE_GROUP_NAME,
1017 "An explicit group was specified for the '%s' map, "
1018 "but it provides a name for a group other than Group1 (%d); "
1019 "Ignoring group name '%s'\n",
1021 xkb_atom_text(info->ctx, name));
1025 if (group_to_use >= darray_size(info->group_names))
1026 darray_resize0(info->group_names, group_to_use + 1);
1027 darray_item(info->group_names, group_to_use) = name;
1033 HandleGlobalVar(SymbolsInfo *info, VarDef *stmt)
1035 const char *elem, *field;
1039 if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &arrayNdx))
1042 if (elem && istreq(elem, "key")) {
1043 ret = SetSymbolsField(info, &info->default_key, field, arrayNdx,
1046 else if (!elem && (istreq(field, "name") ||
1047 istreq(field, "groupname"))) {
1048 ret = SetGroupName(info, arrayNdx, stmt->value);
1050 else if (!elem && (istreq(field, "groupswrap") ||
1051 istreq(field, "wrapgroups"))) {
1053 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
1054 "Global \"groupswrap\" not supported; Ignored\n");
1057 else if (!elem && (istreq(field, "groupsclamp") ||
1058 istreq(field, "clampgroups"))) {
1060 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
1061 "Global \"groupsclamp\" not supported; Ignored\n");
1064 else if (!elem && (istreq(field, "groupsredirect") ||
1065 istreq(field, "redirectgroups"))) {
1067 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
1068 "Global \"groupsredirect\" not supported; Ignored\n");
1071 else if (!elem && istreq(field, "allownone")) {
1073 XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
1074 "Radio groups not supported; "
1075 "Ignoring \"allownone\" specification\n");
1079 ret = SetActionField(info->ctx, info->actions, &info->mods,
1080 elem, field, arrayNdx, stmt->value);
1087 HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
1090 const char *elem, *field;
1093 for (; def; def = (VarDef *) def->common.next) {
1094 if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
1096 XKB_ERROR_WRONG_SCOPE,
1097 "Cannot set a global default value from within a key statement; "
1098 "Move statements to the global file scope\n");
1103 if (!def->value || def->value->expr.op == EXPR_KEYSYM_LIST)
1110 ok = ExprResolveLhs(info->ctx, def->name, &elem, &field,
1115 ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
1122 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
1124 xkb_layout_index_t i;
1128 if (info->explicit_group == XKB_LAYOUT_INVALID)
1131 darray_enumerate_from(i, groupi, keyi->groups, 1) {
1132 if (groupi->defined) {
1134 ClearGroupInfo(groupi);
1135 InitGroupInfo(groupi);
1141 XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE,
1142 "For the map %s an explicit group specified, "
1143 "but key %s has more than one group defined; "
1144 "All groups except first one will be ignored\n",
1145 info->name, KeyInfoText(info, keyi));
1148 darray_resize0(keyi->groups, info->explicit_group + 1);
1149 if (info->explicit_group > 0) {
1150 darray_item(keyi->groups, info->explicit_group) =
1151 darray_item(keyi->groups, 0);
1152 InitGroupInfo(&darray_item(keyi->groups, 0));
1159 HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
1163 keyi = info->default_key;
1164 darray_init(keyi.groups);
1165 darray_copy(keyi.groups, info->default_key.groups);
1166 for (xkb_layout_index_t i = 0; i < darray_size(keyi.groups); i++)
1167 CopyGroupInfo(&darray_item(keyi.groups, i),
1168 &darray_item(info->default_key.groups, i));
1169 keyi.merge = stmt->merge;
1170 keyi.name = stmt->keyName;
1172 if (!HandleSymbolsBody(info, stmt->symbols, &keyi)) {
1177 if (!SetExplicitGroup(info, &keyi)) {
1182 if (!AddKeySymbols(info, &keyi, true)) {
1191 HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
1194 xkb_mod_index_t ndx;
1196 struct xkb_context *ctx = info->ctx;
1197 const char *modifier_name = xkb_atom_text(ctx, def->modifier);
1199 if (istreq(modifier_name, "none")) {
1200 // Handle special "None" entry
1203 // Handle normal entry
1204 ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL);
1205 if (ndx == XKB_MOD_INVALID) {
1207 XKB_ERROR_INVALID_REAL_MODIFIER,
1208 "Illegal modifier map definition; "
1209 "Ignoring map for non-modifier \"%s\"\n",
1210 xkb_atom_text(ctx, def->modifier));
1217 tmp.merge = def->merge;
1219 for (ExprDef *key = def->keys; key; key = (ExprDef *) key->common.next) {
1222 if (key->expr.op == EXPR_VALUE &&
1223 key->expr.value_type == EXPR_TYPE_KEYNAME) {
1224 tmp.haveSymbol = false;
1225 tmp.u.keyName = key->key_name.key_name;
1227 else if (ExprResolveKeySym(ctx, key, &sym)) {
1228 tmp.haveSymbol = true;
1233 XKB_ERROR_INVALID_MODMAP_ENTRY,
1234 "Modmap entries may contain only key names or keysyms; "
1235 "Illegal definition for %s modifier ignored\n",
1236 ModIndexText(info->ctx, &info->mods, tmp.modifier));
1240 ok = AddModMapEntry(info, &tmp) && ok;
1246 HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
1251 info->name = strdup_safe(file->name);
1253 for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) {
1254 switch (stmt->type) {
1256 ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
1259 ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
1262 ok = HandleGlobalVar(info, (VarDef *) stmt);
1265 ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge);
1268 ok = HandleModMapDef(info, (ModMapDef *) stmt);
1272 XKB_ERROR_WRONG_STATEMENT_TYPE,
1273 "Symbols files may not include other types; "
1274 "Ignoring %s\n", stmt_type_to_string(stmt->type));
1282 if (info->errorCount > 10) {
1284 XKB_ERROR_INVALID_SYNTAX,
1285 "Abandoning symbols file \"%s\"\n",
1293 * Given a keysym @sym, return a key which generates it, or NULL.
1294 * This is used for example in a modifier map definition, such as:
1295 * modifier_map Lock { Caps_Lock };
1296 * where we want to add the Lock modifier to the modmap of the key
1297 * which matches the keysym Caps_Lock.
1298 * Since there can be many keys which generates the keysym, the key
1299 * is chosen first by lowest group in which the keysym appears, than
1300 * by lowest level and than by lowest key code.
1302 static struct xkb_key *
1303 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
1305 struct xkb_key *key;
1306 xkb_layout_index_t group;
1307 bool got_one_group, got_one_level;
1311 xkb_level_index_t level = 0;
1312 got_one_group = false;
1314 got_one_level = false;
1315 xkb_keys_foreach(key, keymap) {
1316 if (group < key->num_groups &&
1317 level < XkbKeyNumLevels(key, group)) {
1318 got_one_group = got_one_level = true;
1319 if (key->groups[group].levels[level].num_syms == 1 &&
1320 key->groups[group].levels[level].u.sym == sym)
1325 } while (got_one_level);
1327 } while (got_one_group);
1333 * Find an appropriate type for a group and return its name.
1336 * - ONE_LEVEL for width 0/1
1337 * - ALPHABETIC for 2 shift levels, with lower/upercase keysyms
1338 * - KEYPAD for keypad keys.
1339 * - TWO_LEVEL for other 2 shift level keys.
1340 * and the same for four level keys.
1342 * FIXME: Decide how to handle multiple-syms-per-level, and do it.
1345 FindAutomaticType(struct xkb_context *ctx, GroupInfo *groupi)
1347 xkb_keysym_t sym0, sym1;
1348 const xkb_level_index_t width = darray_size(groupi->levels);
1350 #define GET_SYM(level) \
1351 (darray_item(groupi->levels, level).num_syms == 0 ? \
1352 XKB_KEY_NoSymbol : \
1353 darray_item(groupi->levels, level).num_syms == 1 ? \
1354 darray_item(groupi->levels, level).u.sym : \
1355 /* num_syms > 1 */ \
1356 darray_item(groupi->levels, level).u.syms[0])
1358 if (width == 1 || width <= 0)
1359 return xkb_atom_intern_literal(ctx, "ONE_LEVEL");
1365 if (xkb_keysym_is_lower(sym0) && xkb_keysym_is_upper(sym1))
1366 return xkb_atom_intern_literal(ctx, "ALPHABETIC");
1368 if (xkb_keysym_is_keypad(sym0) || xkb_keysym_is_keypad(sym1))
1369 return xkb_atom_intern_literal(ctx, "KEYPAD");
1371 return xkb_atom_intern_literal(ctx, "TWO_LEVEL");
1375 if (xkb_keysym_is_lower(sym0) && xkb_keysym_is_upper(sym1)) {
1376 xkb_keysym_t sym2, sym3;
1378 sym3 = (width == 4 ? GET_SYM(3) : XKB_KEY_NoSymbol);
1380 if (xkb_keysym_is_lower(sym2) && xkb_keysym_is_upper(sym3))
1381 return xkb_atom_intern_literal(ctx, "FOUR_LEVEL_ALPHABETIC");
1383 return xkb_atom_intern_literal(ctx, "FOUR_LEVEL_SEMIALPHABETIC");
1386 if (xkb_keysym_is_keypad(sym0) || xkb_keysym_is_keypad(sym1))
1387 return xkb_atom_intern_literal(ctx, "FOUR_LEVEL_KEYPAD");
1389 return xkb_atom_intern_literal(ctx, "FOUR_LEVEL");
1392 return XKB_ATOM_NONE;
1397 static const struct xkb_key_type *
1398 FindTypeForGroup(struct xkb_keymap *keymap, KeyInfo *keyi,
1399 xkb_layout_index_t group, bool *explicit_type)
1402 GroupInfo *groupi = &darray_item(keyi->groups, group);
1403 xkb_atom_t type_name = groupi->type;
1405 *explicit_type = true;
1407 if (type_name == XKB_ATOM_NONE) {
1408 if (keyi->default_type != XKB_ATOM_NONE) {
1409 type_name = keyi->default_type;
1412 type_name = FindAutomaticType(keymap->ctx, groupi);
1413 if (type_name != XKB_ATOM_NONE)
1414 *explicit_type = false;
1418 if (type_name == XKB_ATOM_NONE) {
1419 log_warn(keymap->ctx,
1420 XKB_WARNING_CANNOT_INFER_KEY_TYPE,
1421 "Couldn't find an automatic type for key '%s' group %d with %lu levels; "
1422 "Using the default type\n",
1423 KeyNameText(keymap->ctx, keyi->name), group + 1,
1424 (unsigned long) darray_size(groupi->levels));
1428 for (i = 0; i < keymap->num_types; i++)
1429 if (keymap->types[i].name == type_name)
1432 if (i >= keymap->num_types) {
1433 log_warn(keymap->ctx,
1434 XKB_WARNING_UNDEFINED_KEY_TYPE,
1435 "The type \"%s\" for key '%s' group %d was not previously defined; "
1436 "Using the default type\n",
1437 xkb_atom_text(keymap->ctx, type_name),
1438 KeyNameText(keymap->ctx, keyi->name), group + 1);
1442 return &keymap->types[i];
1446 * Index 0 is guaranteed to contain something, usually
1447 * ONE_LEVEL or at least some default one-level type.
1449 return &keymap->types[0];
1453 CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
1456 struct xkb_key *key;
1458 const GroupInfo *group0;
1459 xkb_layout_index_t i;
1462 * The name is guaranteed to be real and not an alias (see
1463 * AddKeySymbols), so 'false' is safe here.
1465 key = XkbKeyByName(keymap, keyi->name, false);
1467 log_vrb(info->ctx, 5,
1468 XKB_WARNING_UNDEFINED_KEYCODE,
1469 "Key %s not found in keycodes; Symbols ignored\n",
1470 KeyInfoText(info, keyi));
1474 /* Find the range of groups we need. */
1475 key->num_groups = 0;
1476 darray_enumerate(i, groupi, keyi->groups)
1477 if (groupi->defined)
1478 key->num_groups = i + 1;
1480 if (key->num_groups <= 0)
1481 return false; /* WSGO */
1483 darray_resize(keyi->groups, key->num_groups);
1486 * If there are empty groups between non-empty ones, fill them with data
1487 * from the first group.
1488 * We can make a wrong assumption here. But leaving gaps is worse.
1490 group0 = &darray_item(keyi->groups, 0);
1491 darray_foreach_from(groupi, keyi->groups, 1) {
1492 if (groupi->defined)
1495 CopyGroupInfo(groupi, group0);
1498 key->groups = calloc(key->num_groups, sizeof(*key->groups));
1500 log_err(info->ctx, "Failed to allocate memory for key->groups\n");
1504 /* Find and assign the groups' types in the keymap. */
1505 darray_enumerate(i, groupi, keyi->groups) {
1506 const struct xkb_key_type *type;
1509 type = FindTypeForGroup(keymap, keyi, i, &explicit_type);
1511 /* Always have as many levels as the type specifies. */
1512 if (type->num_levels < darray_size(groupi->levels)) {
1513 struct xkb_level *leveli;
1515 log_vrb(info->ctx, 1,
1516 XKB_WARNING_EXTRA_SYMBOLS_IGNORED,
1517 "Type \"%s\" has %d levels, but %s has %d levels; "
1518 "Ignoring extra symbols\n",
1519 xkb_atom_text(keymap->ctx, type->name), type->num_levels,
1520 KeyInfoText(info, keyi),
1521 (int) darray_size(groupi->levels));
1523 darray_foreach_from(leveli, groupi->levels, type->num_levels)
1524 ClearLevelInfo(leveli);
1526 darray_resize0(groupi->levels, type->num_levels);
1528 key->groups[i].explicit_type = explicit_type;
1529 key->groups[i].type = type;
1533 darray_enumerate(i, groupi, keyi->groups)
1534 darray_steal(groupi->levels, &key->groups[i].levels, NULL);
1536 key->out_of_range_group_number = keyi->out_of_range_group_number;
1537 key->out_of_range_group_action = keyi->out_of_range_group_action;
1539 if (keyi->defined & KEY_FIELD_VMODMAP) {
1540 key->vmodmap = keyi->vmodmap;
1541 key->explicit |= EXPLICIT_VMODMAP;
1544 if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
1545 key->repeats = (keyi->repeat == KEY_REPEAT_YES);
1546 key->explicit |= EXPLICIT_REPEAT;
1549 darray_foreach(groupi, keyi->groups) {
1550 if (groupi->defined & GROUP_FIELD_ACTS) {
1551 key->explicit |= EXPLICIT_INTERP;
1560 CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
1563 struct xkb_key *key;
1565 if (!entry->haveSymbol) {
1566 key = XkbKeyByName(keymap, entry->u.keyName, true);
1568 log_vrb(info->ctx, 5,
1569 XKB_WARNING_UNDEFINED_KEYCODE,
1570 "Key %s not found in keycodes; "
1571 "Modifier map entry for %s not updated\n",
1572 KeyNameText(info->ctx, entry->u.keyName),
1573 ModIndexText(info->ctx, &info->mods, entry->modifier));
1578 key = FindKeyForSymbol(keymap, entry->u.keySym);
1580 log_vrb(info->ctx, 5,
1581 XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL,
1582 "Key \"%s\" not found in symbol map; "
1583 "Modifier map entry for %s not updated\n",
1584 KeysymText(info->ctx, entry->u.keySym),
1585 ModIndexText(info->ctx, &info->mods, entry->modifier));
1590 // Handle modMap None
1591 if (entry->modifier != XKB_MOD_NONE) {
1592 // Convert modifier index to modifier mask
1593 key->modmap |= (1u << entry->modifier);
1600 CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
1605 keymap->symbols_section_name = strdup_safe(info->name);
1606 XkbEscapeMapName(keymap->symbols_section_name);
1608 keymap->mods = info->mods;
1610 darray_steal(info->group_names,
1611 &keymap->group_names, &keymap->num_group_names);
1613 darray_foreach(keyi, info->keys)
1614 if (!CopySymbolsDefToKeymap(keymap, info, keyi))
1617 if (xkb_context_get_log_verbosity(keymap->ctx) > 3) {
1618 struct xkb_key *key;
1620 xkb_keys_foreach(key, keymap) {
1621 if (key->name == XKB_ATOM_NONE)
1624 if (key->num_groups < 1)
1625 log_info(info->ctx, XKB_LOG_MESSAGE_NO_ID,
1626 "No symbols defined for %s\n",
1627 KeyNameText(info->ctx, key->name));
1631 darray_foreach(mm, info->modmaps)
1632 if (!CopyModMapDefToKeymap(keymap, info, mm))
1635 /* XXX: If we don't ignore errorCount, things break. */
1640 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
1641 enum merge_mode merge)
1644 ActionsInfo *actions;
1646 actions = NewActionsInfo();
1650 InitSymbolsInfo(&info, keymap, actions, &keymap->mods);
1651 info.default_key.merge = merge;
1653 HandleSymbolsFile(&info, file, merge);
1655 if (info.errorCount != 0)
1658 if (!CopySymbolsToKeymap(keymap, &info))
1661 ClearSymbolsInfo(&info);
1662 FreeActionsInfo(actions);
1666 FreeActionsInfo(actions);
1667 ClearSymbolsInfo(&info);