From b19aace542d0f01608ad2766263805581cb6e005 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Tue, 24 Jun 2008 22:24:13 +0200 Subject: [PATCH] Fix draw_align_fromstr calls. Note that it's undefined to have side effects on an argument and pass this argument again to another function. Signed-off-by: Pierre Habouzit --- common/draw.c | 5 ++--- statusbar.c | 3 ++- titlebar.c | 3 ++- widget.c | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/common/draw.c b/common/draw.c index 5487aade9..b28fa81ec 100644 --- a/common/draw.c +++ b/common/draw.c @@ -210,7 +210,6 @@ static void draw_markup_on_element(markup_parser_data_t *p, const char *elem, const char **names, const char **values) { - size_t len; draw_parser_data_t *data = p->priv; /* hack: markup.c validates tags so we can avoid strcmps here */ @@ -236,10 +235,10 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, break; case 't': /* text */ for(; *names; names++, values++) - switch(a_tokenize(*names, (len = a_strlen(*names)))) + switch(a_tokenize(*names, -1)) { case A_TK_ALIGN: - data->align = draw_align_fromstr(*values, len); + data->align = draw_align_fromstr(*values, -1); break; case A_TK_SHADOW: xcolor_new(data->connection, data->phys_screen, *values, diff --git a/statusbar.c b/statusbar.c index 96e4cd5d5..6cead3ede 100644 --- a/statusbar.c +++ b/statusbar.c @@ -517,7 +517,8 @@ luaA_statusbar_new(lua_State *L) else sb->colors.bg = globalconf.colors.bg; - sb->align = draw_align_fromstr(luaA_getopt_string(L, 1, "align", "left", &len), len); + buf = luaA_getopt_string(L, 1, "align", "left", &len); + sb->align = draw_align_fromstr(buf, len); sb->width = luaA_getopt_number(L, 1, "width", 0); if(sb->width > 0) diff --git a/titlebar.c b/titlebar.c index a24bae007..cec1d84dc 100644 --- a/titlebar.c +++ b/titlebar.c @@ -304,7 +304,8 @@ luaA_titlebar_new(lua_State *L) tb = p_new(titlebar_t, 1); - tb->align = draw_align_fromstr(luaA_getopt_string(L, 1, "align", "left", &len), len); + buf = luaA_getopt_string(L, 1, "align", "left", &len); + tb->align = draw_align_fromstr(buf, len); tb->width = luaA_getopt_number(L, 1, "width", 0); tb->height = luaA_getopt_number(L, 1, "height", 0); diff --git a/widget.c b/widget.c index d5c25a90b..462180eee 100644 --- a/widget.c +++ b/widget.c @@ -306,14 +306,15 @@ widget_invalidate_bywidget(widget_t *widget) static int luaA_widget_new(lua_State *L) { - const char *type; + const char *type, *buf; widget_t *w = NULL; widget_constructor_t *wc; alignment_t align; size_t len; luaA_checktable(L, 1); - align = draw_align_fromstr(luaA_getopt_string(L, 1, "align", "left", &len), len); + buf = luaA_getopt_string(L, 1, "align", "left", &len); + align = draw_align_fromstr(buf, len); type = luaA_getopt_string(L, 1, "type", NULL, NULL);