xkbcomp: Require newline after !include line in rules files

Rules file parser allows constructs like

!include "foo" !include "bar" !layout = symbols

This is most likely an oversight in original code.

Closes #452
master
Mikhail Gusarov 2024-02-18 13:57:15 +01:00 committed by Peter Hutterer
parent 89ceb3515b
commit d21645be08
3 changed files with 15 additions and 0 deletions

View File

@ -978,6 +978,14 @@ include_statement:
switch (tok = gettok(m, s)) { switch (tok = gettok(m, s)) {
case TOK_IDENTIFIER: case TOK_IDENTIFIER:
matcher_include(m, s, include_depth, m->val.string); matcher_include(m, s, include_depth, m->val.string);
goto include_statement_end;
default:
goto unexpected;
}
include_statement_end:
switch (tok = gettok(m, s)) {
case TOK_END_OF_LINE:
goto initial; goto initial;
default: default:
goto unexpected; goto unexpected;

View File

@ -0,0 +1 @@
! include %S/inc-dst-simple !include %S/inc-dst-simple ! layout = symbols

View File

@ -159,6 +159,12 @@ main(int argc, char *argv[])
}; };
assert(test_rules(ctx, &test6)); assert(test_rules(ctx, &test6));
struct test_data test7 = {
.rules = "inc-no-newline",
.should_fail = true,
};
assert(test_rules(ctx, &test7));
xkb_context_unref(ctx); xkb_context_unref(ctx);
return 0; return 0;
} }