MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_findtable

Function luaL_findtable

third-party/lua-5.2.4/src/lauxlib.c:767–791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765#if defined(LUA_COMPAT_MODULE)
766
767static const char *luaL_findtable (lua_State *L, int idx,
768 const char *fname, int szhint) {
769 const char *e;
770 if (idx) lua_pushvalue(L, idx);
771 do {
772 e = strchr(fname, '.');
773 if (e == NULL) e = fname + strlen(fname);
774 lua_pushlstring(L, fname, e - fname);
775 lua_rawget(L, -2);
776 if (lua_isnil(L, -1)) { /* no such field? */
777 lua_pop(L, 1); /* remove this nil */
778 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
779 lua_pushlstring(L, fname, e - fname);
780 lua_pushvalue(L, -2);
781 lua_settable(L, -4); /* set new table into field */
782 }
783 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
784 lua_pop(L, 2); /* remove table and value */
785 return fname; /* return problematic part of the name */
786 }
787 lua_remove(L, -2); /* remove previous table */
788 fname = e + 1;
789 } while (*e == '.');
790 return NULL;
791}
792
793
794/*

Callers 1

luaL_pushmoduleFunction · 0.70

Calls 6

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