Interp: More lazy keysym resolution
authorDaniel Stone <daniel@fooishbar.org>
Mon, 21 Jun 2010 13:27:58 +0000 (14:27 +0100)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 22 Jun 2010 14:57:16 +0000 (15:57 +0100)
Resolve the keysyms when we create an InterpDef, rather than directly
in the parser.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
src/xkbcomp/compat.c
src/xkbcomp/parseutils.c
src/xkbcomp/parseutils.h
src/xkbcomp/xkbparse.y

index 3c6146a..6058c5a 100644 (file)
@@ -35,6 +35,7 @@
 #include "indicators.h"
 #include "action.h"
 #include "compat.h"
+#include "parseutils.h"
 
 typedef struct _SymInterpInfo
 {
@@ -667,7 +668,12 @@ HandleInterpDef(InterpDef * def, XkbcDescPtr xkb, unsigned merge,
 
     si = info->dflt;
     si.defs.merge = merge;
-    si.interp.sym = def->sym;
+    if (!LookupKeysym(def->sym, &si.interp.sym))
+    {
+        WARN("Could not resolve keysym %s\n", def->sym);
+        info->errorCount++;
+        return False;
+    }
     si.interp.match = pred & XkbSI_OpMask;
     si.interp.mods = mods;
     if (!HandleInterpBody(def->def, xkb, &si, info))
index cea1572..f2847e2 100644 (file)
@@ -219,7 +219,7 @@ BoolVarCreate(Atom nameToken, unsigned set)
 }
 
 InterpDef *
-InterpCreate(CARD32 sym, ExprDef * match)
+InterpCreate(char *sym, ExprDef * match)
 {
     InterpDef *def;
 
@@ -228,7 +228,7 @@ InterpCreate(CARD32 sym, ExprDef * match)
     {
         def->common.stmtType = StmtInterpDef;
         def->common.next = NULL;
-        def->sym = sym;
+        def->sym = strdup(sym);
         def->match = match;
     }
     else
index 9bc0a6b..d96a20b 100644 (file)
@@ -88,7 +88,7 @@ extern VarDef *BoolVarCreate(Atom /* nameToken */ ,
                              unsigned   /* set */
     );
 
-extern InterpDef *InterpCreate(CARD32 /* sym */ ,
+extern InterpDef *InterpCreate(char * /* sym */ ,
                                ExprDef *        /* match */
     );
 
index 1c05356..32f8f0a 100644 (file)
@@ -376,9 +376,9 @@ InterpretDecl       :       INTERPRET InterpretMatch OBRACE
                ;
 
 InterpretMatch :       KeySym PLUS Expr        
-                       { $$= InterpCreate(XStringToKeysym($1), $3); }
+                       { $$= InterpCreate($1, $3); }
                |       KeySym                  
-                       { $$= InterpCreate(XStringToKeysym($1), NULL); }
+                       { $$= InterpCreate($1, NULL); }
                ;
 
 VarDeclList    :       VarDeclList VarDecl