Ensure we always have a complete keymap Refuse to compile without keycodes + compat + types + symbols. 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 156e223..f73eeff 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -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;
}
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 5630ea5..74aa1fb 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -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;