Print stack traceback support for Lua 5.1

Lua 5.1 lacks the C API luaL_traceback() function, so Lua
debug.traceback() has to be used instead.
This commit is contained in:
Lefteris Chatzimparmpas 2012-12-05 21:25:21 +01:00
parent d7966dbe2d
commit 568e414754
1 changed files with 8 additions and 0 deletions

View File

@ -98,7 +98,15 @@ static int
traceback_handler(lua_State *lua)
{
#if LUA_VERSION_NUM < 502
lua_getfield(lua, LUA_GLOBALSINDEX, "debug");
lua_getfield(lua, -1, "traceback");
lua_pushvalue(lua, 1);
lua_pushinteger(lua, 2);
lua_call(lua, 2, 1);
#else
luaL_traceback(lua, lua, lua_tostring(lua, 1), 0);
#endif
return 1;
}