| 782 | #if defined(LUA_COMPAT_MODULE) |
| 783 | |
| 784 | static const char *luaL_findtable (lua_State *L, int idx, |
| 785 | const char *fname, int szhint) { |
| 786 | const char *e; |
| 787 | if (idx) lua_pushvalue(L, idx); |
| 788 | do { |
| 789 | e = strchr(fname, '.'); |
| 790 | if (e == NULL) e = fname + strlen(fname); |
| 791 | lua_pushlstring(L, fname, e - fname); |
| 792 | if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ |
| 793 | lua_pop(L, 1); /* remove this nil */ |
| 794 | lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ |
| 795 | lua_pushlstring(L, fname, e - fname); |
| 796 | lua_pushvalue(L, -2); |
| 797 | lua_settable(L, -4); /* set new table into field */ |
| 798 | } |
| 799 | else if (!lua_istable(L, -1)) { /* field has a non-table value? */ |
| 800 | lua_pop(L, 2); /* remove table and value */ |
| 801 | return fname; /* return problematic part of the name */ |
| 802 | } |
| 803 | lua_remove(L, -2); /* remove previous table */ |
| 804 | fname = e + 1; |
| 805 | } while (*e == '.'); |
| 806 | return NULL; |
| 807 | } |
| 808 | |
| 809 | |
| 810 | /* |
no test coverage detected