KeySym: Actually handle NoSymbol
authorDaniel Stone <daniel@fooishbar.org>
Sat, 25 Apr 2009 04:32:04 +0000 (14:32 +1000)
committerDaniel Stone <daniel@fooishbar.org>
Sat, 25 Apr 2009 04:56:57 +0000 (14:56 +1000)
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>
src/keysym.c
src/makekeys/makekeys.c
test/xkey.sh

index 4738fc2..3bcfd8f 100644 (file)
@@ -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;
index 02b1efe..5e21964 100644 (file)
@@ -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");
index 7e6b16b..e1bb73e 100755 (executable)
@@ -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