| 93 | |
| 94 | |
| 95 | LUALIB_API void luaL_where (lua_State *L, int level) { |
| 96 | lua_Debug ar; |
| 97 | if (lua_getstack(L, level, &ar)) { /* check function at level */ |
| 98 | lua_getinfo(L, "Sl", &ar); /* get info about it */ |
| 99 | if (ar.currentline > 0) { /* is there info? */ |
| 100 | const char *src; |
| 101 | ptrdiff_t srclen; |
| 102 | if (get_src_at_line(ar.source, ar.currentline, &src, &srclen) == 0) { |
| 103 | if (srclen > 31) srclen = 31; |
| 104 | char line[srclen + 1]; |
| 105 | memcpy(line, src, srclen); |
| 106 | line[srclen] = 0; |
| 107 | lua_pushfstring(L, "[%s...]:%d: ", line, ar.currentline); |
| 108 | } |
| 109 | else |
| 110 | lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); |
| 111 | return; |
| 112 | } |
| 113 | } |
| 114 | lua_pushliteral(L, ""); /* else, no information available... */ |
| 115 | } |
| 116 | |
| 117 | |
| 118 | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { |
no test coverage detected