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