** The use of 'lua_pushfstring' ensures this function does not ** need reserved stack space when called. */
| 214 | ** need reserved stack space when called. |
| 215 | */ |
| 216 | LUALIB_API void luaL_where (lua_State *L, int level) { |
| 217 | lua_Debug ar; |
| 218 | if (lua_getstack(L, level, &ar)) { /* check function at level */ |
| 219 | lua_getinfo(L, "Sl", &ar); /* get info about it */ |
| 220 | if (ar.currentline > 0) { /* is there info? */ |
| 221 | lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); |
| 222 | return; |
| 223 | } |
| 224 | } |
| 225 | lua_pushfstring(L, ""); /* else, no information available... */ |
| 226 | } |
| 227 | |
| 228 | |
| 229 | /* |
no test coverage detected