Commit dd85790c73064715436b96fec5af7704e229a3d9

Ran Benita 2012-07-13T17:51:26

Move InitCanonicalKeyTypes to keytypes.c It's only got one call site and it's in keytypes.c, so move it there and make it static. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/misc.c b/src/misc.c
index 1cb9baf..7a7ed7f 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -27,138 +27,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "xkb-priv.h"
 #include "alloc.h"
 
-static struct xkb_kt_map_entry map2Level[]= {
-    {
-        .level = ShiftMask,
-        .mods = {.mask = 1, .vmods = ShiftMask, .real_mods = 0 }
-    }
-};
-
-static struct xkb_kt_map_entry mapAlpha[]= {
-    {
-        .level = ShiftMask,
-        .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
-    },
-    {
-        .level = LockMask,
-        .mods = { .mask = 0, .vmods = LockMask,  .real_mods = 0 }
-    }
-};
-
-static struct xkb_mods preAlpha[]= {
-    { .mask = 0,        .vmods = 0,        .real_mods = 0 },
-    { .mask = LockMask, .vmods = LockMask, .real_mods = 0 }
-};
-
-#define NL_VMOD_MASK 0
-static struct xkb_kt_map_entry mapKeypad[]= {
-    {
-        .level = ShiftMask,
-        .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
-    },
-    {
-        .level = 0,
-        .mods = { .mask = 1, .vmods = 0, .real_mods = NL_VMOD_MASK }
-    }
-};
-
-static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
-    {
-        .mods = { .mask = 0, .vmods = 0, .real_mods = 0 },
-        .num_levels = 1,
-        .preserve = NULL,
-        .name = NULL,
-        .level_names = NULL
-    },
-    {
-        .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
-        .num_levels = 2,
-        .map = darray_lit(map2Level),
-        .preserve = NULL,
-        .name = NULL,
-        .level_names = NULL
-    },
-    {
-        .mods = { .mask = ShiftMask|LockMask, .vmods = ShiftMask|LockMask, .real_mods = 0 },
-        .num_levels = 2,
-        .map = darray_lit(mapAlpha),
-        .preserve = preAlpha,
-        .name = NULL,
-        .level_names = NULL
-    },
-    {
-        .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = NL_VMOD_MASK },
-        .num_levels = 2,
-        .map = darray_lit(mapKeypad),
-        .preserve = NULL,
-        .name = NULL,
-        .level_names = NULL
-    }
-};
-
-int
-XkbcInitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
-                          int keypadVMod)
-{
-    struct xkb_client_map * map;
-    const struct xkb_key_type *from;
-    int rtrn;
-
-    if (!keymap)
-        return BadMatch;
-
-    rtrn = XkbcAllocClientMap(keymap, XkbKeyTypesMask, XkbNumRequiredTypes);
-    if (rtrn != Success)
-        return rtrn;
-
-    map = keymap->map;
-    if ((which & XkbAllRequiredTypes) == 0)
-        return Success;
-
-    rtrn = Success;
-    from = canonicalTypes;
-
-    if (which & XkbOneLevelMask)
-        rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex],
-                               &darray_item(map->types, XkbOneLevelIndex));
-
-    if ((which & XkbTwoLevelMask) && (rtrn == Success))
-        rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex],
-                               &darray_item(map->types, XkbTwoLevelIndex));
-
-    if ((which & XkbAlphabeticMask) && (rtrn == Success))
-        rtrn = XkbcCopyKeyType(&from[XkbAlphabeticIndex],
-                               &darray_item(map->types, XkbAlphabeticIndex));
-
-    if ((which & XkbKeypadMask) && (rtrn == Success)) {
-        struct xkb_key_type * type;
-
-        rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex],
-                               &darray_item(map->types, XkbKeypadIndex));
-        type = &darray_item(map->types, XkbKeypadIndex);
-
-        if ((keypadVMod >= 0) && (keypadVMod < XkbNumVirtualMods) &&
-            (rtrn == Success)) {
-            struct xkb_kt_map_entry *entry;
-            type->mods.vmods = (1 << keypadVMod);
-
-            entry = &darray_item(type->map, 0);
-            entry->mods.mask = ShiftMask;
-            entry->mods.real_mods = ShiftMask;
-            entry->mods.vmods = 0;
-            entry->level = 1;
-
-            entry = &darray_item(type->map, 1);
-            entry->mods.mask = 0;
-            entry->mods.real_mods = 0;
-            entry->mods.vmods = (1 << keypadVMod);
-            entry->level = 1;
-        }
-    }
-
-    return Success;
-}
-
 unsigned
 _XkbcKSCheckCase(xkb_keysym_t ks)
 {
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 02b847c..59d2821 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -456,10 +456,6 @@ xkb_map_new_from_kccgst(struct xkb_context *ctx,
 extern int
 xkb_context_take_file_id(struct xkb_context *ctx);
 
-extern int
-XkbcInitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
-                          int keypadVMod);
-
 extern unsigned
 _XkbcKSCheckCase(xkb_keysym_t sym);
 
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 900c345..c38ac4f 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -1079,6 +1079,137 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
     return ComputeEffectiveMap(keymap, type);
 }
 
