Convert CompileKeymap to early-return style 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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index a5beedb..156e223 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -77,83 +77,79 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
}
have = 0;
ok = 1;
- file = (XkbFile *) file->defs;
/* Check for duplicate entries in the input file */
- while ((file) && (ok))
+ for (file = (XkbFile *) file->defs; file; file = (XkbFile *) file->common.next)
{
if (file->topName != mainName) {
free(file->topName);
file->topName = strdup(mainName);
}
+
if ((have & (1 << file->type)) != 0)
{
ERROR("More than one %s section in a %s file\n",
XkbcConfigText(file->type), XkbcConfigText(mainType));
ACTION("All sections after the first ignored\n");
- ok = False;
+ return False;
}
else if ((1 << file->type) & (~legal))
{
ERROR("Cannot define %s in a %s file\n",
XkbcConfigText(file->type), XkbcConfigText(mainType));
- ok = False;
+ return False;
}
- else
+
+ switch (file->type)
{
- switch (file->type)
- {
- case XkmSemanticsFile:
- case XkmLayoutFile:
- case XkmKeymapFile:
- WSGO("Illegal %s configuration in a %s file\n",
- XkbcConfigText(file->type), XkbcConfigText(mainType));
- ACTION("Ignored\n");
- ok = False;
- break;
- case XkmKeyNamesIndex:
- sections.keycodes = file;
- break;
- case XkmTypesIndex:
- sections.types = file;
- break;
- case XkmSymbolsIndex:
- sections.symbols = file;
- break;
- case XkmCompatMapIndex:
- sections.compat = file;
- break;
- case XkmGeometryIndex:
- /* XXX free me! */
- break;
- case XkmVirtualModsIndex:
- case XkmIndicatorsIndex:
- WSGO("Found an isolated %s section\n",
- XkbcConfigText(file->type));
- break;
- default:
- WSGO("Unknown file type %d\n", file->type);
- break;
- }
+ case XkmKeyNamesIndex:
+ sections.keycodes = file;
+ break;
+ case XkmTypesIndex:
+ sections.types = file;
+ break;
+ case XkmSymbolsIndex:
+ sections.symbols = file;
+ break;
+ case XkmCompatMapIndex:
+ sections.compat = file;
+ break;
+ case XkmGeometryIndex:
+ continue;
+ case XkmVirtualModsIndex:
+ case XkmIndicatorsIndex:
+ WSGO("Found an isolated %s section\n", XkbcConfigText(file->type));
+ ACTION("Ignored\n");
+ continue;
+ default:
+ WSGO("Unknown file type %d\n", file->type);
+ ACTION("Ignored\n");
+ continue;
+ case XkmSemanticsFile:
+ case XkmLayoutFile:
+ case XkmKeymapFile:
+ WSGO("Illegal %s configuration in a %s file\n",
+ XkbcConfigText(file->type), XkbcConfigText(mainType));
+ ACTION("Ignored\n");
+ continue;
}
- if (ok)
- have |= (1 << file->type);
- file = (XkbFile *) file->common.next;
+
+ have |= (1 << file->type);
}
+
/* compile the sections we have in the file one-by-one, or fail. */
- if (ok)
- {
- if (ok && (sections.keycodes != NULL))
- ok = CompileKeycodes(sections.keycodes, xkb, MergeOverride);
- if (ok && (sections.types != NULL))
- ok = CompileKeyTypes(sections.types, xkb, MergeOverride);
- if (ok && (sections.compat != NULL))
- ok = CompileCompatMap(sections.compat, xkb, MergeOverride,
- &unbound);
- if (ok && (sections.symbols != NULL))
- ok = CompileSymbols(sections.symbols, xkb, MergeOverride);
- }
- if (!ok)
+ 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))
{
@@ -173,6 +169,7 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
XkbcConfigText(mainType));
return False;
}
+
ok = BindIndicators(xkb, True, unbound, NULL);
return ok;
}