| 341 | |
| 342 | |
| 343 | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { |
| 344 | StkId o = index2adr(L, idx); |
| 345 | if (!ttisstring(o)) { |
| 346 | lua_lock(L); /* `luaV_tostring' may create a new string */ |
| 347 | if (!luaV_tostring(L, o)) { /* conversion failed? */ |
| 348 | if (len != NULL) *len = 0; |
| 349 | lua_unlock(L); |
| 350 | return NULL; |
| 351 | } |
| 352 | luaC_checkGC(L); |
| 353 | o = index2adr(L, idx); /* previous call may reallocate the stack */ |
| 354 | lua_unlock(L); |
| 355 | } |
| 356 | if (len != NULL) *len = tsvalue(o)->len; |
| 357 | return svalue(o); |
| 358 | } |
| 359 | |
| 360 | |
| 361 | LUA_API size_t lua_objlen (lua_State *L, int idx) { |
no test coverage detected