Skip to content

Commit

Permalink
xkbcomp: Require newline after !include line in rules files
Browse files Browse the repository at this point in the history
Rules file parser allows constructs like

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

This is most likely an oversight in original code.

Closes #452
  • Loading branch information
dottedmag authored and whot committed Feb 20, 2024
1 parent 89ceb35 commit d21645b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/xkbcomp/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,14 @@ matcher_match(struct matcher *m, struct scanner *s,
switch (tok = gettok(m, s)) {
case TOK_IDENTIFIER:
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;
default:
goto unexpected;
Expand Down
1 change: 1 addition & 0 deletions test/data/rules/inc-no-newline
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
! include %S/inc-dst-simple !include %S/inc-dst-simple ! layout = symbols
6 changes: 6 additions & 0 deletions test/rules-file-includes.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ main(int argc, char *argv[])
};
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);
return 0;
}

0 comments on commit d21645b

Please sign in to comment.