rules: fix scanning of line-continuation without leading space
authorRan Benita <ran234@gmail.com>
Mon, 14 Oct 2013 16:05:24 +0000 (19:05 +0300)
committerRan Benita <ran234@gmail.com>
Mon, 14 Oct 2013 16:05:24 +0000 (19:05 +0300)
We were failing to scan something like\
this correctly.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/rules.c
test/data/rules/groups

index 54468a0..de82d96 100644 (file)
@@ -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++;
         }
index d9de6ee..15dc3c5 100644 (file)
@@ -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 =