MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaL_findtable

Function luaL_findtable

src/Chain/libraries/glua/lauxlib.cpp:2857–2880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2855#if defined(LUA_COMPAT_MODULE)
2856
2857static const char *luaL_findtable(lua_State *L, int idx,
2858 const char *fname, int szhint) {
2859 const char *e;
2860 if (idx) lua_pushvalue(L, idx);
2861 do {
2862 e = strchr(fname, '.');
2863 if (e == nullptr) e = fname + strlen(fname);
2864 lua_pushlstring(L, fname, e - fname);
2865 if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */
2866 lua_pop(L, 1); /* remove this nil */
2867 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
2868 lua_pushlstring(L, fname, e - fname);
2869 lua_pushvalue(L, -2);
2870 lua_settable(L, -4); /* set new table into field */
2871 }
2872 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
2873 lua_pop(L, 2); /* remove table and value */
2874 return fname; /* return problematic part of the name */
2875 }
2876 lua_remove(L, -2); /* remove previous table */
2877 fname = e + 1;
2878 } while (*e == '.');
2879 return nullptr;
2880}
2881
2882
2883/*

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