commit 7a3c8314aca39e665078989a9846d79aac056db4
parent 6f8257ec5f728889c412f6d8da0c66614ccde708
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 18 Jan 2008 15:14:24 -0200
small bug (see http://lua-users.org/lists/lua-l/2007-08/msg00350.html)
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/ldblib.c b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.106 2007/04/26 20:39:38 roberto Exp roberto $
+** $Id: ldblib.c,v 1.107 2007/06/22 15:33:54 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -255,17 +255,18 @@ static void gethooktable (lua_State *L) {
static int db_sethook (lua_State *L) {
- int arg;
+ int arg, mask, count;
+ lua_Hook func;
lua_State *L1 = getthread(L, &arg);
if (lua_isnoneornil(L, arg+1)) {
lua_settop(L, arg+1);
- lua_sethook(L1, NULL, 0, 0); /* turn off hooks */
+ func = NULL; mask = 0; count = 0; /* turn off hooks */
}
else {
const char *smask = luaL_checkstring(L, arg+2);
- int count = luaL_optint(L, arg+3, 0);
luaL_checktype(L, arg+1, LUA_TFUNCTION);
- lua_sethook(L1, hookf, makemask(smask, count), count);
+ count = luaL_optint(L, arg+3, 0);
+ func = hookf; mask = makemask(smask, count);
}
gethooktable(L1);
lua_pushlightuserdata(L1, L1);
@@ -273,6 +274,7 @@ static int db_sethook (lua_State *L) {
lua_xmove(L, L1, 1);
lua_rawset(L1, -3); /* set new hook */
lua_pop(L1, 1); /* remove hook table */
+ lua_sethook(L1, func, mask, count);
return 0;
}