rules: move the matcher result handling to the caller This shouldn't be processed in the matcher itself, especially in the glorious future when we can have nested matchers. Only handle this once in the caller to the original parsed file. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 1d021fa..15b6012 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -823,10 +823,9 @@ gettok(struct matcher *m, struct scanner *s)
static bool
matcher_match(struct matcher *m, struct scanner *s,
const char *string, size_t len,
- const char *file_name, struct xkb_component_names *out)
+ const char *file_name)
{
enum rules_token tok;
- struct matched_sval *mval;
if (!m)
return false;
@@ -961,37 +960,6 @@ unexpected:
}
finish:
- if (darray_empty(m->kccgst[KCCGST_KEYCODES]) ||
- darray_empty(m->kccgst[KCCGST_TYPES]) ||
- darray_empty(m->kccgst[KCCGST_COMPAT]) ||
- /* darray_empty(m->kccgst[KCCGST_GEOMETRY]) || */
- darray_empty(m->kccgst[KCCGST_SYMBOLS]))
- goto error;
-
- darray_steal(m->kccgst[KCCGST_KEYCODES], &out->keycodes, NULL);
- darray_steal(m->kccgst[KCCGST_TYPES], &out->types, NULL);
- darray_steal(m->kccgst[KCCGST_COMPAT], &out->compat, NULL);
- darray_steal(m->kccgst[KCCGST_SYMBOLS], &out->symbols, NULL);
- darray_free(m->kccgst[KCCGST_GEOMETRY]);
-
-
- mval = &m->rmlvo.model;
- if (!mval->matched && mval->sval.len > 0)
- log_err(m->ctx, "Unrecognized RMLVO model \"%.*s\" was ignored\n",
- mval->sval.len, mval->sval.start);
- darray_foreach(mval, m->rmlvo.layouts)
- if (!mval->matched && mval->sval.len > 0)
- log_err(m->ctx, "Unrecognized RMLVO layout \"%.*s\" was ignored\n",
- mval->sval.len, mval->sval.start);
- darray_foreach(mval, m->rmlvo.variants)
- if (!mval->matched && mval->sval.len > 0)
- log_err(m->ctx, "Unrecognized RMLVO variant \"%.*s\" was ignored\n",
- mval->sval.len, mval->sval.start);
- darray_foreach(mval, m->rmlvo.options)
- if (!mval->matched && mval->sval.len > 0)
- log_err(m->ctx, "Unrecognized RMLVO option \"%.*s\" was ignored\n",
- mval->sval.len, mval->sval.start);
-
return true;
state_error:
@@ -1003,8 +971,7 @@ error:
static bool
read_rules_file(struct xkb_context *ctx,
struct matcher *matcher,
- const char *path,
- struct xkb_component_names *out)
+ const char *path)
{
bool ret = false;
FILE *file;
@@ -1025,7 +992,7 @@ read_rules_file(struct xkb_context *ctx,
scanner_init(&scanner, matcher->ctx, string, size, path, NULL);
- ret = matcher_match(matcher, &scanner, string, size, path, out);
+ ret = matcher_match(matcher, &scanner, string, size, path);
unmap_file(string, size);
out:
@@ -1043,6 +1010,7 @@ xkb_components_from_rules(struct xkb_context *ctx,
FILE *file;
char *path = NULL;
struct matcher *matcher = NULL;
+ struct matched_sval *mval;
file = FindFileInXkbPath(ctx, rmlvo->rules, FILE_TYPE_RULES, &path);
if (!file)
@@ -1053,9 +1021,40 @@ xkb_components_from_rules(struct xkb_context *ctx,
matcher = matcher_new(ctx, rmlvo);
- ret = read_rules_file(ctx, matcher, path, out);
- if (!ret)
+ ret = read_rules_file(ctx, matcher, path);
+ if (!ret ||
+ darray_empty(matcher->kccgst[KCCGST_KEYCODES]) ||
+ darray_empty(matcher->kccgst[KCCGST_TYPES]) ||
+ darray_empty(matcher->kccgst[KCCGST_COMPAT]) ||
+ /* darray_empty(matcher->kccgst[KCCGST_GEOMETRY]) || */
+ darray_empty(matcher->kccgst[KCCGST_SYMBOLS])) {
log_err(ctx, "No components returned from XKB rules \"%s\"\n", path);
+ ret = false;
+ goto err_out;
+ }
+
+ darray_steal(matcher->kccgst[KCCGST_KEYCODES], &out->keycodes, NULL);
+ darray_steal(matcher->kccgst[KCCGST_TYPES], &out->types, NULL);
+ darray_steal(matcher->kccgst[KCCGST_COMPAT], &out->compat, NULL);
+ darray_steal(matcher->kccgst[KCCGST_SYMBOLS], &out->symbols, NULL);
+ darray_free(matcher->kccgst[KCCGST_GEOMETRY]);
+
+ mval = &matcher->rmlvo.model;
+ if (!mval->matched && mval->sval.len > 0)
+ log_err(matcher->ctx, "Unrecognized RMLVO model \"%.*s\" was ignored\n",
+ mval->sval.len, mval->sval.start);
+ darray_foreach(mval, matcher->rmlvo.layouts)
+ if (!mval->matched && mval->sval.len > 0)
+ log_err(matcher->ctx, "Unrecognized RMLVO layout \"%.*s\" was ignored\n",
+ mval->sval.len, mval->sval.start);
+ darray_foreach(mval, matcher->rmlvo.variants)
+ if (!mval->matched && mval->sval.len > 0)
+ log_err(matcher->ctx, "Unrecognized RMLVO variant \"%.*s\" was ignored\n",
+ mval->sval.len, mval->sval.start);
+ darray_foreach(mval, matcher->rmlvo.options)
+ if (!mval->matched && mval->sval.len > 0)
+ log_err(matcher->ctx, "Unrecognized RMLVO option \"%.*s\" was ignored\n",
+ mval->sval.len, mval->sval.start);
err_out:
matcher_free(matcher);