MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaL_findtable

Function luaL_findtable

depends/lua/src/lauxlib.c:855–878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853#if defined(LUA_COMPAT_MODULE)
854
855static const char *luaL_findtable (lua_State *L, int idx,
856 const char *fname, int szhint) {
857 const char *e;
858 if (idx) lua_pushvalue(L, idx);
859 do {
860 e = strchr(fname, '.');
861 if (e == NULL) e = fname + strlen(fname);
862 lua_pushlstring(L, fname, e - fname);
863 if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */
864 lua_pop(L, 1); /* remove this nil */
865 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
866 lua_pushlstring(L, fname, e - fname);
867 lua_pushvalue(L, -2);
868 lua_settable(L, -4); /* set new table into field */
869 }
870 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
871 lua_pop(L, 2); /* remove table and value */
872 return fname; /* return problematic part of the name */
873 }
874 lua_remove(L, -2); /* remove previous table */
875 fname = e + 1;
876 } while (*e == '.');
877 return NULL;
878}
879
880
881/*

Callers 1

luaL_pushmoduleFunction · 0.85

Calls 5

lua_pushvalueFunction · 0.85
lua_pushlstringFunction · 0.85
lua_rawgetFunction · 0.85
lua_createtableFunction · 0.85
lua_settableFunction · 0.85

Tested by

no test coverage detected