| 374 | |
| 375 | |
| 376 | LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) { |
| 377 | StkId o = index2addr(L, idx); |
| 378 | if (!ttisstring(o)) { |
| 379 | if (!cvt2str(o)) { /* not convertible? */ |
| 380 | if (len != nullptr) *len = 0; |
| 381 | return nullptr; |
| 382 | } |
| 383 | lua_lock(L); /* 'luaO_tostring' may create a new string */ |
| 384 | luaC_checkGC(L); |
| 385 | o = index2addr(L, idx); /* previous call may reallocate the stack */ |
| 386 | luaO_tostring(L, o); |
| 387 | lua_unlock(L); |
| 388 | } |
| 389 | if (len != nullptr) |
| 390 | *len = vslen(o); |
| 391 | return svalue(o); |
| 392 | } |
| 393 | |
| 394 | |
| 395 | LUA_API size_t lua_rawlen(lua_State *L, int idx) { |
no test coverage detected