| 853 | #if defined(LUA_COMPAT_MODULE) |
| 854 | |
| 855 | static const char *luaL_findtable (lua_State *L, int idx, |
| 856 | const char *fname, int szhint) { |
| 857 | const char *e; |
| 858 | if (idx) lua_pushvalue(L, idx); |
| 859 | do { |
| 860 | e = strchr(fname, '.'); |
| 861 | if (e == NULL) e = fname + strlen(fname); |
| 862 | lua_pushlstring(L, fname, e - fname); |
| 863 | if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ |
| 864 | lua_pop(L, 1); /* remove this nil */ |
| 865 | lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ |
| 866 | lua_pushlstring(L, fname, e - fname); |
| 867 | lua_pushvalue(L, -2); |
| 868 | lua_settable(L, -4); /* set new table into field */ |
| 869 | } |
| 870 | else if (!lua_istable(L, -1)) { /* field has a non-table value? */ |
| 871 | lua_pop(L, 2); /* remove table and value */ |
| 872 | return fname; /* return problematic part of the name */ |
| 873 | } |
| 874 | lua_remove(L, -2); /* remove previous table */ |
| 875 | fname = e + 1; |
| 876 | } while (*e == '.'); |
| 877 | return NULL; |
| 878 | } |
| 879 | |
| 880 | |
| 881 | /* |
no test coverage detected