aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ldblib.c b/ldblib.c
index eb429acc..c2c9dafc 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.65 2002/08/05 17:36:24 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.66 2002/08/06 18:01:50 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,8 +126,8 @@ static void hookf (lua_State *L, lua_Debug *ar) {
126} 126}
127 127
128 128
129static int makemask (const char *smask, int count) { 129static unsigned long makemask (const char *smask, int count) {
130 int mask = 0; 130 unsigned long 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;
@@ -135,7 +135,7 @@ static int makemask (const char *smask, int count) {
135} 135}
136 136
137 137
138static char *unmakemask (int mask, char *smask) { 138static char *unmakemask (unsigned long mask, char *smask) {
139 int i = 0; 139 int i = 0;
140 if (mask & LUA_MASKCALL) smask[i++] = 'c'; 140 if (mask & LUA_MASKCALL) smask[i++] = 'c';
141 if (mask & LUA_MASKRET) smask[i++] = 'r'; 141 if (mask & LUA_MASKRET) smask[i++] = 'r';
@@ -152,8 +152,9 @@ static int sethook (lua_State *L) {
152 } 152 }
153 else { 153 else {
154 const char *smask = luaL_check_string(L, 2); 154 const char *smask = luaL_check_string(L, 2);
155 int count = luaL_opt_int(L, 3, 0); 155 lua_Number count = luaL_opt_number(L, 3, 0);
156 luaL_check_type(L, 1, LUA_TFUNCTION); 156 luaL_check_type(L, 1, LUA_TFUNCTION);
157 luaL_arg_check(L, count <= LUA_MAXCOUNT, 2, "count too large (>= 2^24)");
157 lua_sethook(L, hookf, makemask(smask, count)); 158 lua_sethook(L, hookf, makemask(smask, count));
158 } 159 }
159 lua_pushlightuserdata(L, (void *)&KEY_HOOK); 160 lua_pushlightuserdata(L, (void *)&KEY_HOOK);
@@ -165,7 +166,7 @@ static int sethook (lua_State *L) {
165 166
166static int gethook (lua_State *L) { 167static int gethook (lua_State *L) {
167 char buff[5]; 168 char buff[5];
168 int mask = lua_gethookmask(L); 169 unsigned long mask = lua_gethookmask(L);
169 lua_pushlightuserdata(L, (void *)&KEY_HOOK); 170 lua_pushlightuserdata(L, (void *)&KEY_HOOK);
170 lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ 171 lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */
171 lua_pushstring(L, unmakemask(mask, buff)); 172 lua_pushstring(L, unmakemask(mask, buff));