Define our own NoSymbol value and use it
authorRan Benita <ran234@gmail.com>
Sat, 24 Mar 2012 11:27:48 +0000 (13:27 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 27 Mar 2012 13:16:36 +0000 (14:16 +0100)
Since we have our own xkb_keysym_t type, it makes sense to have our own
NoSymbol value instead of the one from X11/X.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
14 files changed:
include/xkbcommon/xkbcommon.h
makekeys/makekeys.c
src/keysym.c
src/malloc.c
src/map.c
src/xkballoc.h
src/xkbcomp/action.c
src/xkbcomp/compat.c
src/xkbcomp/expr.c
src/xkbcomp/parseutils.c
src/xkbcomp/symbols.c
src/xkbcomp/xkbpath.h
src/xkbcomp/xkbscan.l
test/xkey.c

index 0679235..b823890 100644 (file)
@@ -97,6 +97,8 @@ typedef uint32_t xkb_led_index_t;
 #define XKB_KEYCODE_INVALID             (0xffffffff)
 #define XKB_LED_INVALID                 (0xffffffff)
 
+#define XKB_KEYSYM_NO_SYMBOL            0
+
 #define XKB_KEYCODE_MAX                 (0xffffffff - 1)
 #define xkb_keycode_is_legal_ext(kc)    (kc <= XKB_KEYCODE_MAX)
 #define xkb_keycode_is_legal_x11(kc)    (kc <= XKB_KEYCODE_MAX)
index c731e40..4d7767f 100644 (file)
@@ -26,7 +26,10 @@ from The Open Group.
 
 */
 
-/* Constructs hash tables for XStringToKeysym and XKeysymToString. */
+/*
+ * Constructs hash tables for xkb_keysym_to_string and
+ * xkb_string_from_keysym.
+ */
 
 #include "xkbcommon/xkbcommon.h"
 
@@ -151,9 +154,9 @@ main(int argc, char *argv[])
         fclose(fptr);
     }
 
-    /* Special case NoSymbol. */
+    /* Special case XKB_KEYSYM_NO_SYMBOL. */
     info[ksnum].name = strdup("NoSymbol");
-    info[ksnum].val = 0L;
+    info[ksnum].val = XKB_KEYSYM_NO_SYMBOL;
     ksnum++;
 
     printf("/* This file is generated from keysymdef.h. */\n");
index 24fdf52..a5cbc44 100644 (file)
@@ -28,7 +28,6 @@ authorization from the authors.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-#include <X11/X.h>
 #include <X11/keysymdef.h>
 #include "xkbmisc.h"
 #include "xkbcommon/xkbcommon.h"
@@ -50,7 +49,7 @@ xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
     }
 
     /* Not listed in keysymdef.h for hysterical raisins. */
-    if (ks == NoSymbol) {
+    if (ks == XKB_KEYSYM_NO_SYMBOL) {
         snprintf(buffer, size, "NoSymbol");
         return;
     }
@@ -135,11 +134,11 @@ xkb_string_to_keysym(const char *s)
         val = strtoul(&s[1], NULL, 16);
 
         if (val < 0x20 || (val > 0x7e && val < 0xa0))
-            return NoSymbol;
+            return XKB_KEYSYM_NO_SYMBOL;
         if (val < 0x100)
             return val;
         if (val > 0x10ffff)
-            return NoSymbol;
+            return XKB_KEYSYM_NO_SYMBOL;
         return val | 0x01000000;
     }
     else if (s[0] == '0' && s[1] == 'x') {
@@ -153,12 +152,12 @@ xkb_string_to_keysym(const char *s)
         xkb_keysym_t ret;
         char *tmp = strdup(s);
         if (!tmp)
-            return NoSymbol;
+            return XKB_KEYSYM_NO_SYMBOL;
         memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
         ret = xkb_string_to_keysym(tmp);
         free(tmp);
         return ret;
     }
 
-    return NoSymbol;
+    return XKB_KEYSYM_NO_SYMBOL;
 }
index 6168a67..37e513c 100644 (file)
@@ -92,7 +92,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
                 return BadAlloc;
             }
             map->num_syms = 1;
-            map->syms[0] = NoSymbol;
+            map->syms[0] = XKB_KEYSYM_NO_SYMBOL;
         }
 
         if (!map->key_sym_map) {
@@ -295,7 +295,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
     if (!newSyms)
         return NULL;
 
-    newSyms[0] = NoSymbol;
+    newSyms[0] = XKB_KEYSYM_NO_SYMBOL;
     nSyms = 1;
     for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
         uint32_t nCopy;
index e51a67a..114b0de 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -305,7 +305,7 @@ xkb_key_get_syms_by_level(struct xkb_desc *xkb, xkb_keycode_t key, unsigned int
                           unsigned int level, xkb_keysym_t **syms_out)
 {
     *syms_out = &(XkbKeySymEntry(xkb, key, level, group));
-    if (**syms_out == NoSymbol)
+    if (**syms_out == XKB_KEYSYM_NO_SYMBOL)
         goto err;
 
     return 1;
index 2e0a23e..d16c58b 100644 (file)
@@ -27,7 +27,6 @@ authorization from the authors.
 #ifndef _XKBALLOC_H_
 #define _XKBALLOC_H_
 
-#include <X11/Xdefs.h>
 #include <X11/X.h>
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
index eca1d6d..d0e2f0f 100644 (file)
@@ -24,8 +24,6 @@
 
  ********************************************************/
 
-#include <X11/X.h>
-
 #include "xkbcomp.h"
 #include "xkbmisc.h"
 #include "expr.h"
index 31de1e4..38cd013 100644 (file)
@@ -24,7 +24,6 @@
 
  ********************************************************/
 
-#include <X11/Xos.h>
 #include "xkbcomp.h"
 #include "xkballoc.h"
 #include "xkbmisc.h"
@@ -778,8 +777,8 @@ CopyInterps(CompatInfo * info,
     for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next)
     {
         if (((si->interp.match & XkbSI_OpMask) != pred) ||
-            (needSymbol && (si->interp.sym == NoSymbol)) ||
-            ((!needSymbol) && (si->interp.sym != NoSymbol)))
+            (needSymbol && (si->interp.sym == XKB_KEYSYM_NO_SYMBOL)) ||
+            ((!needSymbol) && (si->interp.sym != XKB_KEYSYM_NO_SYMBOL)))
             continue;
         if (compat->num_si >= compat->size_si)
         {
@@ -894,7 +893,7 @@ UpdateActionMods(struct xkb_desc *xkb, union xkb_action *act, uint32_t rmodmask)
 /**
  * Find an interpretation which applies to this particular level, either by
  * finding an exact match for the symbol and modifier combination, or a
- * generic NoSymbol match.
+ * generic XKB_KEYSYM_NO_SYMBOL match.
  */
 static struct xkb_sym_interpret *
 FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32_t level)
@@ -914,7 +913,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
         Bool found;
 
         if ((num_syms != 1 || interp->sym != syms[0]) &&
-            interp->sym != NoSymbol)
+            interp->sym != XKB_KEYSYM_NO_SYMBOL)
             continue;
 
         if (level == 0 || !(interp->match & XkbSI_LevelOneOnly))
@@ -943,7 +942,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
             break;
         }
 
-        if (found && interp->sym != NoSymbol)
+        if (found && interp->sym != XKB_KEYSYM_NO_SYMBOL)
             return interp;
         else if (found && !ret)
             ret = interp;
index 75c59ad..694d0c6 100644 (file)
@@ -30,7 +30,6 @@
 #include "vmod.h"
 
 #include <ctype.h>
-#include <X11/X.h>
 
 /***====================================================================***/
 
