| 413 | |
| 414 | |
| 415 | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { |
| 416 | TValue *o; |
| 417 | lua_lock(L); |
| 418 | o = index2value(L, idx); |
| 419 | if (!ttisstring(o)) { |
| 420 | if (!cvt2str(o)) { /* not convertible? */ |
| 421 | if (len != NULL) *len = 0; |
| 422 | lua_unlock(L); |
| 423 | return NULL; |
| 424 | } |
| 425 | luaO_tostring(L, o); |
| 426 | luaC_checkGC(L); |
| 427 | o = index2value(L, idx); /* previous call may reallocate the stack */ |
| 428 | } |
| 429 | lua_unlock(L); |
| 430 | if (len != NULL) |
| 431 | return getlstr(tsvalue(o), *len); |
| 432 | else |
| 433 | return getstr(tsvalue(o)); |
| 434 | } |
| 435 | |
| 436 | |
| 437 | LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { |
no test coverage detected