rules: fix scanning of line-continuation without leading space We were failing to scan something like\ this correctly. Signed-off-by: Ran Benita <ran234@gmail.com>
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
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 54468a0..de82d96 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -164,6 +164,12 @@ enum rules_token {
log_warn((scanner)->ctx, "rules/%s:%d:%d: " fmt "\n", \
(scanner)->file_name, (loc)->line, (loc)->column, __VA_ARGS__)
+static inline bool
+is_ident(char ch)
+{
+ return is_graph(ch) && ch != '\\';
+}
+
static enum rules_token
lex(struct scanner *s, union lvalue *val, struct location *loc)
{
@@ -209,7 +215,7 @@ skip_more_whitespace_and_comments:
if (chr(s, '$')) {
val->string.start = s->s + s->pos;
val->string.len = 0;
- while (is_graph(peek(s))) {
+ while (is_ident(peek(s))) {
next(s);
val->string.len++;
}
@@ -222,10 +228,10 @@ skip_more_whitespace_and_comments:
}
/* Identifier. */
- if (is_graph(peek(s))) {
+ if (is_ident(peek(s))) {
val->string.start = s->s + s->pos;
val->string.len = 0;
- while (is_graph(peek(s))) {
+ while (is_ident(peek(s))) {
next(s);
val->string.len++;
}
diff --git a/test/data/rules/groups b/test/data/rules/groups
index d9de6ee..15dc3c5 100644
--- a/test/data/rules/groups
+++ b/test/data/rules/groups
@@ -1,4 +1,7 @@
-! $model_group = pc101 pc102 pc104 pc105
+! $model_group = pc101 pc102 \
+ pc104\
+ pc105\
+ pc106
! $layout_group = ar br cr us
! $variant_group =