From b38525421f5b6f28b7f441ff8b2c3a97b047aae2 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 21 Jun 2010 14:27:58 +0100 Subject: [PATCH] Interp: More lazy keysym resolution Resolve the keysyms when we create an InterpDef, rather than directly in the parser. Signed-off-by: Daniel Stone --- src/xkbcomp/compat.c | 8 +++++++- src/xkbcomp/parseutils.c | 4 ++-- src/xkbcomp/parseutils.h | 2 +- src/xkbcomp/xkbparse.y | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 3c6146a..6058c5a 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -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)) diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index cea1572..f2847e2 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -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 diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h index 9bc0a6b..d96a20b 100644 --- a/src/xkbcomp/parseutils.h +++ b/src/xkbcomp/parseutils.h @@ -88,7 +88,7 @@ extern VarDef *BoolVarCreate(Atom /* nameToken */ , unsigned /* set */ ); -extern InterpDef *InterpCreate(CARD32 /* sym */ , +extern InterpDef *InterpCreate(char * /* sym */ , ExprDef * /* match */ ); diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y index 1c05356..32f8f0a 100644 --- a/src/xkbcomp/xkbparse.y +++ b/src/xkbcomp/xkbparse.y @@ -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