diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-18 12:17:58 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-18 12:17:58 -0300 |
commit | 8f080fd683d63b0cd4b38380f6a5bdae5d6e2584 (patch) | |
tree | 5d953ace0d6139381e2b0a01b329f1aecc15b435 | |
parent | d8678edddc98beab8eb78e63e698191a9ffd39b8 (diff) | |
download | lua-8f080fd683d63b0cd4b38380f6a5bdae5d6e2584.tar.gz lua-8f080fd683d63b0cd4b38380f6a5bdae5d6e2584.tar.bz2 lua-8f080fd683d63b0cd4b38380f6a5bdae5d6e2584.zip |
`traceback' returns only the traceback
-rw-r--r-- | ldblib.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.56 2002/06/06 12:40:36 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.57 2002/06/13 13:44: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 | */ |
@@ -185,10 +185,7 @@ static int errorfb (lua_State *L) { | |||
185 | int level = 1; /* skip level 0 (it's this function) */ | 185 | int level = 1; /* skip level 0 (it's this function) */ |
186 | int firstpart = 1; /* still before eventual `...' */ | 186 | int firstpart = 1; /* still before eventual `...' */ |
187 | lua_Debug ar; | 187 | lua_Debug ar; |
188 | if (!lua_isstring(L, 1)) | 188 | lua_settop(L, 0); |
189 | return lua_gettop(L); | ||
190 | lua_settop(L, 1); | ||
191 | lua_pushliteral(L, "\n"); | ||
192 | lua_pushliteral(L, "stack traceback:\n"); | 189 | lua_pushliteral(L, "stack traceback:\n"); |
193 | while (lua_getstack(L, level++, &ar)) { | 190 | while (lua_getstack(L, level++, &ar)) { |
194 | char buff[10]; | 191 | char buff[10]; |
@@ -242,13 +239,16 @@ static const luaL_reg dblib[] = { | |||
242 | {"setlinehook", setlinehook}, | 239 | {"setlinehook", setlinehook}, |
243 | {"setlocal", setlocal}, | 240 | {"setlocal", setlocal}, |
244 | {"debug", debug}, | 241 | {"debug", debug}, |
242 | {"traceback", errorfb}, | ||
245 | {NULL, NULL} | 243 | {NULL, NULL} |
246 | }; | 244 | }; |
247 | 245 | ||
248 | 246 | ||
249 | LUALIB_API int lua_dblibopen (lua_State *L) { | 247 | LUALIB_API int lua_dblibopen (lua_State *L) { |
250 | luaL_opennamedlib(L, LUA_DBLIBNAME, dblib, 0); | 248 | luaL_opennamedlib(L, LUA_DBLIBNAME, dblib, 0); |
251 | lua_register(L, "_ERRORMESSAGE", errorfb); | 249 | lua_pushliteral(L, LUA_TRACEBACK); |
250 | lua_pushcfunction(L, errorfb); | ||
251 | lua_settable(L, LUA_REGISTRYINDEX); | ||
252 | return 0; | 252 | return 0; |
253 | } | 253 | } |
254 | 254 | ||