| 621 | #if defined(LUA_COMPAT_MODULE) |
| 622 | |
| 623 | static const char *luaL_findtable (lua_State *L, int idx, |
| 624 | const char *fname, int szhint) { |
| 625 | const char *e; |
| 626 | if (idx) lua_pushvalue(L, idx); |
| 627 | do { |
| 628 | e = strchr(fname, '.'); |
| 629 | if (e == NULL) e = fname + strlen(fname); |
| 630 | lua_pushlstring(L, fname, e - fname); |
| 631 | lua_rawget(L, -2); |
| 632 | if (lua_isnil(L, -1)) { /* no such field? */ |
| 633 | lua_pop(L, 1); /* remove this nil */ |
| 634 | lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ |
| 635 | lua_pushlstring(L, fname, e - fname); |
| 636 | lua_pushvalue(L, -2); |
| 637 | lua_settable(L, -4); /* set new table into field */ |
| 638 | } |
| 639 | else if (!lua_istable(L, -1)) { /* field has a non-table value? */ |
| 640 | lua_pop(L, 2); /* remove table and value */ |
| 641 | return fname; /* return problematic part of the name */ |
| 642 | } |
| 643 | lua_remove(L, -2); /* remove previous table */ |
| 644 | fname = e + 1; |
| 645 | } while (*e == '.'); |
| 646 | return NULL; |
| 647 | } |
| 648 | |
| 649 | |
| 650 | /* |
no test coverage detected