rules: reformat components_from_rules Signed-off-by: Ran Benita <ran234@gmail.com>
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
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index da36e68..f663181 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -1168,20 +1168,19 @@ xkb_components_from_rules(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo)
{
int i;
- FILE *rulesFile;
- char *rulesPath;
- struct rules *loaded;
- struct xkb_component_names *names = NULL;
+ FILE *file;
+ char *path;
+ struct rules *rules;
struct var_defs defs = {
.model = rmlvo->model,
.layout = rmlvo->layout,
.variant = rmlvo->variant,
.options = rmlvo->options,
};
+ struct xkb_component_names *kccgst = NULL;
- rulesFile = XkbFindFileInPath(ctx, rmlvo->rules, XkmRulesFile,
- &rulesPath);
- if (!rulesFile) {
+ file = XkbFindFileInPath(ctx, rmlvo->rules, XkmRulesFile, &path);
+ if (!file) {
ERROR("could not find \"%s\" rules in XKB path\n", rmlvo->rules);
ERROR("%d include paths searched:\n",
xkb_context_num_include_paths(ctx));
@@ -1190,33 +1189,34 @@ xkb_components_from_rules(struct xkb_context *ctx,
return NULL;
}
- loaded = load_rules(rulesFile);
- if (!loaded) {
- ERROR("failed to load XKB rules \"%s\"\n", rulesPath);
- goto unwind_file;
+ rules = load_rules(file);
+ if (!rules) {
+ ERROR("failed to load XKB rules \"%s\"\n", path);
+ goto err;
}
- names = calloc(1, sizeof(*names));
- if (!names) {
+ kccgst = calloc(1, sizeof(*kccgst));
+ if (!kccgst) {
ERROR("failed to allocate XKB components\n");
- goto unwind_file;
+ goto err;
}
- if (!get_components(loaded, &defs, names)) {
- free(names->keymap);
- free(names->keycodes);
- free(names->types);
- free(names->compat);
- free(names->symbols);
- free(names);
- names = NULL;
- ERROR("no components returned from XKB rules \"%s\"\n", rulesPath);
+ if (!get_components(rules, &defs, kccgst)) {
+ free(kccgst->keymap);
+ free(kccgst->keycodes);
+ free(kccgst->types);
+ free(kccgst->compat);
+ free(kccgst->symbols);
+ free(kccgst);
+ kccgst = NULL;
+ ERROR("no components returned from XKB rules \"%s\"\n", path);
+ goto err;
}
-unwind_file:
- free_rules(loaded);
- if (rulesFile)
- fclose(rulesFile);
- free(rulesPath);
- return names;
+err:
+ free_rules(rules);
+ if (file)
+ fclose(file);
+ free(path);
+ return kccgst;
}