From 602e87805bdb829dfc0867b1466e2b1dc729ab52 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 24 Mar 2012 13:27:48 +0200 Subject: Define our own NoSymbol value and use it 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 --- include/xkbcommon/xkbcommon.h | 2 ++ makekeys/makekeys.c | 9 ++++++--- src/keysym.c | 11 +++++------ src/malloc.c | 4 ++-- src/map.c | 2 +- src/xkballoc.h | 1 - src/xkbcomp/action.c | 2 -- src/xkbcomp/compat.c | 11 +++++------ src/xkbcomp/expr.c | 11 ++++++----- src/xkbcomp/parseutils.c | 4 ++-- src/xkbcomp/symbols.c | 14 +++++++------- src/xkbcomp/xkbpath.h | 1 - src/xkbcomp/xkbscan.l | 1 - test/xkey.c | 3 +-- 14 files changed, 37 insertions(+), 39 deletions(-) diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h index 0679235..b823890 100644 --- a/include/xkbcommon/xkbcommon.h +++ b/include/xkbcommon/xkbcommon.h @@ -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) diff --git a/makekeys/makekeys.c b/makekeys/makekeys.c index c731e40..4d7767f 100644 --- a/makekeys/makekeys.c +++ b/makekeys/makekeys.c @@ -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"); diff --git a/src/keysym.c b/src/keysym.c index 24fdf52..a5cbc44 100644 --- a/src/keysym.c +++ b/src/keysym.c @@ -28,7 +28,6 @@ authorization from the authors. #ifdef HAVE_CONFIG_H #include #endif -#include #include #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; } diff --git a/src/malloc.c b/src/malloc.c index 6168a67..37e513c 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -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; diff --git a/src/map.c b/src/map.c index e51a67a..114b0de 100644 --- 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; diff --git a/src/xkballoc.h b/src/xkballoc.h index 2e0a23e..d16c58b 100644 --- a/src/xkballoc.h +++ b/src/xkballoc.h @@ -27,7 +27,6 @@ authorization from the authors. #ifndef _XKBALLOC_H_ #define _XKBALLOC_H_ -#include #include #include "xkbcommon/xkbcommon.h" #include "XKBcommonint.h" diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index eca1d6d..d0e2f0f 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -24,8 +24,6 @@ ********************************************************/ -#include - #include "xkbcomp.h" #include "xkbmisc.h" #include "expr.h" diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 31de1e4..38cd013 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -24,7 +24,6 @@ ********************************************************/ -#include #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; diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 75c59ad..694d0c6 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -30,7 +30,6 @@ #include "vmod.h" #include -#include /***====================================================================***/ @@ -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); diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 631a452..1d66986 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -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; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index ddb7afb..b3953c1 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -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]) diff --git a/src/xkbcomp/xkbpath.h b/src/xkbcomp/xkbpath.h index 0273e9b..3632cbb 100644 --- a/src/xkbcomp/xkbpath.h +++ b/src/xkbcomp/xkbpath.h @@ -28,7 +28,6 @@ #define _XKBPATH_H_ 1 #include -#include #include extern const char *XkbDirectoryForInclude(unsigned /* type */ diff --git a/src/xkbcomp/xkbscan.l b/src/xkbcomp/xkbscan.l index 8120681..599a388 100644 --- a/src/xkbcomp/xkbscan.l +++ b/src/xkbcomp/xkbscan.l @@ -28,7 +28,6 @@ #include #include -#include #include "utils.h" #include "parseutils.h" diff --git a/test/xkey.c b/test/xkey.c index 52914a2..51909c2 100644 --- a/test/xkey.c +++ b/test/xkey.c @@ -3,12 +3,11 @@ #include #include #include -#include 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); -- cgit v1.2.1