MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaL_findtable

Function luaL_findtable

Source/Misc/lua/src/lua.c:10569–10593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10567
10568
10569LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
10570const char *fname, int szhint) {
10571const char *e;
10572lua_pushvalue(L, idx);
10573do {
10574e = strchr(fname, '.');
10575if (e == NULL) e = fname + strlen(fname);
10576lua_pushlstring(L, fname, e - fname);
10577lua_rawget(L, -2);
10578if (lua_isnil(L, -1)) { /* no such field? */
10579lua_pop(L, 1); /* remove this nil */
10580lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
10581lua_pushlstring(L, fname, e - fname);
10582lua_pushvalue(L, -2);
10583lua_settable(L, -4); /* set new table into field */
10584}
10585else if (!lua_istable(L, -1)) { /* field has a non-table value? */
10586lua_pop(L, 2); /* remove table and value */
10587return fname; /* return problematic part of the name */
10588}
10589lua_remove(L, -2); /* remove previous table */
10590fname = e + 1;
10591} while (*e == '.');
10592return NULL;
10593}
10594
10595
10596

Callers 3

luaI_openlibFunction · 0.85
ll_moduleFunction · 0.85
luaopen_packageFunction · 0.85

Calls 6

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

Tested by

no test coverage detected