| 2190 | |
| 2191 | |
| 2192 | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { |
| 2193 | StkId o = index2adr(L, idx); |
| 2194 | if (!ttisstring(o)) { |
| 2195 | lua_lock(L); /* `luaV_tostring' may create a new string */ |
| 2196 | if (!luaV_tostring(L, o)) { /* conversion failed? */ |
| 2197 | if (len != NULL) *len = 0; |
| 2198 | lua_unlock(L); |
| 2199 | return NULL; |
| 2200 | } |
| 2201 | luaC_checkGC(L); |
| 2202 | o = index2adr(L, idx); /* previous call may reallocate the stack */ |
| 2203 | lua_unlock(L); |
| 2204 | } |
| 2205 | if (len != NULL) *len = tsvalue(o)->len; |
| 2206 | return svalue(o); |
| 2207 | } |
| 2208 | |
| 2209 | |
| 2210 | LUA_API size_t lua_objlen (lua_State *L, int idx) { |
no test coverage detected