From 56fd77139e5d2cebb02d8b2a6d0e3dde1c6b7c60 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 2 Sep 2010 19:04:48 +0200 Subject: [PATCH] draw: Stop using a_tokenize Signed-off-by: Uli Schlachter --- draw.c | 24 ++++++++++++------------ draw.h | 2 +- objects/widgets/textbox.c | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/draw.c b/draw.c index 2b23d302..1d9535d0 100644 --- a/draw.c +++ b/draw.c @@ -32,7 +32,6 @@ #include "globalconf.h" #include "screen.h" -#include "common/tokenize.h" #include "common/xutil.h" /** Convert text from any charset to UTF-8 using iconv. @@ -366,21 +365,22 @@ draw_text_extents(draw_text_context_t *data) /** Transform a string to a alignment_t type. * Recognized string are flex, fixed, left, center, middle or right. * \param align A string with align text. - * \param len The string length. * \return An alignment_t type. */ alignment_t -draw_align_fromstr(const char *align, ssize_t len) +draw_align_fromstr(const char *align) { - switch(a_tokenize(align, len)) - { - case A_TK_CENTER: return AlignCenter; - case A_TK_RIGHT: return AlignRight; - case A_TK_TOP: return AlignTop; - case A_TK_BOTTOM: return AlignBottom; - case A_TK_MIDDLE: return AlignMiddle; - default: return AlignLeft; - } + if(a_strcmp(align, "center") == 0) + return AlignCenter; + if(a_strcmp(align, "right") == 0) + return AlignRight; + if(a_strcmp(align, "top") == 0) + return AlignTop; + if(a_strcmp(align, "bottom") == 0) + return AlignBottom; + if(a_strcmp(align, "middle") == 0) + return AlignMiddle; + return AlignLeft; } /** Transform an alignment to a string. diff --git a/draw.h b/draw.h index 1d776cbb..3295a75b 100644 --- a/draw.h +++ b/draw.h @@ -130,7 +130,7 @@ void draw_rectangle(draw_context_t *, area_t, float, bool, const color_t *); void draw_image(draw_context_t *, int, int, double, image_t *); void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int); area_t draw_text_extents(draw_text_context_t *); -alignment_t draw_align_fromstr(const char *, ssize_t); +alignment_t draw_align_fromstr(const char *); const char *draw_align_tostr(alignment_t); static inline void diff --git a/objects/widgets/textbox.c b/objects/widgets/textbox.c index 486d0899..af7ad66e 100644 --- a/objects/widgets/textbox.c +++ b/objects/widgets/textbox.c @@ -332,8 +332,8 @@ luaA_textbox_newindex(lua_State *L, const char *prop) if(a_strcmp(prop, "bg_align") == 0) { - buf = luaL_checklstring(L, 3, &len); - d->bg_align = draw_align_fromstr(buf, len); + buf = luaL_checkstring(L, 3); + d->bg_align = draw_align_fromstr(buf); } else if(a_strcmp(prop, "bg_resize") == 0) d->bg_resize = luaA_checkboolean(L, 3); @@ -352,13 +352,13 @@ luaA_textbox_newindex(lua_State *L, const char *prop) } else if(a_strcmp(prop, "align") == 0) { - if((buf = luaL_checklstring(L, 3, &len))) - d->align = draw_align_fromstr(buf, len); + if((buf = luaL_checkstring(L, 3))) + d->align = draw_align_fromstr(buf); } else if(a_strcmp(prop, "valign") == 0) { - if((buf = luaL_checklstring(L, 3, &len))) - d->valign = draw_align_fromstr(buf, len); + if((buf = luaL_checkstring(L, 3))) + d->valign = draw_align_fromstr(buf); } else if(a_strcmp(prop, "border_color") == 0) {