Commit 8e3239a78f7e47321535a4917bddf4ce00d3d244

Daniel Stone 2009-04-25T14:32:04

KeySym: Actually handle NoSymbol Add NoSymbol into the keysym table, so keysym <-> string conversion works for that, too; also eliminate special-casing of VoidSymbol. This will require special-casing in libX11 to preserve its API. Signed-off-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/src/keysym.c b/src/keysym.c
index 4738fc2..3bcfd8f 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -42,13 +42,17 @@ XkbcKeysymToString(KeySym ks)
 {
     int i, n, h, idx;
     const unsigned char *entry;
+    static char ret[11];
     unsigned char val1, val2, val3, val4;
 
-    if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
+    if ((ks & ((unsigned long) ~0x1fffffff)) != 0)
         return NULL;
 
-    if (ks == XK_VoidSymbol)
-        ks = 0;
+    /* Not listed in keysymdef.h for hysterical raisins. */
+    if (ks == NoSymbol) {
+        sprintf(ret, "NoSymbol");
+        return ret;
+    }
 
     if (ks <= 0x1fffffff) {
         val1 = ks >> 24;
diff --git a/src/makekeys/makekeys.c b/src/makekeys/makekeys.c
index 02b1efe..5e21964 100644
--- a/src/makekeys/makekeys.c
+++ b/src/makekeys/makekeys.c
@@ -206,8 +206,6 @@ main(int argc, char *argv[])
                 continue;
         }
 
-        if (info[ksnum].val == XK_VoidSymbol)
-            info[ksnum].val = 0;
         if (info[ksnum].val > 0x1fffffff) {
             fprintf(stderr,
                     "ignoring illegal keysym (%s), remove it from .h file!\n",
@@ -228,6 +226,11 @@ main(int argc, char *argv[])
         }
     }
 
+    /* Special case NoSymbol. */
+    info[ksnum].name = strdup("NoSymbol");
+    info[ksnum].val = 0L;
+    ksnum++;
+
     printf("/* This file is generated from keysymdef.h. */\n");
     printf("/* Do not edit. */\n");
     printf("\n");
diff --git a/test/xkey.sh b/test/xkey.sh
index 7e6b16b..e1bb73e 100755
--- a/test/xkey.sh
+++ b/test/xkey.sh
@@ -40,6 +40,7 @@ rm -f "$log"
 check_string Undo 0xFF65
 check_key 0x1008FF56 XF86Close
 check_string ThisKeyShouldNotExist NoSymbol
-check_key 0x0 NULL
+check_key 0x0 NoSymbol
 check_string XF86_Switch_VT_5 0x1008FE05
 check_key 0x1008FE20 XF86_Ungrab
+check_string VoidSymbol 0xFFFFFF