textbox: allow nil as value for text

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-12 18:13:23 +02:00
parent 905d8e78a1
commit 57b7d39cdb
1 changed files with 6 additions and 4 deletions

View File

@ -137,17 +137,19 @@ 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);
if(buf)
a_iso2utf8(&d->text, buf, len);
d->len = len;
}