MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaL_findtable

Function luaL_findtable

freebsd/contrib/openzfs/module/lua/lauxlib.c:623–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621#if defined(LUA_COMPAT_MODULE)
622
623static const char *luaL_findtable (lua_State *L, int idx,
624 const char *fname, int szhint) {
625 const char *e;
626 if (idx) lua_pushvalue(L, idx);
627 do {
628 e = strchr(fname, '.');
629 if (e == NULL) e = fname + strlen(fname);
630 lua_pushlstring(L, fname, e - fname);
631 lua_rawget(L, -2);
632 if (lua_isnil(L, -1)) { /* no such field? */
633 lua_pop(L, 1); /* remove this nil */
634 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
635 lua_pushlstring(L, fname, e - fname);
636 lua_pushvalue(L, -2);
637 lua_settable(L, -4); /* set new table into field */
638 }
639 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
640 lua_pop(L, 2); /* remove table and value */
641 return fname; /* return problematic part of the name */
642 }
643 lua_remove(L, -2); /* remove previous table */
644 fname = e + 1;
645 } while (*e == '.');
646 return NULL;
647}
648
649
650/*

Callers 1

luaL_pushmoduleFunction · 0.70

Calls 7

strchrFunction · 0.85
lua_pushvalueFunction · 0.70
lua_pushlstringFunction · 0.70
lua_rawgetFunction · 0.70
lua_createtableFunction · 0.70
lua_settableFunction · 0.70
lua_removeFunction · 0.70

Tested by

no test coverage detected