Use luaL_traceback only with Lua 5.2+

It has been added in Lua 5.2, and should not require us to bump the
Lua dependency.  It is only meant to provide useful information, but is
not required.

This is a follow-up to 6e97b5f8.
This commit is contained in:
Daniel Hahler 2015-07-28 04:06:10 +02:00
parent bed8b26c60
commit 5e6f104e0e
1 changed files with 4 additions and 0 deletions

4
luaa.h
View File

@ -57,8 +57,10 @@ luaA_warn(lua_State *L, const char *fmt, ...)
va_end(ap);
fprintf(stderr, "\n");
#if LUA_VERSION_NUM >= 502
luaL_traceback(L, L, NULL, 2);
fprintf(stderr, "%s\n", lua_tostring(L, -1));
#endif
}
static inline int
@ -66,8 +68,10 @@ luaA_typerror(lua_State *L, int narg, const char *tname)
{
const char *msg = lua_pushfstring(L, "%s expected, got %s",
tname, luaL_typename(L, narg));
#if LUA_VERSION_NUM >= 502
luaL_traceback(L, L, NULL, 2);
lua_concat(L, 2);
#endif
return luaL_argerror(L, narg, msg);
}