diff options
Diffstat (limited to 'ldblib.c')
-rw-r--r-- | ldblib.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.71 2002/11/14 15:41:38 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.72 2002/11/18 15:23:15 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 | */ |
@@ -126,16 +126,17 @@ static void hookf (lua_State *L, lua_Debug *ar) { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | static unsigned long makemask (const char *smask, int count) { | 129 | static int makemask (const char *smask, int count) { |
130 | unsigned long mask = 0; | 130 | int mask = 0; |
131 | if (strchr(smask, 'c')) mask |= LUA_MASKCALL; | 131 | if (strchr(smask, 'c')) mask |= LUA_MASKCALL; |
132 | if (strchr(smask, 'r')) mask |= LUA_MASKRET; | 132 | if (strchr(smask, 'r')) mask |= LUA_MASKRET; |
133 | if (strchr(smask, 'l')) mask |= LUA_MASKLINE; | 133 | if (strchr(smask, 'l')) mask |= LUA_MASKLINE; |
134 | return mask | LUA_MASKCOUNT(count); | 134 | if (count > 0) mask |= LUA_MASKCOUNT; |
135 | return mask; | ||
135 | } | 136 | } |
136 | 137 | ||
137 | 138 | ||
138 | static char *unmakemask (unsigned long mask, char *smask) { | 139 | static char *unmakemask (int mask, char *smask) { |
139 | int i = 0; | 140 | int i = 0; |
140 | if (mask & LUA_MASKCALL) smask[i++] = 'c'; | 141 | if (mask & LUA_MASKCALL) smask[i++] = 'c'; |
141 | if (mask & LUA_MASKRET) smask[i++] = 'r'; | 142 | if (mask & LUA_MASKRET) smask[i++] = 'r'; |
@@ -148,14 +149,13 @@ static char *unmakemask (unsigned long mask, char *smask) { | |||
148 | static int sethook (lua_State *L) { | 149 | static int sethook (lua_State *L) { |
149 | if (lua_isnoneornil(L, 1)) { | 150 | if (lua_isnoneornil(L, 1)) { |
150 | lua_settop(L, 1); | 151 | lua_settop(L, 1); |
151 | lua_sethook(L, NULL, 0); /* turn off hooks */ | 152 | lua_sethook(L, NULL, 0, 0); /* turn off hooks */ |
152 | } | 153 | } |
153 | else { | 154 | else { |
154 | const char *smask = luaL_checkstring(L, 2); | 155 | const char *smask = luaL_checkstring(L, 2); |
155 | lua_Number count = luaL_optnumber(L, 3, 0); | 156 | lua_Number count = luaL_optnumber(L, 3, 0); |
156 | luaL_checktype(L, 1, LUA_TFUNCTION); | 157 | luaL_checktype(L, 1, LUA_TFUNCTION); |
157 | luaL_argcheck(L, count <= LUA_MAXCOUNT, 2, "count too large (>= 2^24)"); | 158 | lua_sethook(L, hookf, makemask(smask, count), count); |
158 | lua_sethook(L, hookf, makemask(smask, (int)count)); | ||
159 | } | 159 | } |
160 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); | 160 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); |
161 | lua_pushvalue(L, 1); | 161 | lua_pushvalue(L, 1); |
@@ -166,7 +166,7 @@ static int sethook (lua_State *L) { | |||
166 | 166 | ||
167 | static int gethook (lua_State *L) { | 167 | static int gethook (lua_State *L) { |
168 | char buff[5]; | 168 | char buff[5]; |
169 | unsigned long mask = lua_gethookmask(L); | 169 | int mask = lua_gethookmask(L); |
170 | lua_Hook hook = lua_gethook(L); | 170 | lua_Hook hook = lua_gethook(L); |
171 | if (hook != NULL && hook != hookf) /* external hook? */ | 171 | if (hook != NULL && hook != hookf) /* external hook? */ |
172 | lua_pushliteral(L, "external hook"); | 172 | lua_pushliteral(L, "external hook"); |
@@ -175,7 +175,7 @@ static int gethook (lua_State *L) { | |||
175 | lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ | 175 | lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ |
176 | } | 176 | } |
177 | lua_pushstring(L, unmakemask(mask, buff)); | 177 | lua_pushstring(L, unmakemask(mask, buff)); |
178 | lua_pushnumber(L, lua_getmaskcount(mask)); | 178 | lua_pushnumber(L, lua_gethookcount(L)); |
179 | return 3; | 179 | return 3; |
180 | } | 180 | } |
181 | 181 | ||