diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-01-18 15:14:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-01-18 15:14:47 -0200 |
commit | 7a3c8314aca39e665078989a9846d79aac056db4 (patch) | |
tree | 2cc564f5c3a229f32d988ef9777e3899398a4ce2 | |
parent | 6f8257ec5f728889c412f6d8da0c66614ccde708 (diff) | |
download | lua-7a3c8314aca39e665078989a9846d79aac056db4.tar.gz lua-7a3c8314aca39e665078989a9846d79aac056db4.tar.bz2 lua-7a3c8314aca39e665078989a9846d79aac056db4.zip |
small bug (see http://lua-users.org/lists/lua-l/2007-08/msg00350.html)
-rw-r--r-- | ldblib.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.106 2007/04/26 20:39:38 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.107 2007/06/22 15:33:54 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -255,17 +255,18 @@ static void gethooktable (lua_State *L) { | |||
255 | 255 | ||
256 | 256 | ||
257 | static int db_sethook (lua_State *L) { | 257 | static int db_sethook (lua_State *L) { |
258 | int arg; | 258 | int arg, mask, count; |
259 | lua_Hook func; | ||
259 | lua_State *L1 = getthread(L, &arg); | 260 | lua_State *L1 = getthread(L, &arg); |
260 | if (lua_isnoneornil(L, arg+1)) { | 261 | if (lua_isnoneornil(L, arg+1)) { |
261 | lua_settop(L, arg+1); | 262 | lua_settop(L, arg+1); |
262 | lua_sethook(L1, NULL, 0, 0); /* turn off hooks */ | 263 | func = NULL; mask = 0; count = 0; /* turn off hooks */ |
263 | } | 264 | } |
264 | else { | 265 | else { |
265 | const char *smask = luaL_checkstring(L, arg+2); | 266 | const char *smask = luaL_checkstring(L, arg+2); |
266 | int count = luaL_optint(L, arg+3, 0); | ||
267 | luaL_checktype(L, arg+1, LUA_TFUNCTION); | 267 | luaL_checktype(L, arg+1, LUA_TFUNCTION); |
268 | lua_sethook(L1, hookf, makemask(smask, count), count); | 268 | count = luaL_optint(L, arg+3, 0); |
269 | func = hookf; mask = makemask(smask, count); | ||
269 | } | 270 | } |
270 | gethooktable(L1); | 271 | gethooktable(L1); |
271 | lua_pushlightuserdata(L1, L1); | 272 | lua_pushlightuserdata(L1, L1); |
@@ -273,6 +274,7 @@ static int db_sethook (lua_State *L) { | |||
273 | lua_xmove(L, L1, 1); | 274 | lua_xmove(L, L1, 1); |
274 | lua_rawset(L1, -3); /* set new hook */ | 275 | lua_rawset(L1, -3); /* set new hook */ |
275 | lua_pop(L1, 1); /* remove hook table */ | 276 | lua_pop(L1, 1); /* remove hook table */ |
277 | lua_sethook(L1, func, mask, count); | ||
276 | return 0; | 278 | return 0; |
277 | } | 279 | } |
278 | 280 | ||