common/util.h: Stop using a_tokenize()

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-02 19:00:31 +02:00
parent dbe237319b
commit f96019639d
3 changed files with 13 additions and 25 deletions

View File

@ -27,7 +27,6 @@
#include <fcntl.h> #include <fcntl.h>
#include "common/util.h" #include "common/util.h"
#include "common/tokenize.h"
/** Print error and exit with EXIT_FAILURE code. /** 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. /** Get a position type from a string.
* \param pos The position. * \param pos The position.
* \param len The string length, -1 if unknown.
* \return A position. * \return A position.
*/ */
position_t position_t
position_fromstr(const char *pos, ssize_t len) position_fromstr(const char *pos)
{ {
switch(a_tokenize(pos, len)) if(a_strcmp(pos, "bottom") == 0)
{
default:
return Top;
case A_TK_BOTTOM:
return Bottom; return Bottom;
case A_TK_RIGHT: if(a_strcmp(pos, "right") == 0)
return Right; return Right;
case A_TK_LEFT: if(a_strcmp(pos, "left") == 0)
return Left; return Left;
} return Top;
} }
/** Convert a position type to a string. /** Convert a position type to a string.
@ -97,21 +91,16 @@ position_tostr(position_t p)
/** Get a orientation type from a string. /** Get a orientation type from a string.
* \param pos The orientation. * \param pos The orientation.
* \param len The string length, -1 if unknown.
* \return A orientation. * \return A orientation.
*/ */
orientation_t orientation_t
orientation_fromstr(const char *pos, ssize_t len) orientation_fromstr(const char *pos)
{ {
switch(a_tokenize(pos, len)) if(a_strcmp(pos, "south") == 0)
{
default:
return North;
case A_TK_SOUTH:
return South; return South;
case A_TK_EAST: if(a_strcmp(pos, "east") == 0)
return East; return East;
} return North;
} }
/** Convert a orientation type to a string. /** Convert a orientation type to a string.

View File

@ -338,9 +338,9 @@ void _fatal(int, const char *, const char *, ...)
void _warn(int, const char *, const char *, ...) void _warn(int, const char *, const char *, ...)
__attribute__ ((format(printf, 3, 4))); __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); 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); const char * orientation_tostr(orientation_t);
void a_exec(const char *); void a_exec(const char *);

View File

@ -1035,11 +1035,10 @@ luaA_wibox_get_screen(lua_State *L, wibox_t *wibox)
static int static int
luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox) luaA_wibox_set_orientation(lua_State *L, wibox_t *wibox)
{ {
size_t len; const char *buf = luaL_checkstring(L, -1);
const char *buf = luaL_checklstring(L, -1, &len);
if(buf) if(buf)
{ {
wibox_set_orientation(L, -3, orientation_fromstr(buf, len)); wibox_set_orientation(L, -3, orientation_fromstr(buf));
wibox_need_update(wibox); wibox_need_update(wibox);
} }
return 0; return 0;