rules: drop the matcher_err() macro and use scanner_err directly No functional changes, this is what the macro expanded to anyway. Prep work for putting the scanner on the stack and removing it from the matcher struct. 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 125 126 127 128 129 130 131 132 133 134 135
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 47c2ff9..a6abd52 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -324,9 +324,6 @@ matcher_free(struct matcher *m)
free(m);
}
-#define matcher_err(matcher, fmt, ...) \
- scanner_err(&(matcher)->scanner, fmt, ## __VA_ARGS__)
-
static void
matcher_group_start_new(struct matcher *m, struct sval name)
{
@@ -386,14 +383,14 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
/* Not found. */
if (mlvo >= _MLVO_NUM_ENTRIES) {
- matcher_err(m, "invalid mapping: %.*s is not a valid value here; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: %.*s is not a valid value here; ignoring rule set",
ident.len, ident.start);
m->mapping.skip = true;
return;
}
if (m->mapping.defined_mlvo_mask & (1u << mlvo)) {
- matcher_err(m, "invalid mapping: %.*s appears twice on the same line; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: %.*s appears twice on the same line; ignoring rule set",
mlvo_sval.len, mlvo_sval.start);
m->mapping.skip = true;
return;
@@ -405,7 +402,7 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
int consumed = extract_layout_index(ident.start + mlvo_sval.len,
ident.len - mlvo_sval.len, &idx);
if ((int) (ident.len - mlvo_sval.len) != consumed) {
- matcher_err(m, "invalid mapping: \"%.*s\" may only be followed by a valid group index; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: \"%.*s\" may only be followed by a valid group index; ignoring rule set",
mlvo_sval.len, mlvo_sval.start);
m->mapping.skip = true;
return;
@@ -418,7 +415,7 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
m->mapping.variant_idx = idx;
}
else {
- matcher_err(m, "invalid mapping: \"%.*s\" cannot be followed by a group index; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: \"%.*s\" cannot be followed by a group index; ignoring rule set",
mlvo_sval.len, mlvo_sval.start);
m->mapping.skip = true;
return;
@@ -445,14 +442,14 @@ matcher_mapping_set_kccgst(struct matcher *m, struct sval ident)
/* Not found. */
if (kccgst >= _KCCGST_NUM_ENTRIES) {
- matcher_err(m, "invalid mapping: %.*s is not a valid value here; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: %.*s is not a valid value here; ignoring rule set",
ident.len, ident.start);
m->mapping.skip = true;
return;
}
if (m->mapping.defined_kccgst_mask & (1u << kccgst)) {
- matcher_err(m, "invalid mapping: %.*s appears twice on the same line; ignoring rule set",
+ scanner_err(&m->scanner, "invalid mapping: %.*s appears twice on the same line; ignoring rule set",
kccgst_sval.len, kccgst_sval.start);
m->mapping.skip = true;
return;
@@ -467,12 +464,12 @@ static void
matcher_mapping_verify(struct matcher *m)
{
if (m->mapping.num_mlvo == 0) {
- matcher_err(m, "invalid mapping: must have at least one value on the left hand side; ignoring rule set");
+ scanner_err(&m->scanner, "invalid mapping: must have at least one value on the left hand side; ignoring rule set");
goto skip;
}
if (m->mapping.num_kccgst == 0) {
- matcher_err(m, "invalid mapping: must have at least one value on the right hand side; ignoring rule set");
+ scanner_err(&m->scanner, "invalid mapping: must have at least one value on the right hand side; ignoring rule set");
goto skip;
}
@@ -523,7 +520,7 @@ matcher_rule_set_mlvo_common(struct matcher *m, struct sval ident,
enum mlvo_match_type match_type)
{
if (m->rule.num_mlvo_values + 1 > m->mapping.num_mlvo) {
- matcher_err(m, "invalid rule: has more values than the mapping line; ignoring rule");
+ scanner_err(&m->scanner, "invalid rule: has more values than the mapping line; ignoring rule");
m->rule.skip = true;
return;
}
@@ -555,7 +552,7 @@ static void
matcher_rule_set_kccgst(struct matcher *m, struct sval ident)
{
if (m->rule.num_kccgst_values + 1 > m->mapping.num_kccgst) {
- matcher_err(m, "invalid rule: has more values than the mapping line; ignoring rule");
+ scanner_err(&m->scanner, "invalid rule: has more values than the mapping line; ignoring rule");
m->rule.skip = true;
return;
}
@@ -669,7 +666,7 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to,
int consumed;
if (mlv != MLVO_LAYOUT && mlv != MLVO_VARIANT) {
- matcher_err(m, "invalid index in %%-expansion; may only index layout or variant");
+ scanner_err(&m->scanner, "invalid index in %%-expansion; may only index layout or variant");
goto error;
}
@@ -745,7 +742,7 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to,
error:
darray_free(expanded);
- matcher_err(m, "invalid %%-expansion in value; not used");
+ scanner_err(&m->scanner, "invalid %%-expansion in value; not used");
return false;
}
@@ -754,7 +751,7 @@ matcher_rule_verify(struct matcher *m)
{
if (m->rule.num_mlvo_values != m->mapping.num_mlvo ||
m->rule.num_kccgst_values != m->mapping.num_kccgst) {
- matcher_err(m, "invalid rule: must have same number of values as mapping line; ignoring rule");
+ scanner_err(&m->scanner, "invalid rule: must have same number of values as mapping line; ignoring rule");
m->rule.skip = true;
}
}
@@ -994,7 +991,7 @@ finish:
return true;
state_error:
- matcher_err(m, "unexpected token");
+ scanner_err(&m->scanner, "unexpected token");
error:
return false;
}