| 2757 | #define COMPAT53_LEVELS2 10 /* size of the second part of the stack */ |
| 2758 | |
| 2759 | COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, |
| 2760 | const char *msg, int level) { |
| 2761 | lua_Debug ar; |
| 2762 | int top = lua_gettop(L); |
| 2763 | int numlevels = compat53_countlevels(L1); |
| 2764 | int mark = (numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2) ? COMPAT53_LEVELS1 : 0; |
| 2765 | if (msg) lua_pushfstring(L, "%s\n", msg); |
| 2766 | lua_pushliteral(L, "stack traceback:"); |
| 2767 | while (lua_getstack(L1, level++, &ar)) { |
| 2768 | if (level == mark) { /* too many levels? */ |
| 2769 | lua_pushliteral(L, "\n\t..."); /* add a '...' */ |
| 2770 | level = numlevels - COMPAT53_LEVELS2; /* and skip to last ones */ |
| 2771 | } |
| 2772 | else { |
| 2773 | lua_getinfo(L1, "Slnt", &ar); |
| 2774 | lua_pushfstring(L, "\n\t%s:", ar.short_src); |
| 2775 | if (ar.currentline > 0) |
| 2776 | lua_pushfstring(L, "%d:", ar.currentline); |
| 2777 | lua_pushliteral(L, " in "); |
| 2778 | compat53_pushfuncname(L, &ar); |
| 2779 | lua_concat(L, lua_gettop(L) - top); |
| 2780 | } |
| 2781 | } |
| 2782 | lua_concat(L, lua_gettop(L) - top); |
| 2783 | } |
| 2784 | |
| 2785 | COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname) { |
| 2786 | const char *serr = NULL; |
no test coverage detected