From f0b87f3de6261a4b95e6a68aa0a24b35b5278e56 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 15 Jun 2010 18:47:37 +0100 Subject: XStringToKeysym: Special case for XF86 keysyms Some XFree86 keysyms were in XKeysymDB as XF86_foo, despite really being XF86foo. So, if we get to the bottom of XStringToKeysym and haven't found our XF86_foo, try it again as XF86foo. Signed-off-by: Daniel Stone Reviewed-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/StrKeysym.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nx-X11/lib/X11/StrKeysym.c') diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c index 9bdc80d32..98629ed18 100644 --- a/nx-X11/lib/X11/StrKeysym.c +++ b/nx-X11/lib/X11/StrKeysym.c @@ -152,5 +152,18 @@ XStringToKeysym(_Xconst char *s) return val; return val | 0x01000000; } + + /* 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. */ + if (strncmp(s, "XF86_", 5) == 0) { + KeySym ret; + char *tmp = strdup(s); + memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1); + ret = XStringToKeysym(tmp); + free(tmp); + return ret; + } + return NoSymbol; } -- cgit v1.2.3 From b414bc2c6f389224023c1d184d8aa0d18387512c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 8 Jul 2010 16:49:51 +0100 Subject: XStringToKeysym: Check strdup() return value Signed-off-by: Daniel Stone Reviewed-by: Keith Packard Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/StrKeysym.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nx-X11/lib/X11/StrKeysym.c') diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c index 98629ed18..a05e755e9 100644 --- a/nx-X11/lib/X11/StrKeysym.c +++ b/nx-X11/lib/X11/StrKeysym.c @@ -159,6 +159,8 @@ XStringToKeysym(_Xconst char *s) if (strncmp(s, "XF86_", 5) == 0) { KeySym ret; char *tmp = strdup(s); + if (!tmp) + return NoSymbol; memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1); ret = XStringToKeysym(tmp); free(tmp); -- cgit v1.2.3 From 93b55eeec022007d638c0a3b305765d44d3cd185 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 9 Jul 2010 18:13:13 +0100 Subject: 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 Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/StrKeysym.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'nx-X11/lib/X11/StrKeysym.c') diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c index a05e755e9..21dec924b 100644 --- a/nx-X11/lib/X11/StrKeysym.c +++ b/nx-X11/lib/X11/StrKeysym.c @@ -27,6 +27,7 @@ in this Software without prior written authorization from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include #include "Xlibint.h" #include #include @@ -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. */ -- cgit v1.2.3 From d91c145a46bcece11623121f5e468d24d5031cab Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 15 Feb 2013 23:25:38 -0800 Subject: XStringToKeysym: preserve constness when casting off unsignedness for strcmp Fixes gcc warning: StrKeysym.c:97:17: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/StrKeysym.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/lib/X11/StrKeysym.c') diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c index 21dec924b..125aceca3 100644 --- a/nx-X11/lib/X11/StrKeysym.c +++ b/nx-X11/lib/X11/StrKeysym.c @@ -94,7 +94,7 @@ XStringToKeysym(_Xconst char *s) { entry = &_XkeyTable[idx]; if ((entry[0] == sig1) && (entry[1] == sig2) && - !strcmp(s, (char *)entry + 6)) + !strcmp(s, (const char *)entry + 6)) { val = (entry[2] << 24) | (entry[3] << 16) | (entry[4] << 8) | entry[5]; -- cgit v1.2.3