summaryrefslogtreecommitdiff
path: root/src/ldblib.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2008-01-18 12:00:00 +0000
committerrepogen <>2008-01-18 12:00:00 +0000
commit5065c5cce2d4c35d65319fede6b8eddc410fb846 (patch)
tree127eee020245a47128184a35cb78059a26d1770f /src/ldblib.c
parentb2874e1bcdc4d4a56d8a232a88d5e17c6a9826f5 (diff)
downloadlua-github-5.1.3-rc2.tar.gz
Lua 5.1.3-rc25.1.3-rc2
Diffstat (limited to 'src/ldblib.c')
-rw-r--r--src/ldblib.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ldblib.c b/src/ldblib.c
index bb47cc72..8d631e37 100644
--- a/src/ldblib.c
+++ b/src/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.104.1.1 2007/12/27 13:02:25 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.2 2008/01/18 16:39:45 roberto Exp $
** 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); /* set hooks */
return 0;
}