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