| 3274 | #define COMPAT53_LEVELS2 10 /* size of the second part of the stack */ |
| 3275 | |
| 3276 | COMPAT53_API void luaL_traceback(lua_State* L, lua_State* L1, const char* msg, int level) { |
| 3277 | lua_Debug ar; |
| 3278 | int top = lua_gettop(L); |
| 3279 | int numlevels = compat53_countlevels(L1); |
| 3280 | int mark = (numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2) ? COMPAT53_LEVELS1 : 0; |
| 3281 | if (msg) |
| 3282 | lua_pushfstring(L, "%s\n", msg); |
| 3283 | lua_pushliteral(L, "stack traceback:"); |
| 3284 | while (lua_getstack(L1, level++, &ar)) { |
| 3285 | if (level == mark) { /* too many levels? */ |
| 3286 | lua_pushliteral(L, "\n\t..."); /* add a '...' */ |
| 3287 | level = numlevels - COMPAT53_LEVELS2; /* and skip to last ones */ |
| 3288 | } |
| 3289 | else { |
| 3290 | lua_getinfo(L1, "Slnt", &ar); |
| 3291 | lua_pushfstring(L, "\n\t%s:", ar.short_src); |
| 3292 | if (ar.currentline > 0) |
| 3293 | lua_pushfstring(L, "%d:", ar.currentline); |
| 3294 | lua_pushliteral(L, " in "); |
| 3295 | compat53_pushfuncname(L, &ar); |
| 3296 | lua_concat(L, lua_gettop(L) - top); |
| 3297 | } |
| 3298 | } |
| 3299 | lua_concat(L, lua_gettop(L) - top); |
| 3300 | } |
| 3301 | |
| 3302 | COMPAT53_API int luaL_fileresult(lua_State* L, int stat, const char* fname) { |
| 3303 | const char* serr = NULL; |
no test coverage detected