From a27497aa03b080d8e7a2481aaf7af5d4784b40ec Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 Jan 2005 15:21:10 -0200 Subject: `debug.traceback' gets an optional `initial level' parameter --- ldblib.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ldblib.c') diff --git a/ldblib.c b/ldblib.c index 244b24d0..f56bcae0 100644 --- 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 */ -- cgit v1.2.3-55-g6feb