+static struct xkb_kt_map_entry map2Level[]= {
+    {
+        .level = ShiftMask,
+        .mods = {.mask = 1, .vmods = ShiftMask, .real_mods = 0 }
+    }
+};
+
+static struct xkb_kt_map_entry mapAlpha[]= {
+    {
+        .level = ShiftMask,
+        .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
+    },
+    {
+        .level = LockMask,
+        .mods = { .mask = 0, .vmods = LockMask,  .real_mods = 0 }
+    }
+};
+
+static struct xkb_mods preAlpha[]= {
+    { .mask = 0,        .vmods = 0,        .real_mods = 0 },
+    { .mask = LockMask, .vmods = LockMask, .real_mods = 0 }
+};
+
+static struct xkb_kt_map_entry mapKeypad[]= {
+    {
+        .level = ShiftMask,
+        .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
+    },
+    {
+        .level = 0,
+        .mods = { .mask = 1, .vmods = 0, .real_mods = 0 }
+    }
+};
+
+static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
+    {
+        .mods = { .mask = 0, .vmods = 0, .real_mods = 0 },
+        .num_levels = 1,
+        .preserve = NULL,
+        .name = NULL,
+        .level_names = NULL
+    },
+    {
+        .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
+        .num_levels = 2,
+        .map = darray_lit(map2Level),
+        .preserve = NULL,
+        .name = NULL,
+        .level_names = NULL
+    },
+    {
+        .mods = {
+            .mask = ShiftMask|LockMask,
+            .vmods = ShiftMask|LockMask,
+            .real_mods = 0
+        },
+        .num_levels = 2,
+        .map = darray_lit(mapAlpha),
+        .preserve = preAlpha,
+        .name = NULL,
+        .level_names = NULL
+    },
+    {
+        .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
+        .num_levels = 2,
+        .map = darray_lit(mapKeypad),
+        .preserve = NULL,
+        .name = NULL,
+        .level_names = NULL
+    }
+};
+
+static int
+InitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which, int keypadVMod)
+{
+    struct xkb_client_map *map;
+    const struct xkb_key_type *from;
+    int rtrn;
+
+    rtrn = XkbcAllocClientMap(keymap, XkbKeyTypesMask, XkbNumRequiredTypes);
+    if (rtrn != Success)
+        return rtrn;
+
+    map = keymap->map;
+    if ((which & XkbAllRequiredTypes) == 0)
+        return Success;
+
+    rtrn = Success;
+    from = canonicalTypes;
+
+    if (which & XkbOneLevelMask)
+        rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex],
+                               &darray_item(map->types, XkbOneLevelIndex));
+
+    if ((which & XkbTwoLevelMask) && rtrn == Success)
+        rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex],
+                               &darray_item(map->types, XkbTwoLevelIndex));
+
+    if ((which & XkbAlphabeticMask) && rtrn == Success)
+        rtrn = XkbcCopyKeyType(&from[XkbAlphabeticIndex],
+                               &darray_item(map->types, XkbAlphabeticIndex));
+
+    if ((which & XkbKeypadMask) && rtrn == Success) {
+        struct xkb_key_type *type;
+
+        rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex],
+                               &darray_item(map->types, XkbKeypadIndex));
+        type = &darray_item(map->types, XkbKeypadIndex);
+
+        if (keypadVMod >= 0 && keypadVMod < XkbNumVirtualMods &&
+            rtrn == Success) {
+            struct xkb_kt_map_entry *entry;
+            type->mods.vmods = (1 << keypadVMod);
+
+            entry = &darray_item(type->map, 0);
+            entry->mods.mask = ShiftMask;
+            entry->mods.real_mods = ShiftMask;
+            entry->mods.vmods = 0;
+            entry->level = 1;
+
+            entry = &darray_item(type->map, 1);
+            entry->mods.mask = 0;
+            entry->mods.real_mods = 0;
+            entry->mods.vmods = (1 << keypadVMod);
+            entry->level = 1;
+        }
+    }
+
+    return Success;
+}
+
 bool
 CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
 {
@@ -1124,7 +1255,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
         missing = XkbAllRequiredTypes & (~info.stdPresent);
         keypadVMod = FindKeypadVMod(keymap);
 
-        if (XkbcInitCanonicalKeyTypes(keymap, missing, keypadVMod) != Success) {
+        if (InitCanonicalKeyTypes(keymap, missing, keypadVMod) != Success) {
             WSGO("Couldn't initialize canonical key types\n");
             goto err_info;
         }