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

Function luaL_findtable

other_src/lua/src/lauxlib.cpp:382–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380
381
382LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
383 const char *fname, int szhint) {
384 const char *e;
385 lua_pushvalue(L, idx);
386 do {
387 e = strchr(fname, '.');
388 if (e == NULL) e = fname + strlen(fname);
389 lua_pushlstring(L, fname, e - fname);
390 lua_rawget(L, -2);
391 if (lua_isnil(L, -1)) { /* no such field? */
392 lua_pop(L, 1); /* remove this nil */
393 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
394 lua_pushlstring(L, fname, e - fname);
395 lua_pushvalue(L, -2);
396 lua_settable(L, -4); /* set new table into field */
397 }
398 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
399 lua_pop(L, 2); /* remove table and value */
400 return fname; /* return problematic part of the name */
401 }
402 lua_remove(L, -2); /* remove previous table */
403 fname = e + 1;
404 } while (*e == '.');
405 return NULL;
406}
407
408
409

Callers 3

ll_moduleFunction · 0.70
luaopen_packageFunction · 0.70
luaI_openlibFunction · 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