From 1f9547b4e0f48d2eab9933296b3c5e0a7f3d1580 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 2 Sep 2010 19:12:21 +0200 Subject: [PATCH] common/xutil.c: Stop using a_tokenize Signed-off-by: Uli Schlachter --- common/xutil.c | 36 ++++++++++++++++++++---------------- common/xutil.h | 2 +- objects/key.c | 5 ++--- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/common/xutil.c b/common/xutil.c index 3676a3cd2..1cd4bc7cd 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -29,7 +29,6 @@ #include #include "common/xutil.h" -#include "common/tokenize.h" /** Get the lock masks (shiftlock, numlock, capslock, modeswitch). * \param connection The X connection. @@ -94,23 +93,28 @@ xutil_lock_mask_get(xcb_connection_t *connection, #define ERRORS_NBR 256 uint16_t -xutil_key_mask_fromstr(const char *keyname, size_t len) +xutil_key_mask_fromstr(const char *keyname) { - switch(a_tokenize(keyname, len)) - { - case A_TK_SHIFT: return XCB_MOD_MASK_SHIFT; - case A_TK_LOCK: return XCB_MOD_MASK_LOCK; - case A_TK_CTRL: - case A_TK_CONTROL: return XCB_MOD_MASK_CONTROL; - case A_TK_MOD1: return XCB_MOD_MASK_1; - case A_TK_MOD2: return XCB_MOD_MASK_2; - case A_TK_MOD3: return XCB_MOD_MASK_3; - case A_TK_MOD4: return XCB_MOD_MASK_4; - case A_TK_MOD5: return XCB_MOD_MASK_5; + if(a_strcmp(keyname, "Shift") == 0) + return XCB_MOD_MASK_SHIFT; + if(a_strcmp(keyname, "Lock") == 0) + return XCB_MOD_MASK_LOCK; + if(a_strcmp(keyname, "Ctrl") == 0 || a_strcmp(keyname, "Control") == 0) + return XCB_MOD_MASK_CONTROL; + if(a_strcmp(keyname, "Mod1") == 0) + return XCB_MOD_MASK_1; + if(a_strcmp(keyname, "Mod2") == 0) + return XCB_MOD_MASK_2; + if(a_strcmp(keyname, "Mod3") == 0) + return XCB_MOD_MASK_3; + if(a_strcmp(keyname, "Mod4") == 0) + return XCB_MOD_MASK_4; + if(a_strcmp(keyname, "Mod5") == 0) + return XCB_MOD_MASK_5; + if(a_strcmp(keyname, "Any") == 0) /* this is misnamed but correct */ - case A_TK_ANY: return XCB_BUTTON_MASK_ANY; - default: return XCB_NO_SYMBOL; - } + return XCB_BUTTON_MASK_ANY; + return XCB_NO_SYMBOL; } void diff --git a/common/xutil.h b/common/xutil.h index baabc0b71..b87412c58 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -57,7 +57,7 @@ void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_t, xcb_key_symbols_t *, uint16_t *, uint16_t *, uint16_t *, uint16_t *); -uint16_t xutil_key_mask_fromstr(const char *, size_t); +uint16_t xutil_key_mask_fromstr(const char *); void xutil_key_mask_tostr(uint16_t, const char **, size_t *); #endif diff --git a/objects/key.c b/objects/key.c index 4c2c80d91..5f61ae7ce 100644 --- a/objects/key.c +++ b/objects/key.c @@ -147,9 +147,8 @@ luaA_tomodifiers(lua_State *L, int ud) for(int i = 1; i <= len; i++) { lua_rawgeti(L, ud, i); - size_t blen; - const char *key = luaL_checklstring(L, -1, &blen); - mod |= xutil_key_mask_fromstr(key, blen); + const char *key = luaL_checkstring(L, -1); + mod |= xutil_key_mask_fromstr(key); lua_pop(L, 1); } return mod;