From f96019639d2553a4d026de9c2d5cf4e98b33b066 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 2 Sep 2010 19:00:31 +0200 Subject: [PATCH] common/util.h: Stop using a_tokenize() Signed-off-by: Uli Schlachter --- common/util.c | 29 +++++++++-------------------- common/util.h | 4 ++-- objects/wibox.c | 5 ++--- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/common/util.c b/common/util.c index 8e27dd67..b2987b70 100644 --- a/common/util.c +++ b/common/util.c @@ -27,7 +27,6 @@ #include #include "common/util.h" -#include "common/tokenize.h" /** Print error and exit with EXIT_FAILURE code. */ @@ -59,23 +58,18 @@ _warn(int line, const char *fct, const char *fmt, ...) /** Get a position type from a string. * \param pos The position. - * \param len The string length, -1 if unknown. * \return A position. */ position_t -position_fromstr(const char *pos, ssize_t len) +position_fromstr(const char *pos) { - switch(a_tokenize(pos, len)) - { - default: - return Top; - case A_TK_BOTTOM: + if(a_strcmp(pos, "bottom") == 0) return Bottom; - case A_TK_RIGHT: + if(a_strcmp(pos, "right") == 0) return Right; - case A_TK_LEFT: + if(a_strcmp(pos, "left") == 0) return Left; - } + return Top; } /** Convert a position type to a string. @@ -97,21 +91,16 @@ position_tostr(position_t p) /** Get a orientation type from a string. * \param pos The orientation. - * \param len The string length, -1 if unknown. * \return A orientation. */ orientation_t -orientation_fromstr(const char *pos, ssize_t len) +orientation_fromstr(const char *pos) { - switch(a_tokenize(pos, len)) - { - default: - return North; - case A_TK_SOUTH: + if(a_strcmp(pos, "south") == 0) return South; - case A_TK_EAST: + if(a_strcmp(pos, "east") == 0) return East; - } + return North; } /** Convert a orientation type to a string. diff --git a/common/util.h b/common/util.h index 46318269..f6af8d61 100644 --- a/common/util.h +++ b/common/util.h @@ -338,9 +338,9 @@ void _fatal(int, const char *, const char *, ...) void _warn(int, const char *, const char *, ...) __attribute__ ((format(printf, 3, 4))); -position_t position_fromstr(const char *, ssize_t); +position_t position_fromstr(const char *); const char * position_tostr(position_t); -orientation_t orientation_fromstr(const char *, ssize_t); +orientation_t orientation_fromstr(const char *); const char * orientation_tostr(orientation_t); void a_exec(const char *); diff --git a/objects/wibox.c b/objects/wibox.c index c45c0ec3..a36b92c6 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -1035,11 +1035,10 @@ luaA_wibox_get_screen(lua_State *L, wibox_t *wibox) static int luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox) { - size_t len; - const char *buf = luaL_checklstring(L, -1, &len); + const char *buf = luaL_checkstring(L, -1); if(buf) { - wibox_set_orientation(L, -3, orientation_fromstr(buf, len)); + wibox_set_orientation(L, -3, orientation_fromstr(buf)); wibox_need_update(wibox); } return 0;