MCPcopy Create free account
hub / github.com/crownengine/crown / luaL_optlstring

Function luaL_optlstring

3rdparty/luajit/src/lj_api.c:541–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541LUALIB_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
563LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def,
564 const char *const lst[])

Callers

nothing calls this directly

Calls 3

strlenFunction · 0.85
lj_err_argtFunction · 0.85
index2adrFunction · 0.70

Tested by

no test coverage detected