| 502 | } |
| 503 | |
| 504 | LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) |
| 505 | { |
| 506 | TValue *o = index2adr(L, idx); |
| 507 | GCstr *s; |
| 508 | if (LJ_LIKELY(tvisstr(o))) { |
| 509 | s = strV(o); |
| 510 | } else if (tvisnumber(o)) { |
| 511 | lj_gc_check(L); |
| 512 | o = index2adr(L, idx); /* GC may move the stack. */ |
| 513 | s = lj_strfmt_number(L, o); |
| 514 | setstrV(L, o, s); |
| 515 | } else { |
| 516 | if (len != NULL) *len = 0; |
| 517 | return NULL; |
| 518 | } |
| 519 | if (len != NULL) *len = s->len; |
| 520 | return strdata(s); |
| 521 | } |
| 522 | |
| 523 | LUALIB_API const char *luaL_checklstring(lua_State *L, int idx, size_t *len) |
| 524 | { |
no test coverage detected