diff options
-rw-r--r-- | ldblib.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.89 2004/11/17 12:02:41 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.90 2005/01/10 16:30:59 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 | */ |
@@ -275,12 +275,17 @@ static int debug (lua_State *L) { | |||
275 | #define LEVELS2 10 /* size of the second part of the stack */ | 275 | #define LEVELS2 10 /* size of the second part of the stack */ |
276 | 276 | ||
277 | static int errorfb (lua_State *L) { | 277 | static int errorfb (lua_State *L) { |
278 | int level = 0; | 278 | int level; |
279 | int firstpart = 1; /* still before eventual `...' */ | 279 | int firstpart = 1; /* still before eventual `...' */ |
280 | int arg; | 280 | int arg; |
281 | lua_State *L1 = getthread(L, &arg); | 281 | lua_State *L1 = getthread(L, &arg); |
282 | lua_Debug ar; | 282 | lua_Debug ar; |
283 | if (L == L1) level++; /* skip level 0 (it's this function) */ | 283 | if (lua_isnumber(L, arg+2)) { |
284 | level = lua_tonumber(L, arg+2); | ||
285 | lua_pop(L, 1); | ||
286 | } | ||
287 | else | ||
288 | level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ | ||
284 | if (lua_gettop(L) == arg) | 289 | if (lua_gettop(L) == arg) |
285 | lua_pushliteral(L, ""); | 290 | lua_pushliteral(L, ""); |
286 | else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ | 291 | else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ |