MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaL_findtable

Function luaL_findtable

lua/lauxlib.c:405–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403
404
405LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
406 const char *fname, int szhint) {
407 const char *e;
408 lua_pushvalue(L, idx);
409 do {
410 e = strchr(fname, '.');
411 if (e == NULL) e = fname + strlen(fname);
412 lua_pushlstring(L, fname, e - fname);
413 lua_rawget(L, -2);
414 if (lua_isnil(L, -1)) { /* no such field? */
415 lua_pop(L, 1); /* remove this nil */
416 lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
417 lua_pushlstring(L, fname, e - fname);
418 lua_pushvalue(L, -2);
419 lua_settable(L, -4); /* set new table into field */
420 }
421 else if (!lua_istable(L, -1)) { /* field has a non-table value? */
422 lua_pop(L, 2); /* remove table and value */
423 return fname; /* return problematic part of the name */
424 }
425 lua_remove(L, -2); /* remove previous table */
426 fname = e + 1;
427 } while (*e == '.');
428 return NULL;
429}
430
431
432

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