compose/parser: fix parsing of multiple modifiers
authorRan Benita <ran234@gmail.com>
Tue, 14 Oct 2014 08:28:17 +0000 (11:28 +0300)
committerRan Benita <ran234@gmail.com>
Tue, 14 Oct 2014 08:28:57 +0000 (11:28 +0300)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/compose/parser.c

index d1ac0137abbe396835b2c8fc4b06f5afa38a9647..ebc1ffd8b92a7ce613a5b9ffdbe4cb1dff199afb 100644 (file)
@@ -530,7 +530,6 @@ parse(struct xkb_compose_table *table, struct scanner *s,
     union lvalue val;
     struct keysym_from_name_cache *cache = s->priv;
     xkb_keysym_t keysym;
-    bool tilde;
     struct production production;
     enum { MAX_ERRORS = 10 };
     int num_errors = 0;
@@ -594,7 +593,6 @@ lhs_tok:
         production.modmask = 0xff;
         goto lhs_keysym;
     case TOK_BANG:
-        tilde = false;
         goto lhs_mod_list;
     default:
         goto lhs_keysym_tok;
@@ -624,27 +622,36 @@ lhs_keysym_tok:
         goto unexpected;
     }
 
-lhs_mod_list:
-    switch (tok = lex(s, &val)) {
-    case TOK_TILDE:
-        tilde = true;
-        goto lhs_mod_list;
-    case TOK_IDENT: {
-        xkb_mod_index_t mod = resolve_modifier(val.string.str);
+lhs_mod_list: {
+        bool tilde = false;
+        xkb_mod_index_t mod;
+
+        tok = lex(s, &val);
+        if (tok == TOK_TILDE) {
+            tilde = true;
+            tok = lex(s, &val);
+        }
+
+        if (tok != TOK_IDENT) {
+            if (tilde || production.modmask == 0)
+                goto unexpected;
+            goto lhs_keysym_tok;
+        }
+
+        mod = resolve_modifier(val.string.str);
         if (mod == XKB_MOD_INVALID) {
             scanner_err(s, "unrecognized modifier \"%s\"",
                         val.string.str);
             goto error;
         }
+
         production.modmask |= 1 << mod;
         if (tilde)
             production.mods &= ~(1 << mod);
         else
             production.mods |= 1 << mod;
-        goto lhs;
-    }
-    default:
-        goto unexpected;
+
+        goto lhs_mod_list;
     }
 
 rhs: