Define our own None atom value
authorRan Benita <ran234@gmail.com>
Sat, 24 Mar 2012 10:33:28 +0000 (12:33 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 27 Mar 2012 13:16:11 +0000 (14:16 +0100)
Since we define our own xkb_atom_t type, it makes sense not to use the
X11/X.h None value. This way we can also remove a lot of X11 includes.

Signed-off-by: Ran Benita <ran234@gmail.com>
18 files changed:
src/atom.c
src/map.c
src/maprules.c
src/misc.c
src/xkballoc.h
src/xkbcomp/action.c
src/xkbcomp/expr.c
src/xkbcomp/keycodes.c
src/xkbcomp/keytypes.c
src/xkbcomp/symbols.c
src/xkbcomp/xkbcomp.h
src/xkbcomp/xkbparse.y
src/xkbmisc.h
src/xkbrules.h
test/filecomp.c
test/namescomp.c
test/rulescomp.c
test/state.c

index 40c2153..f39ba45 100644 (file)
@@ -88,7 +88,7 @@ typedef struct _Node {
 
 #define BAD_RESOURCE 0xe0000000
 
-static xkb_atom_t lastAtom = None;
+static xkb_atom_t lastAtom = XKB_ATOM_NONE;
 static NodePtr atomRoot = NULL;
 static unsigned long tableLength;
 static NodePtr *nodeTable = NULL;
@@ -98,7 +98,7 @@ XkbcAtomText(xkb_atom_t atom)
 {
     NodePtr node;
 
-    if ((atom == None) || (atom > lastAtom))
+    if ((atom == XKB_ATOM_NONE) || (atom > lastAtom))
         return NULL;
     if (!(node = nodeTable[atom]))
         return NULL;
@@ -123,7 +123,7 @@ xkb_intern_atom(const char *string)
     int makeit = True;
 
     if (!string)
-       return None;
+       return XKB_ATOM_NONE;
 
     len = strlen(string);
     np = &atomRoot;
@@ -181,7 +181,7 @@ xkb_intern_atom(const char *string)
                 return BAD_RESOURCE;
             }
             tableLength = newLength;
-           table[None] = NULL;
+           table[XKB_ATOM_NONE] = NULL;
 
             nodeTable = table;
         }
@@ -195,7 +195,7 @@ xkb_intern_atom(const char *string)
         return nd->a;
     }
     else
-        return None;
+        return XKB_ATOM_NONE;
 }
 
 static void
@@ -218,5 +218,5 @@ XkbcFreeAllAtoms(void)
     atomRoot = NULL;
     free(nodeTable);
     nodeTable = NULL;
-    lastAtom = None;
+    lastAtom = XKB_ATOM_NONE;
 }
index 34df22b..e51a67a 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -57,7 +57,6 @@
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 #include "xkballoc.h"
-#include <X11/X.h>
 
 /**
  * Returns the total number of modifiers active in the keymap.
index ecac8ae..1537ab8 100644 (file)
 #define XOS_USE_NO_LOCKING
 #include <X11/Xos_r.h>
 
-#include <X11/Xproto.h>
-#include <X11/X.h>
-#include <X11/Xos.h>
-#include <X11/Xfuncs.h>
-
 #ifdef DEBUG
 #define PR_DEBUG(s)            fprintf(stderr,s)
 #define PR_DEBUG1(s,a)         fprintf(stderr,s,a)
index 03ffeb7..37e6375 100644 (file)
@@ -60,25 +60,25 @@ static struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
       1,        /* num_levels */
       0,        /* map_count */
       NULL, NULL,
-      None, NULL
+      NULL, NULL
     },
     { { ShiftMask, ShiftMask, 0 },
       2,        /* num_levels */
       mapSize(map2Level),   /* map_count */
       map2Level, NULL,
-      None,      NULL
+      NULL,      NULL
     },
     { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
       2,        /* num_levels */
       mapSize(mapAlpha),    /* map_count */
       mapAlpha, preAlpha,
-      None,     NULL
+      NULL,     NULL
     },
     { { ShiftMask, ShiftMask, NL_VMOD_MASK },
       2,        /* num_levels */
       mapSize(mapKeypad),   /* map_count */
       mapKeypad, NULL,
-      None,      NULL
+      NULL,      NULL
     }
 };
 
index 2839eda..2e0a23e 100644 (file)
@@ -27,8 +27,8 @@ authorization from the authors.
 #ifndef _XKBALLOC_H_
 #define _XKBALLOC_H_
 
-#include <X11/X.h>
 #include <X11/Xdefs.h>
+#include <X11/X.h>
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 
index d0e2f0f..eca1d6d 100644 (file)
@@ -24,6 +24,8 @@
 
  ********************************************************/
 
+#include <X11/X.h>
+
 #include "xkbcomp.h"
 #include "xkbmisc.h"
 #include "expr.h"
index cd35494..75c59ad 100644 (file)
@@ -30,6 +30,7 @@
 #include "vmod.h"
 
 #include <ctype.h>
+#include <X11/X.h>
 
 /***====================================================================***/
 
@@ -169,7 +170,7 @@ SimpleLookup(const void * priv, xkb_atom_t field, unsigned type,
     const LookupEntry *entry;
     const char *str;
 
-    if ((priv == NULL) || (field == None) || (type != TypeInt))
+    if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt))
     {
         return False;
     }
index f03d7dd..bfe7d13 100644 (file)
@@ -141,7 +141,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
     ii->defs.fileID = info->fileID;
     ii->defs.next = NULL;
     ii->ndx = 0;
-    ii->name = None;
+    ii->name = XKB_ATOM_NONE;
     ii->virtual = False;
 }
 
index 00dc139..0a03afc 100644 (file)
@@ -121,7 +121,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
     info->dflt.defs.fileID = 0;
     info->dflt.defs.merge = MergeOverride;
     info->dflt.defs.next = NULL;
-    info->dflt.name = None;
+    info->dflt.name = XKB_ATOM_NONE;
     info->dflt.mask = 0;
     info->dflt.vmask = 0;
     info->dflt.groupInfo = False;
@@ -758,7 +758,7 @@ AddLevelName(KeyTypeInfo * type,
         }
         return True;
     }
-    else if (type->lvlNames[level] != None)
+    else if (type->lvlNames[level] != XKB_ATOM_NONE)
     {
         if (warningLevel > 0)
         {
@@ -984,7 +984,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
     }
     for (i = 0; i < info->dflt.szNames; i++)
     {
-        if ((i < type.numLevels) && (info->dflt.lvlNames[i] != None))
+        if ((i < type.numLevels) && (info->dflt.lvlNames[i] != XKB_ATOM_NONE))
         {
             AddLevelName(&type, i, info->dflt.lvlNames[i], False, False);
         }
index 35210e8..ddb7afb 100644 (file)
@@ -93,11 +93,11 @@ InitKeyInfo(KeyInfo * info)
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
         info->numLevels[i] = 0;
-        info->types[i] = None;
+        info->types[i] = XKB_ATOM_NONE;
         info->syms[i] = NULL;
         info->acts[i] = NULL;
     }
-    info->dfltType = None;
+    info->dfltType = XKB_ATOM_NONE;
     info->behavior.type = XkbKB_Default;
     info->behavior.data = 0;
     info->vmodmap = 0;
@@ -122,13 +122,13 @@ FreeKeyInfo(KeyInfo * info)
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
         info->numLevels[i] = 0;
-        info->types[i] = None;
+        info->types[i] = XKB_ATOM_NONE;
         free(info->syms[i]);
         info->syms[i] = NULL;
         free(info->acts[i]);
         info->acts[i] = NULL;
     }
-    info->dfltType = None;
+    info->dfltType = XKB_ATOM_NONE;
     info->behavior.type = XkbKB_Default;
     info->behavior.data = 0;
     info->vmodmap = 0;
@@ -242,7 +242,7 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
     info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo);
     info->modMap = NULL;
     for (i = 0; i < XkbNumKbdGroups; i++)
-        info->groupNames[i] = None;
+        info->groupNames[i] = XKB_ATOM_NONE;
     InitKeyInfo(&info->dflt);
     InitVModInfo(&info->vmods, xkb);
     info->action = NULL;
@@ -507,9 +507,9 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
                 MergeKeyGroups(info, into, from, (unsigned) i);
             }
         }
-        if (from->types[i] != None)
+        if (from->types[i] != XKB_ATOM_NONE)
         {
-            if ((into->types[i] != None) && (report) &&
+            if ((into->types[i] != XKB_ATOM_NONE) && report &&
                 (into->types[i] != from->types[i]))
             {
                 xkb_atom_t use, ignore;
@@ -532,7 +532,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
                         XkbcAtomText(ignore));
             }
             if ((from->defs.merge != MergeAugment)
-                || (into->types[i] == None))
+                || (into->types[i] == XKB_ATOM_NONE))
             {
                 into->types[i] = from->types[i];
             }
@@ -703,9 +703,10 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
     }
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
-        if (from->groupNames[i] != None)
+        if (from->groupNames[i] != XKB_ATOM_NONE)
         {
-            if ((merge != MergeAugment) || (into->groupNames[i] == None))
+            if ((merge != MergeAugment) ||
+                (into->groupNames[i] == XKB_ATOM_NONE))
                 into->groupNames[i] = from->groupNames[i];
         }
     }
@@ -1773,9 +1774,9 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
             haveActions = True;
         autoType = False;
         /* Assign the type to the key, if it is missing. */
-        if (key->types[i] == None)
+        if (key->types[i] == XKB_ATOM_NONE)
         {
-            if (key->dfltType != None)
+            if (key->dfltType != XKB_ATOM_NONE)
                 key->types[i] = key->dfltType;
             else if (FindAutomaticType(key->numLevels[i], key->syms[i],
                                        &key->types[i], &autoType))
@@ -2016,7 +2017,7 @@ CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
             ApplyAliases(xkb, &info.aliases);
         for (i = 0; i < XkbNumKbdGroups; i++)
         {
-            if (info.groupNames[i] != None)
+            if (info.groupNames[i] != XKB_ATOM_NONE)
             {
                 free(UNCONSTIFY(xkb->names->groups[i]));
                 xkb->names->groups[i] = XkbcAtomGetString(info.groupNames[i]);
index 3c98a4e..baab968 100644 (file)
@@ -27,9 +27,6 @@
 #ifndef XKBCOMP_H
 #define        XKBCOMP_H 1
 
-#include <X11/X.h>
-#include <X11/Xdefs.h>
-
 #include "utils.h"
 
 #include "xkbcommon/xkbcommon.h"
index 13e5628..9db7ee5 100644 (file)
@@ -569,11 +569,11 @@ Element           :       ACTION_TOK
                |       SHAPE   
                        { $$= xkb_intern_atom("shape"); }
                |       ROW     
-                       { $$= None; }
+                       { $$= XKB_ATOM_NONE; }
                |       SECTION 
-                       { $$= None; }
+                       { $$= XKB_ATOM_NONE; }
                |       TEXT
-                       { $$= None; }
+                       { $$= XKB_ATOM_NONE; }
                ;
 
 OptMergeMode   :       MergeMode               { $$= $1; }
@@ -658,7 +658,7 @@ Lhs         :       FieldSpec
                        {
                            ExprDef *expr;
                            expr= ExprCreate(ExprArrayRef,TypeUnknown);
-                           expr->value.array.element= None;
+                           expr->value.array.element= XKB_ATOM_NONE;
                            expr->value.array.field= $1;
                            expr->value.array.entry= $3;
                            $$= expr;
index 1d74ef5..7167aa0 100644 (file)
@@ -27,13 +27,14 @@ authorization from the authors.
 #ifndef _XKBMISC_H_
 #define _XKBMISC_H_
 
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 
 typedef uint32_t xkb_atom_t;
 
+#define XKB_ATOM_NONE 0
+
 /***====================================================================***/
 
 extern Bool
index a69e8b9..e57b056 100644 (file)
@@ -27,12 +27,9 @@ authorization from the authors.
 #ifndef _XKBRULES_H_
 #define _XKBRULES_H_
 
-#include <stdio.h>
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 
-
 /* From filecommon */
 
 #define XkbXKMFile  0
index e5538af..370c4b2 100644 (file)
@@ -32,8 +32,6 @@ authorization from the authors.
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
 
index 95dcecc..bd81447 100644 (file)
@@ -26,8 +26,6 @@ authorization from the authors.
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
 
index 0a84c94..c761a49 100644 (file)
@@ -26,7 +26,6 @@ authorization from the authors.
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
index 476ee18..5c6d1f5 100644 (file)
@@ -26,8 +26,6 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include <X11/keysym.h>
 #include <linux/input.h>
 #include "xkbcommon/xkbcommon.h"