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>
master
Ran Benita 2012-06-29 16:04:55 +03:00
parent f637d35a86
commit 8f257397af
1 changed files with 12 additions and 17 deletions

View File

@ -35,9 +35,8 @@
struct xkb_keymap * struct xkb_keymap *
CompileKeymap(struct xkb_context *ctx, XkbFile *file) CompileKeymap(struct xkb_context *ctx, XkbFile *file)
{ {
unsigned have; unsigned have = 0;
bool ok; bool ok;
unsigned required, legal;
unsigned mainType; unsigned mainType;
const char *mainName; const char *mainName;
LEDInfo *unbound = NULL, *next; LEDInfo *unbound = NULL, *next;
@ -47,27 +46,23 @@ CompileKeymap(struct xkb_context *ctx, XkbFile *file)
XkbFile *types; XkbFile *types;
XkbFile *compat; XkbFile *compat;
XkbFile *symbols; XkbFile *symbols;
} sections; } sections = { NULL };
if (!keymap) if (!keymap)
return NULL; return NULL;
memset(&sections, 0, sizeof(sections));
mainType = file->type; mainType = file->type;
mainName = file->name ? file->name : "(unnamed)"; mainName = file->name ? file->name : "(unnamed)";
switch (mainType)
{ /*
case XkmKeymapFile: * Other aggregate file types are converted to XkmKeymapFile
required = XkmKeyNamesIndex | XkmTypesIndex | XkmSymbolsIndex | * in the parser.
XkmCompatMapIndex; */
legal = XkmKeymapLegal; if (mainType != XkmKeymapFile) {
break; ERROR("Cannot compile a %s file alone into a keymap\n",
default:
ERROR("Cannot compile %s alone into an XKM file\n",
XkbcConfigText(mainType)); XkbcConfigText(mainType));
return false; return false;
} }
have = 0;
/* Check for duplicate entries in the input file */ /* Check for duplicate entries in the input file */
for (file = (XkbFile *) file->defs; file; file = (XkbFile *) file->common.next) 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"); ACTION("All sections after the first ignored\n");
continue; continue;
} }
else if ((1 << file->type) & (~legal)) else if ((1 << file->type) & (~XkmKeymapLegal))
{ {
ERROR("Cannot define %s in a %s file\n", ERROR("Cannot define %s in a %s file\n",
XkbcConfigText(file->type), XkbcConfigText(mainType)); XkbcConfigText(file->type), XkbcConfigText(mainType));
@ -121,11 +116,11 @@ CompileKeymap(struct xkb_context *ctx, XkbFile *file)
have |= (1 << file->type); have |= (1 << file->type);
} }
if (required & (~have)) if (XkmKeymapRequired & (~have))
{ {
int i, bit; int i, bit;
unsigned missing; unsigned missing;
missing = required & (~have); missing = XkmKeymapRequired & (~have);
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1) for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
{ {
if (missing & bit) if (missing & bit)