keymap: share LevelsSameSyms() The function is generic enough. 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
diff --git a/src/keymap-priv.c b/src/keymap-priv.c
index d21dda7..08945ca 100644
--- a/src/keymap-priv.c
+++ b/src/keymap-priv.c
@@ -137,3 +137,13 @@ XkbModNameToIndex(const struct xkb_mod_set *mods, xkb_atom_t name,
return XKB_MOD_INVALID;
}
+
+bool
+XkbLevelsSameSyms(const struct xkb_level *a, const struct xkb_level *b)
+{
+ if (a->num_syms != b->num_syms)
+ return false;
+ if (a->num_syms <= 1)
+ return a->u.sym == b->u.sym;
+ return memcmp(a->u.syms, b->u.syms, sizeof(*a->u.syms) * a->num_syms) == 0;
+}
diff --git a/src/keymap.h b/src/keymap.h
index d20442f..1093e47 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -455,6 +455,9 @@ xkb_mod_index_t
XkbModNameToIndex(const struct xkb_mod_set *mods, xkb_atom_t name,
enum mod_type type);
+bool
+XkbLevelsSameSyms(const struct xkb_level *a, const struct xkb_level *b);
+
xkb_layout_index_t
XkbWrapGroupIntoRange(int32_t group,
xkb_layout_index_t num_groups,
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index cda93b0..9b05ec9 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -218,19 +218,6 @@ KeyInfoText(SymbolsInfo *info, KeyInfo *keyi)
}
static bool
-LevelsSameSyms(const struct xkb_level *a, const struct xkb_level *b)
-{
- if (a->num_syms != b->num_syms)
- return false;
- if (a->num_syms <= 1)
- return a->u.sym == b->u.sym;
- else
- return memcmp(a->u.syms, b->u.syms,
- sizeof(*a->u.syms) * a->num_syms) == 0;
-
-}
-
-static bool
MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
bool report, xkb_layout_index_t group, xkb_atom_t key_name)
{
@@ -312,7 +299,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
intoLevel->u.sym = fromLevel->u.sym;
fromLevel->num_syms = 0;
}
- else if (!LevelsSameSyms(fromLevel, intoLevel)) {
+ else if (!XkbLevelsSameSyms(fromLevel, intoLevel)) {
if (report)
log_warn(info->ctx,
"Multiple symbols for level %d/group %u on key %s; "