From 5f698f8b6f7e5fb18e0a7386dc506b0d5b538e6b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 25 Nov 2002 15:47:13 -0200 Subject: simpler interface to hooks + use of `int' to count hooks --- lua.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lua.c') diff --git a/lua.c b/lua.c index 13657e35..cc03d08f 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.108 2002/11/14 15:42:05 roberto Exp roberto $ +** $Id: lua.c,v 1.109 2002/11/19 13:49:43 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -57,9 +57,6 @@ static lua_State *L = NULL; static const char *progname; -static lua_Hook old_hook = NULL; -static unsigned long old_mask = 0; - static const luaL_reg lualibs[] = { {"baselib", lua_baselibopen}, @@ -77,7 +74,7 @@ static const luaL_reg lualibs[] = { static void lstop (lua_State *l, lua_Debug *ar) { (void)ar; /* unused arg. */ - lua_sethook(l, old_hook, old_mask); + lua_sethook(l, NULL, 0, 0); luaL_error(l, "interrupted!"); } @@ -85,9 +82,7 @@ static void lstop (lua_State *l, lua_Debug *ar) { static void laction (int i) { signal(i, SIG_DFL); /* if another SIGINT happens before lstop, terminate process (default action) */ - old_hook = lua_gethook(L); - old_mask = lua_gethookmask(L); - lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT(1)); + lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); } -- cgit v1.2.3-55-g6feb