| 407 | |
| 408 | |
| 409 | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { |
| 410 | TValue *o; |
| 411 | lua_lock(L); |
| 412 | o = index2value(L, idx); |
| 413 | if (!ttisstring(o)) { |
| 414 | if (!cvt2str(o)) { /* not convertible? */ |
| 415 | if (len != NULL) *len = 0; |
| 416 | lua_unlock(L); |
| 417 | return NULL; |
| 418 | } |
| 419 | luaO_tostring(L, o); |
| 420 | luaC_checkGC(L); |
| 421 | o = index2value(L, idx); /* previous call may reallocate the stack */ |
| 422 | } |
| 423 | if (len != NULL) |
| 424 | *len = vslen(o); |
| 425 | lua_unlock(L); |
| 426 | return svalue(o); |
| 427 | } |
| 428 | |
| 429 | |
| 430 | LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { |
no test coverage detected