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 "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.

View File

@ -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 *);

View File

@ -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;