Ensure we always have a complete keymap
authorDaniel Stone <daniel@fooishbar.org>
Fri, 9 Mar 2012 18:46:46 +0000 (18:46 +0000)
committerDaniel Stone <daniel@fooishbar.org>
Fri, 9 Mar 2012 19:30:31 +0000 (19:30 +0000)
Refuse to compile without keycodes + compat + types + symbols.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
src/xkbcomp/keymap.c
src/xkbcomp/xkbcomp.c

index 156e223..f73eeff 100644 (file)
@@ -67,7 +67,8 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
         legal = XkmKeymapLegal;
         break;
     case XkmKeymapFile:
-        required = XkmKeymapRequired;
+        required = XkmKeyNamesIndex | XkmTypesIndex | XkmSymbolsIndex | \
+                   XkmCompatMapIndex | XkmVirtualModsIndex;
         legal = XkmKeymapLegal;
         break;
     default:
@@ -136,21 +137,6 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
         have |= (1 << file->type);
     }
 
-    /* compile the sections we have in the file one-by-one, or fail. */
-    if (sections.keycodes != NULL &&
-        !CompileKeycodes(sections.keycodes, xkb, MergeOverride))
-        return False;
-    if (sections.types != NULL &&
-        !CompileKeyTypes(sections.types, xkb, MergeOverride))
-        return False;
-    if (sections.compat != NULL &&
-        !CompileCompatMap(sections.compat, xkb, MergeOverride, &unbound))
-        return False;
-    if (sections.symbols != NULL &&
-        !CompileSymbols(sections.symbols, xkb, MergeOverride))
-        return False;
-
-    xkb->defined = have;
     if (required & (~have))
     {
         int i, bit;
@@ -170,6 +156,22 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
         return False;
     }
 
+    /* compile the sections we have in the file one-by-one, or fail. */
+    if (sections.keycodes != NULL &&
+        !CompileKeycodes(sections.keycodes, xkb, MergeOverride))
+        return False;
+    if (sections.types != NULL &&
+        !CompileKeyTypes(sections.types, xkb, MergeOverride))
+        return False;
+    if (sections.compat != NULL &&
+        !CompileCompatMap(sections.compat, xkb, MergeOverride, &unbound))
+        return False;
+    if (sections.symbols != NULL &&
+        !CompileSymbols(sections.symbols, xkb, MergeOverride))
+        return False;
+
+    xkb->defined = have;
+
     ok = BindIndicators(xkb, True, unbound, NULL);
     return ok;
 }
index 5630ea5..74aa1fb 100644 (file)
@@ -45,11 +45,6 @@ XkbKeymapFileFromComponents(const struct xkb_component_names * ktcsg)
     XkbFile *keycodes, *types, *compat, *symbols;
     IncludeStmt *inc;
 
-    if (!ktcsg) {
-        ERROR("no components to generate keymap file from\n");
-        return NULL;
-    }
-
     inc = IncludeCreate(ktcsg->keycodes, MergeDefault);
     keycodes = CreateXKBFile(XkmKeyNamesIndex, NULL, (ParseCommon *)inc, 0);
 
@@ -231,11 +226,31 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
 {
     XkbFile *file;
 
-    if (!ktcsg || ISEMPTY(ktcsg->keycodes)) {
+    if (!ktcsg) {
+        ERROR("no components specified\n");
+        return NULL;
+    }
+
+    if (ISEMPTY(ktcsg->keycodes)) {
         ERROR("keycodes required to generate XKB keymap\n");
         return NULL;
     }
 
+    if (ISEMPTY(ktcsg->compat)) {
+        ERROR("compat map required to generate XKB keymap\n");
+        return NULL;
+    }
+
+    if (ISEMPTY(ktcsg->types)) {
+        ERROR("types required to generate XKB keymap\n");
+        return NULL;
+    }
+
+    if (ISEMPTY(ktcsg->symbols)) {
+        ERROR("symbols required to generate XKB keymap\n");
+        return NULL;
+    }
+
     if (!(file = XkbKeymapFileFromComponents(ktcsg))) {
         ERROR("failed to generate parsed XKB file from components\n");
         return NULL;