Commit 77ab928e92fea6906d1b273ef3b2f2c2b336aff9

Ran Benita 2012-09-12T21:24:28

symbols: remove unneeded recursion form CopySymbolsDef This function does some funky stuff, which, as far as I can tell, was needed to support the functionality of giving different keycodes the same name and thus make them duplicates (MERGE_ALT_FORM). This stuff was removed as useless in 0765064b3, but this leftover wasn't noticed. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 3752c1d..c00f8bf 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -422,11 +422,8 @@ XkbKeyGetKeycode(struct xkb_keymap *keymap, struct xkb_key *key)
     return (xkb_keycode_t)(key - keymap->keys.item);
 }
 
-#define xkb_foreach_key_from(iter, keymap, from) \
-    darray_foreach_from(iter, keymap->keys, from)
-
 #define xkb_foreach_key(iter, keymap) \
-    xkb_foreach_key_from(iter, keymap, keymap->min_key_code)
+    darray_foreach(iter, keymap->keys)
 
 static inline struct xkb_key_type *
 XkbKeyType(struct xkb_keymap *keymap, struct xkb_key *key,
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 454b6f3..274959b 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -754,7 +754,7 @@ ApplyAliases(KeyNamesInfo *info, struct xkb_keymap *keymap)
 
     darray_foreach(alias, info->aliases) {
         /* Check that ->real is a key. */
-        key = FindNamedKey(keymap, alias->real, false, 0);
+        key = FindNamedKey(keymap, alias->real, false);
         if (!key) {
             log_vrb(info->ctx, 5,
                     "Attempt to alias %s to non-existent key %s; Ignored\n",
@@ -764,7 +764,7 @@ ApplyAliases(KeyNamesInfo *info, struct xkb_keymap *keymap)
         }
 
         /* Check that ->alias is not a key. */
-        key = FindNamedKey(keymap, alias->alias, false, 0);
+        key = FindNamedKey(keymap, alias->alias, false);
         if (key) {
             log_vrb(info->ctx, 5,
                     "Attempt to create alias with the name of a real key; "
@@ -859,24 +859,18 @@ err_info:
 }
 
 struct xkb_key *
-FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
-             bool use_aliases, xkb_keycode_t start_from)
+FindNamedKey(struct xkb_keymap *keymap, unsigned long name, bool use_aliases)
 {
     struct xkb_key *key;
 
-    if (start_from < keymap->min_key_code)
-        start_from = keymap->min_key_code;
-    else if (start_from > keymap->max_key_code)
-        return NULL;
-
-    xkb_foreach_key_from(key, keymap, start_from)
+    xkb_foreach_key(key, keymap)
         if (KeyNameToLong(key->name) == name)
             return key;
 
     if (use_aliases) {
         unsigned long new_name;
         if (FindKeyNameForAlias(keymap, name, &new_name))
-            return FindNamedKey(keymap, new_name, false, 0);
+            return FindNamedKey(keymap, new_name, false);
     }
 
     return NULL;
diff --git a/src/xkbcomp/keycodes.h b/src/xkbcomp/keycodes.h
index d95e16a..41bd18c 100644
--- a/src/xkbcomp/keycodes.h
+++ b/src/xkbcomp/keycodes.h
@@ -56,7 +56,7 @@ LongKeyNameText(unsigned long val)
 
 struct xkb_key *
 FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
-             bool use_aliases, xkb_keycode_t start_from);
+             bool use_aliases);
 
 bool
 FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index fe6511d..a9879ec 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1490,14 +1490,8 @@ PrepareKeyDef(KeyInfo *keyi)
             ClearGroupInfo(&keyi->groups[i]);
 }
 
-/**
- * Copy the KeyInfo into the keyboard description.
- *
- * This function recurses.
- */
 static bool
-CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
-               xkb_keycode_t start_from)
+CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
 {
     struct xkb_keymap *keymap = info->keymap;
     xkb_keycode_t kc;
@@ -1506,18 +1500,15 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
     xkb_group_index_t i, nGroups;
     xkb_level_index_t width, tmp;
     struct xkb_key_type * type;
-    bool haveActions, autoType, useAlias;
+    bool haveActions, autoType;
     unsigned types[XKB_NUM_GROUPS];
     unsigned int symIndex = 0;
 
-    useAlias = (start_from == 0);
-
-    key = FindNamedKey(keymap, keyi->name, useAlias, start_from);
+    key = FindNamedKey(keymap, keyi->name, true);
     if (!key) {
-        if (start_from == 0)
-            log_vrb(info->keymap->ctx, 5,
-                    "Key %s not found in keycodes; Symbols ignored\n",
-                    LongKeyNameText(keyi->name));
+        log_vrb(info->keymap->ctx, 5,
+                "Key %s not found in keycodes; Symbols ignored\n",
+                LongKeyNameText(keyi->name));
         return false;
     }
     kc = XkbKeyGetKeycode(keymap, key);
@@ -1657,8 +1648,6 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
         key->explicit |= EXPLICIT_REPEAT;
     }
 
-    /* do the same thing for the next key */
-    CopySymbolsDef(info, keyi, kc + 1);
     return true;
 }
 
@@ -1669,7 +1658,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
     struct xkb_keymap *keymap = info->keymap;
 
     if (!entry->haveSymbol) {
-        key = FindNamedKey(keymap, entry->u.keyName, true, 0);
+        key = FindNamedKey(keymap, entry->u.keyName, true);
         if (!key) {
             log_vrb(info->keymap->ctx, 5,
                     "Key %s not found in keycodes; "
@@ -1741,7 +1730,7 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
 
     /* copy! */
     darray_foreach(keyi, info.keys)
-        if (!CopySymbolsDef(&info, keyi, 0))
+        if (!CopySymbolsDef(&info, keyi))
             info.errorCount++;
 
     if (xkb_get_log_verbosity(keymap->ctx) > 3) {