| 387 | |
| 388 | |
| 389 | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { |
| 390 | StkId o = index2addr(L, idx); |
| 391 | if (!ttisstring(o)) { |
| 392 | lua_lock(L); /* `luaV_tostring' may create a new string */ |
| 393 | if (!luaV_tostring(L, o)) { /* conversion failed? */ |
| 394 | if (len != NULL) *len = 0; |
| 395 | lua_unlock(L); |
| 396 | return NULL; |
| 397 | } |
| 398 | luaC_checkGC(L); |
| 399 | o = index2addr(L, idx); /* previous call may reallocate the stack */ |
| 400 | lua_unlock(L); |
| 401 | } |
| 402 | if (len != NULL) *len = tsvalue(o)->len; |
| 403 | return svalue(o); |
| 404 | } |
| 405 | |
| 406 | |
| 407 | LUA_API size_t lua_rawlen (lua_State *L, int idx) { |
no test coverage detected