@@ -985,10 +984,12 @@ ExprResolveKeySym(ExprDef * expr,
     {
         const char *str;
         str = XkbcAtomText(expr->value.str);
-        if ((str != NULL) && ((sym = xkb_string_to_keysym(str)) != NoSymbol))
-        {
-            val_rtrn->uval = sym;
-            return True;
+        if (str) {
+            sym = xkb_string_to_keysym(str);
+            if (sym != XKB_KEYSYM_NO_SYMBOL) {
+                val_rtrn->uval = sym;
+                return True;
+            }
         }
     }
     ok = ExprResolveInteger(expr, val_rtrn);
index 631a452..1d66986 100644 (file)
@@ -440,7 +440,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
     if ((!str) || (strcasecmp(str, "any") == 0) ||
         (strcasecmp(str, "nosymbol") == 0))
     {
-        *sym_rtrn = NoSymbol;
+        *sym_rtrn = XKB_KEYSYM_NO_SYMBOL;
         return 1;
     }
     else if ((strcasecmp(str, "none") == 0) ||
@@ -450,7 +450,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
         return 1;
     }
     sym = xkb_string_to_keysym(str);
-    if (sym != NoSymbol)
+    if (sym != XKB_KEYSYM_NO_SYMBOL)
     {
         *sym_rtrn = sym;
         return 1;
index ddb7afb..b3953c1 100644 (file)
@@ -358,14 +358,14 @@ MergeKeyGroups(SymbolsInfo * info,
         if (from->syms[group] && (i < from->numLevels[group]))
             fromSym = from->syms[group][i];
         else
-            fromSym = NoSymbol;
+            fromSym = XKB_KEYSYM_NO_SYMBOL;
         if (into->syms[group] && (i < into->numLevels[group]))
             toSym = into->syms[group][i];
         else
-            toSym = NoSymbol;
-        if ((fromSym == NoSymbol) || (fromSym == toSym))
+            toSym = XKB_KEYSYM_NO_SYMBOL;
+        if ((fromSym == XKB_KEYSYM_NO_SYMBOL) || (fromSym == toSym))
             resultSyms[i] = toSym;
-        else if (toSym == NoSymbol)
+        else if (toSym == XKB_KEYSYM_NO_SYMBOL)
             resultSyms[i] = fromSym;
         else
         {
@@ -927,11 +927,11 @@ AddSymbolsToKey(KeyInfo * key,
             WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
                   value->value.list.syms[i], longText(key->name), ndx + 1,
                   XkbcAtomText(info->groupNames[ndx]), nSyms);
-            key->syms[ndx][i] = NoSymbol;
+            key->syms[ndx][i] = XKB_KEYSYM_NO_SYMBOL;
         }
     }
     for (j = key->numLevels[ndx] - 1;
-         (j >= 0) && (key->syms[ndx][j] == NoSymbol); j--)
+         (j >= 0) && (key->syms[ndx][j] == XKB_KEYSYM_NO_SYMBOL); j--)
     {
         key->numLevels[ndx]--;
     }
@@ -1878,7 +1878,7 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
                 if (tmp < key->numLevels[i])
                     outSyms[tmp] = key->syms[i][tmp];
                 else
-                    outSyms[tmp] = NoSymbol;
+                    outSyms[tmp] = XKB_KEYSYM_NO_SYMBOL;
                 if ((outActs != NULL) && (key->acts[i] != NULL))
                 {
                     if (tmp < key->numLevels[i])
index 0273e9b..3632cbb 100644 (file)
@@ -28,7 +28,6 @@
 #define _XKBPATH_H_ 1
 
 #include <stdio.h>
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 
 extern const char *XkbDirectoryForInclude(unsigned    /* type */
index 8120681..599a388 100644 (file)
@@ -28,7 +28,6 @@
 
 #include <stdio.h>
 #include <ctype.h>
-#include <X11/Xos.h>
 
 #include "utils.h"
 #include "parseutils.h"
index 52914a2..51909c2 100644 (file)
@@ -3,12 +3,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <X11/X.h>
 
 static void print_keysym(const char *s)
 {
     xkb_keysym_t ks = xkb_string_to_keysym(s);
-    if (ks == NoSymbol)
+    if (ks == XKB_KEYSYM_NO_SYMBOL)
         printf("NoSymbol\n");
     else
         printf("0x%lX\n", ks);