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>master
parent
f57c13ea4f
commit
2a578a60b3
|
@ -324,9 +324,6 @@ matcher_free(struct matcher *m)
|
||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define matcher_err(matcher, fmt, ...) \
|
|
||||||
scanner_err(&(matcher)->scanner, fmt, ## __VA_ARGS__)
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
matcher_group_start_new(struct matcher *m, struct sval name)
|
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. */
|
/* Not found. */
|
||||||
if (mlvo >= _MLVO_NUM_ENTRIES) {
|
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);
|
ident.len, ident.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->mapping.defined_mlvo_mask & (1u << mlvo)) {
|
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);
|
mlvo_sval.len, mlvo_sval.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
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,
|
int consumed = extract_layout_index(ident.start + mlvo_sval.len,
|
||||||
ident.len - mlvo_sval.len, &idx);
|
ident.len - mlvo_sval.len, &idx);
|
||||||
if ((int) (ident.len - mlvo_sval.len) != consumed) {
|
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);
|
mlvo_sval.len, mlvo_sval.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
return;
|
||||||
|
@ -418,7 +415,7 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident)
|
||||||
m->mapping.variant_idx = idx;
|
m->mapping.variant_idx = idx;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
mlvo_sval.len, mlvo_sval.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
return;
|
||||||
|
@ -445,14 +442,14 @@ matcher_mapping_set_kccgst(struct matcher *m, struct sval ident)
|
||||||
|
|
||||||
/* Not found. */
|
/* Not found. */
|
||||||
if (kccgst >= _KCCGST_NUM_ENTRIES) {
|
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);
|
ident.len, ident.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->mapping.defined_kccgst_mask & (1u << kccgst)) {
|
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);
|
kccgst_sval.len, kccgst_sval.start);
|
||||||
m->mapping.skip = true;
|
m->mapping.skip = true;
|
||||||
return;
|
return;
|
||||||
|
@ -467,12 +464,12 @@ static void
|
||||||
matcher_mapping_verify(struct matcher *m)
|
matcher_mapping_verify(struct matcher *m)
|
||||||
{
|
{
|
||||||
if (m->mapping.num_mlvo == 0) {
|
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;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->mapping.num_kccgst == 0) {
|
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;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +520,7 @@ matcher_rule_set_mlvo_common(struct matcher *m, struct sval ident,
|
||||||
enum mlvo_match_type match_type)
|
enum mlvo_match_type match_type)
|
||||||
{
|
{
|
||||||
if (m->rule.num_mlvo_values + 1 > m->mapping.num_mlvo) {
|
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;
|
m->rule.skip = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -555,7 +552,7 @@ static void
|
||||||
matcher_rule_set_kccgst(struct matcher *m, struct sval ident)
|
matcher_rule_set_kccgst(struct matcher *m, struct sval ident)
|
||||||
{
|
{
|
||||||
if (m->rule.num_kccgst_values + 1 > m->mapping.num_kccgst) {
|
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;
|
m->rule.skip = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -669,7 +666,7 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to,
|
||||||
int consumed;
|
int consumed;
|
||||||
|
|
||||||
if (mlv != MLVO_LAYOUT && mlv != MLVO_VARIANT) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,7 +742,7 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to,
|
||||||
|
|
||||||
error:
|
error:
|
||||||
darray_free(expanded);
|
darray_free(expanded);
|
||||||
matcher_err(m, "invalid %%-expansion in value; not used");
|
scanner_err(&m->scanner, "invalid %%-expansion in value; not used");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +751,7 @@ matcher_rule_verify(struct matcher *m)
|
||||||
{
|
{
|
||||||
if (m->rule.num_mlvo_values != m->mapping.num_mlvo ||
|
if (m->rule.num_mlvo_values != m->mapping.num_mlvo ||
|
||||||
m->rule.num_kccgst_values != m->mapping.num_kccgst) {
|
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;
|
m->rule.skip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -994,7 +991,7 @@ finish:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
state_error:
|
state_error:
|
||||||
matcher_err(m, "unexpected token");
|
scanner_err(&m->scanner, "unexpected token");
|
||||||
error:
|
error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue