[PATCH] Fix parsing of 0x1a2b3c4d-style symbols
Daniel Stone
daniel at fooishbar.org
Fri Jul 9 11:37:03 PDT 2010
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 at fooishbar.org>
---
configure.ac | 1 +
parseutils.c | 12 ++++++++++++
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;
}
diff --git a/xkbparse.y b/xkbparse.y
index 862acd8..d73b92a 100644
--- a/xkbparse.y
+++ b/xkbparse.y
@@ -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); }
}
;
--
1.7.1
More information about the xorg-devel
mailing list