From f11c913bc45ef697928c7a4745c34a4a0e90b6e7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 10 Jun 2008 20:32:26 +0200 Subject: [PATCH] [lua] Fix gettop() usages Signed-off-by: Julien Danjou --- client.c | 2 +- lua.c | 3 ++- mouse.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index 27eebb73..800f2a76 100644 --- a/client.c +++ b/client.c @@ -1288,7 +1288,7 @@ luaA_client_titlebar_set(lua_State *L) client_t **c = luaA_checkudata(L, 1, "client"); titlebar_t **t = NULL; - if(lua_gettop(L) == 2) + if(lua_gettop(L) == 2 && !lua_isnil(L, 2)) { t = luaA_checkudata(L, 2, "titlebar"); if(client_getbytitlebar(*t)) diff --git a/lua.c b/lua.c index 73d828ac..207b167a 100644 --- a/lua.c +++ b/lua.c @@ -393,8 +393,9 @@ luaA_hooks_timer(lua_State *L) globalconf.timer.tv_usec = 0; globalconf.timer.tv_sec = luaL_checknumber(L, 1); - if(lua_gettop(L) == 2 && lua_isfunction(L, 2)) + if(lua_gettop(L) == 2 && !lua_isnil(L, 2)) { + luaA_checkfunction(L, 2); if(globalconf.hooks.timer) luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.timer); globalconf.hooks.timer = luaL_ref(L, LUA_REGISTRYINDEX); diff --git a/mouse.c b/mouse.c index b20361cc..a71e91c5 100644 --- a/mouse.c +++ b/mouse.c @@ -749,8 +749,8 @@ luaA_client_mouse_resize(lua_State *L) client_t **c = luaA_checkudata(L, 1, "client"); corner_t corner = AutoCorner; - if(lua_gettop(L) == 2 && lua_isstring(L, 2)) - corner = a_strtocorner(lua_tostring(L, 2)); + if(lua_gettop(L) == 2) + corner = a_strtocorner(luaL_checkstring(L, 2)); mouse_client_resize(*c, corner); return 0;