commit a27497aa03b080d8e7a2481aaf7af5d4784b40ec
parent 0480ea088629122334df0e8d5557cb27c9232aa9
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 10 Jan 2005 15:20:48 -0200
`debug.traceback' gets an optional `initial level' parameter
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ldblib.c b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.89 2004/11/17 12:02:41 roberto Exp roberto $
+** $Id: ldblib.c,v 1.90 2005/01/10 16:30:59 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -275,12 +275,17 @@ static int debug (lua_State *L) {
#define LEVELS2 10 /* size of the second part of the stack */
static int errorfb (lua_State *L) {
- int level = 0;
+ int level;
int firstpart = 1; /* still before eventual `...' */
int arg;
lua_State *L1 = getthread(L, &arg);
lua_Debug ar;
- if (L == L1) level++; /* skip level 0 (it's this function) */
+ if (lua_isnumber(L, arg+2)) {
+ level = lua_tonumber(L, arg+2);
+ lua_pop(L, 1);
+ }
+ else
+ level = (L == L1) ? 1 : 0; /* level 0 may be this own function */
if (lua_gettop(L) == arg)
lua_pushliteral(L, "");
else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */