keymap: simplify legal/required logic a bit Now that we've consolidated on the keymap file type, this code only serves to confuse. 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 66 67 68 69 70 71 72 73 74
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index f3bf821..4ce008b 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -35,9 +35,8 @@
struct xkb_keymap *
CompileKeymap(struct xkb_context *ctx, XkbFile *file)
{
- unsigned have;
+ unsigned have = 0;
bool ok;
- unsigned required, legal;
unsigned mainType;
const char *mainName;
LEDInfo *unbound = NULL, *next;
@@ -47,27 +46,23 @@ CompileKeymap(struct xkb_context *ctx, XkbFile *file)
XkbFile *types;
XkbFile *compat;
XkbFile *symbols;
- } sections;
+ } sections = { NULL };
if (!keymap)
return NULL;
- memset(§ions, 0, sizeof(sections));
mainType = file->type;
mainName = file->name ? file->name : "(unnamed)";
- switch (mainType)
- {
- case XkmKeymapFile:
- required = XkmKeyNamesIndex | XkmTypesIndex | XkmSymbolsIndex |
- XkmCompatMapIndex;
- legal = XkmKeymapLegal;
- break;
- default:
- ERROR("Cannot compile %s alone into an XKM file\n",
+
+ /*
+ * Other aggregate file types are converted to XkmKeymapFile
+ * in the parser.
+ */
+ if (mainType != XkmKeymapFile) {
+ ERROR("Cannot compile a %s file alone into a keymap\n",
XkbcConfigText(mainType));
return false;
}
- have = 0;
/* Check for duplicate entries in the input file */
for (file = (XkbFile *) file->defs; file; file = (XkbFile *) file->common.next)
@@ -79,7 +74,7 @@ CompileKeymap(struct xkb_context *ctx, XkbFile *file)
ACTION("All sections after the first ignored\n");
continue;
}
- else if ((1 << file->type) & (~legal))
+ else if ((1 << file->type) & (~XkmKeymapLegal))
{
ERROR("Cannot define %s in a %s file\n",
XkbcConfigText(file->type), XkbcConfigText(mainType));
@@ -121,11 +116,11 @@ CompileKeymap(struct xkb_context *ctx, XkbFile *file)
have |= (1 << file->type);
}
- if (required & (~have))
+ if (XkmKeymapRequired & (~have))
{
int i, bit;
unsigned missing;
- missing = required & (~have);
+ missing = XkmKeymapRequired & (~have);
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
{
if (missing & bit)