xkbcomp: Turn an array into an anonymous struct 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
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index b2dde0b..6c236a6 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -32,12 +32,6 @@
#include "misc.h"
#include "indicators.h"
-#define KEYCODES 0
-#define TYPES 1
-#define COMPAT 2
-#define SYMBOLS 3
-#define MAX_SECTIONS (SYMBOLS + 1)
-
/**
* Compile the given file and store the output in xkb.
* @param file A list of XkbFiles, each denoting one type (e.g.
@@ -52,9 +46,14 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
unsigned mainType;
char *mainName;
LEDInfo *unbound = NULL;
- XkbFile *sections[MAX_SECTIONS];
+ struct {
+ XkbFile *keycodes;
+ XkbFile *types;
+ XkbFile *compat;
+ XkbFile *symbols;
+ } sections;
- memset(sections, 0, sizeof(sections));
+ memset(§ions, 0, sizeof(sections));
mainType = file->type;
mainName = file->name;
switch (mainType)
@@ -111,16 +110,16 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
ok = False;
break;
case XkmKeyNamesIndex:
- sections[KEYCODES] = file;
+ sections.keycodes = file;
break;
case XkmTypesIndex:
- sections[TYPES] = file;
+ sections.types = file;
break;
case XkmSymbolsIndex:
- sections[SYMBOLS] = file;
+ sections.symbols = file;
break;
case XkmCompatMapIndex:
- sections[COMPAT] = file;
+ sections.compat = file;
break;
case XkmGeometryIndex:
/* XXX free me! */
@@ -141,15 +140,15 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
/* 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,
+ 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 && (sections.symbols != NULL))
+ ok = CompileSymbols(sections.symbols, xkb, MergeOverride);
}
if (!ok)
return False;