diff options
author | Daniel Stone <daniel@fooishbar.org> | 2010-07-09 19:34:29 +0100 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2010-07-09 19:34:29 +0100 |
commit | a281386fa887e6bf4110840779aed46dd0ac89b6 (patch) | |
tree | 1a2ff173806fc86f0bc91a79475db064f1fdacb2 | |
parent | 0b04ecbb7a6afb223c91d3b15baab0bc48542281 (diff) |
Fix parsing of 0x1a2b3c4d-style symbols
Raw keysyms were not getting parsed correctly, due to forgetting to add
the code to libX11, forgetting to add the backwards-compat code for old
libX11s, and then stuffing the lexing up anyway. Yeesh.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | parseutils.c | 12 | ||||
-rw-r--r-- | xkbparse.y | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 3ad342c..6ed68c6 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,7 @@ AC_PROG_INSTALL AC_CHECK_FUNCS([strdup strcasecmp]) +AC_CHECK_HEADERS([limits.h]) # Checks for pkg-config packages PKG_CHECK_MODULES(XKBCOMP, x11 xkbfile) diff --git a/parseutils.c b/parseutils.c index d59e3fb..3242965 100644 --- a/parseutils.c +++ b/parseutils.c @@ -30,6 +30,10 @@ #include <X11/keysym.h> #include <X11/extensions/XKBgeom.h> #include <X11/Xalloca.h> +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif +#include <stdlib.h> XkbFile *rtrnValue; @@ -623,6 +627,7 @@ int LookupKeysym(char *str, KeySym * sym_rtrn) { KeySym sym; + char *tmp; if ((!str) || (uStrCaseCmp(str, "any") == 0) || (uStrCaseCmp(str, "nosymbol") == 0)) @@ -642,6 +647,13 @@ LookupKeysym(char *str, KeySym * sym_rtrn) *sym_rtrn = sym; return 1; } + if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') { + sym = strtoul(str, &tmp, 16); + if (sym != ULONG_MAX && (!tmp || *tmp == '\0')) { + *sym_rtrn = sym; + return 1; + } + } return 0; } @@ -726,7 +726,7 @@ KeySym : IDENT { $$= strdup(scanBuf); } | Integer { if ($1<10) { $$= malloc(2); $$[0]= '0' + $1; $$[1]= '\0'; } - else { $$= malloc(17); snprintf($$, 17, "%x", $1); } + else { $$= malloc(19); snprintf($$, 19, "0x%x", $1); } } ; |