diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-01-10 15:21:10 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-01-10 15:21:10 -0200 |
| commit | a27497aa03b080d8e7a2481aaf7af5d4784b40ec (patch) | |
| tree | e4d58d0b29d168342e14c728eb2b4832ef4a3d1f | |
| parent | 0480ea088629122334df0e8d5557cb27c9232aa9 (diff) | |
| download | lua-a27497aa03b080d8e7a2481aaf7af5d4784b40ec.tar.gz lua-a27497aa03b080d8e7a2481aaf7af5d4784b40ec.tar.bz2 lua-a27497aa03b080d8e7a2481aaf7af5d4784b40ec.zip | |
`debug.traceback' gets an optional `initial level' parameter
| -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 */ |
