Fix multiple errors when merging symbol definitions We were getting the size calculation wrong, as well as inconsistently picking a merge strategy. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
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
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index aba73f3..6e7ef40 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -475,14 +475,18 @@ MergeKeyGroups(SymbolsInfo * info,
if (into->symsMapNumEntries[group] && (i < into->numLevels[group]))
toSize = into->symsMapNumEntries[group][i];
- if (fromSize == 0 || fromSize == toSize || clobber)
+ if (fromSize == 0)
{
- fromSize += toSize;
+ resultSize += toSize;
}
- else if (toSize == 0)
+ else if (toSize == 0 || clobber)
{
resultSize += fromSize;
}
+ else
+ {
+ resultSize += toSize;
+ }
}
if (resultSize == 0)
@@ -502,19 +506,21 @@ MergeKeyGroups(SymbolsInfo * info,
unsigned int fromSize = 0;
unsigned int toSize = 0;
- if (from->symsMapNumEntries[group] && (i < from->numLevels[group]))
+ if (i < from->numLevels[group])
fromSize = from->symsMapNumEntries[group][i];
- if (into->symsMapNumEntries[group] && (i < into->numLevels[group]))
+ if (i < into->numLevels[group])
toSize = into->symsMapNumEntries[group][i];
- if (!fromSize && !toSize)
+ if (fromSize == 0 && toSize == 0)
{
into->symsMapIndex[group][i] = -1;
into->symsMapNumEntries[group][i] = 0;
continue;
}
- if ((fromSize && !toSize) || clobber)
+ if (fromSize == 0)
+ use = TO;
+ else if (toSize == 0 || clobber)
use = FROM;
else
use = TO;
@@ -540,7 +546,7 @@ MergeKeyGroups(SymbolsInfo * info,
else
{
memcpy(&resultSyms[cur_idx],
- &into->syms[group][from->symsMapIndex[group][i]],
+ &into->syms[group][into->symsMapIndex[group][i]],
into->symsMapNumEntries[group][i] * sizeof(xkb_keysym_t));
into->symsMapIndex[group][i] = cur_idx;
}
@@ -1864,7 +1870,7 @@ PrepareKeyDef(KeyInfo * key)
identical = false;
break;
}
- if ((key->symsMapIndex[i] != key->symsMapIndex[i]) &&
+ if ((key->symsMapIndex[i] != key->symsMapIndex[0]) &&
(key->symsMapIndex[i] == NULL || key->symsMapIndex[0] == NULL ||
memcmp(key->symsMapIndex[i], key->symsMapIndex[0],
key->numLevels[0] * sizeof(int))))
@@ -1872,7 +1878,7 @@ PrepareKeyDef(KeyInfo * key)
identical = false;
continue;
}
- if ((key->symsMapNumEntries[i] != key->symsMapNumEntries[i]) &&
+ if ((key->symsMapNumEntries[i] != key->symsMapNumEntries[0]) &&
(key->symsMapNumEntries[i] == NULL ||
key->symsMapNumEntries[0] == NULL ||
memcmp(key->symsMapNumEntries[i], key->symsMapNumEntries[0],