| 539 | } |
| 540 | |
| 541 | LUALIB_API const char *luaL_optlstring(lua_State *L, int idx, |
| 542 | const char *def, size_t *len) |
| 543 | { |
| 544 | TValue *o = index2adr(L, idx); |
| 545 | GCstr *s; |
| 546 | if (LJ_LIKELY(tvisstr(o))) { |
| 547 | s = strV(o); |
| 548 | } else if (tvisnil(o)) { |
| 549 | if (len != NULL) *len = def ? strlen(def) : 0; |
| 550 | return def; |
| 551 | } else if (tvisnumber(o)) { |
| 552 | lj_gc_check(L); |
| 553 | o = index2adr(L, idx); /* GC may move the stack. */ |
| 554 | s = lj_strfmt_number(L, o); |
| 555 | setstrV(L, o, s); |
| 556 | } else { |
| 557 | lj_err_argt(L, idx, LUA_TSTRING); |
| 558 | } |
| 559 | if (len != NULL) *len = s->len; |
| 560 | return strdata(s); |
| 561 | } |
| 562 | |
| 563 | LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def, |
| 564 | const char *const lst[]) |
nothing calls this directly
no test coverage detected