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