From 57b7d39cdba2b8bac501ea7422b09b79d68bf020 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 12 Aug 2008 18:13:23 +0200 Subject: [PATCH] textbox: allow nil as value for text Signed-off-by: Julien Danjou --- widgets/textbox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/widgets/textbox.c b/widgets/textbox.c index 97328a0dc..858fc556e 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -137,18 +137,20 @@ luaA_textbox_index(lua_State *L, awesome_token_t token) static int luaA_textbox_newindex(lua_State *L, awesome_token_t token) { - size_t len; + size_t len = 0; widget_t **widget = luaA_checkudata(L, 1, "widget"); - const char *buf; + const char *buf = NULL; textbox_data_t *d = (*widget)->data; switch(token) { case A_TK_TEXT: - if((buf = luaL_checklstring(L, 3, &len))) + if(lua_isnil(L, 3) + || (buf = luaL_checklstring(L, 3, &len))) { p_delete(&d->text); - a_iso2utf8(&d->text, buf, len); + if(buf) + a_iso2utf8(&d->text, buf, len); d->len = len; } break;