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