diff options
author | Daniel Stone <daniel@fooishbar.org> | 2010-07-09 18:13:13 +0100 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2010-07-20 12:36:10 +0100 |
commit | 2e7a18b6a617b9b4bfcea2d36f2bd2d7e0c4a3dd (patch) | |
tree | c2105da797729ec1c00afa6baf51e7896f69b72c /src | |
parent | 3df45ed0c29b98ff468a0ff0ba24830bb664fd5a (diff) |
XStringToKeysym: Cope with 0x1234cafe-style input
If we get input in the style of 0xdeadbeef, just return that exact
keysym. Introduces a dependency on strtoul, which I'm told is OK on all
the systems we care about.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/StrKeysym.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/StrKeysym.c b/src/StrKeysym.c index 4bed94bf..4394e0cd 100644 --- a/src/StrKeysym.c +++ b/src/StrKeysym.c @@ -27,6 +27,7 @@ in this Software without prior written authorization from The Open Group. #ifdef HAVE_CONFIG_H #include <config.h> #endif +#include <limits.h> #include "Xlibint.h" #include <X11/Xresource.h> #include <X11/keysymdef.h> @@ -153,6 +154,15 @@ XStringToKeysym(_Xconst char *s) return val | 0x01000000; } + if (strlen(s) > 2 && s[0] == '0' && s[1] == 'x') { + char *tmp = NULL; + val = strtoul(s, &tmp, 16); + if (val == ULONG_MAX || (tmp && *tmp != '\0')) + return NoSymbol; + else + return val; + } + /* Stupid inconsistency between the headers and XKeysymDB: the former has * no separating underscore, while some XF86* syms in the latter did. * As a last ditch effort, try without. */ |