** The use of 'lua_pushfstring' ensures this function does not ** need reserved stack space when called. */
| 203 | ** need reserved stack space when called. |
| 204 | */ |
| 205 | LUALIB_API void luaL_where (lua_State *L, int level) { |
| 206 | lua_Debug ar; |
| 207 | if (lua_getstack(L, level, &ar)) { /* check function at level */ |
| 208 | lua_getinfo(L, "Sl", &ar); /* get info about it */ |
| 209 | if (ar.currentline > 0) { /* is there info? */ |
| 210 | lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); |
| 211 | return; |
| 212 | } |
| 213 | } |
| 214 | lua_pushfstring(L, ""); /* else, no information available... */ |
| 215 | } |
| 216 | |
| 217 | |
| 218 | /* |
no test coverage detected