symbols: add CopySymbolsToKeymap Like in the other sections. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index ff089e7..9cdd911 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1682,23 +1682,52 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
return true;
}
-/**
- * Handle the xkb_symbols section of an xkb file.
- *
- * @param file The parsed xkb_symbols section of the xkb file.
- * @param keymap Handle to the keyboard description to store the symbols in.
- * @param merge Merge strategy (e.g. MERGE_OVERRIDE).
- */
+static bool
+CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
+{
+ KeyInfo *keyi;
+ ModMapEntry *mm;
+ xkb_group_index_t i;
+ struct xkb_key *key;
+
+ keymap->symbols_section_name = strdup_safe(info->name);
+
+ for (i = 0; i < XKB_NUM_GROUPS; i++)
+ if (info->groupNames[i] != XKB_ATOM_NONE)
+ keymap->group_names[i] = info->groupNames[i];
+
+ darray_foreach(keyi, info->keys) {
+ PrepareKeyDef(keyi);
+ if (!CopySymbolsDef(info, keyi))
+ info->errorCount++;
+ }
+
+ if (xkb_get_log_verbosity(keymap->ctx) > 3) {
+ xkb_foreach_key(key, keymap) {
+ if (key->name[0] == '\0')
+ continue;
+
+ if (key->num_groups < 1)
+ log_info(keymap->ctx,
+ "No symbols defined for %s\n",
+ KeyNameText(key->name));
+ }
+ }
+
+ darray_foreach(mm, info->modMaps)
+ if (!CopyModMapDef(info, mm))
+ info->errorCount++;
+
+ /* XXX: If we don't ignore errorCount, things break. */
+ return true;
+}
+
bool
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{
- xkb_group_index_t i;
- struct xkb_key *key;
SymbolsInfo info;
ActionsInfo *actions;
- KeyInfo *keyi;
- ModMapEntry *mm;
actions = NewActionsInfo();
if (!actions)
@@ -1715,37 +1744,8 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
if (info.errorCount != 0)
goto err_info;
- if (info.name)
- keymap->symbols_section_name = strdup(info.name);
-
- for (i = 0; i < XKB_NUM_GROUPS; i++)
- if (info.groupNames[i] != XKB_ATOM_NONE)
- keymap->group_names[i] = info.groupNames[i];
-
- /* sanitize keys */
- darray_foreach(keyi, info.keys)
- PrepareKeyDef(keyi);
-
- /* copy! */
- darray_foreach(keyi, info.keys)
- if (!CopySymbolsDef(&info, keyi))
- info.errorCount++;
-
- if (xkb_get_log_verbosity(keymap->ctx) > 3) {
- xkb_foreach_key(key, keymap) {
- if (key->name[0] == '\0')
- continue;
-
- if (key->num_groups < 1)
- log_info(info.keymap->ctx,
- "No symbols defined for %s\n",
- KeyNameText(key->name));
- }
- }
-
- darray_foreach(mm, info.modMaps)
- if (!CopyModMapDef(&info, mm))
- info.errorCount++;
+ if (!CopySymbolsToKeymap(keymap, &info))
+ goto err_info;
ClearSymbolsInfo(&info);
FreeActionsInfo(actions);