Commit 7662397fd41a1581f71836e7c7361100d3fb0d56

Ran Benita 2012-07-23T21:18:18

types: fix canonical types copying Without the re-initialization, the copying fails. This wasn't noticed because this code practically never gets executed with ordinary keymaps. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/alloc.c b/src/alloc.c
index c6380fa..cd5bd17 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -41,6 +41,7 @@ XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into)
     free(into->level_names);
 
     *into = *from;
+    darray_init(into->map);
 
     darray_copy(into->map, from->map);
 
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index a3fa0e2..05727f2 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -1055,14 +1055,14 @@ static struct xkb_kt_map_entry mapKeypad[] = {
 };
 
 static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
-    {
+    [XkbOneLevelIndex] = {
         .mods = { .mask = 0, .vmods = 0, .real_mods = 0 },
         .num_levels = 1,
         .preserve = NULL,
         .name = NULL,
         .level_names = NULL
     },
-    {
+    [XkbTwoLevelIndex] = {
         .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
         .num_levels = 2,
         .map = darray_lit(map2Level),
@@ -1070,7 +1070,7 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
         .name = NULL,
         .level_names = NULL
     },
-    {
+    [XkbAlphabeticIndex] = {
         .mods = {
             .mask = ShiftMask | LockMask,
             .vmods = ShiftMask | LockMask,
@@ -1082,7 +1082,7 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
         .name = NULL,
         .level_names = NULL
     },
-    {
+    [XkbKeypadIndex] = {
         .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
         .num_levels = 2,
         .map = darray_lit(mapKeypad),