| 765 | #if defined(LUA_COMPAT_MODULE) |
| 766 | |
| 767 | static const char *luaL_findtable (lua_State *L, int idx, |
| 768 | const char *fname, int szhint) { |
| 769 | const char *e; |
| 770 | if (idx) lua_pushvalue(L, idx); |
| 771 | do { |
| 772 | e = strchr(fname, '.'); |
| 773 | if (e == NULL) e = fname + strlen(fname); |
| 774 | lua_pushlstring(L, fname, e - fname); |
| 775 | lua_rawget(L, -2); |
| 776 | if (lua_isnil(L, -1)) { /* no such field? */ |
| 777 | lua_pop(L, 1); /* remove this nil */ |
| 778 | lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ |
| 779 | lua_pushlstring(L, fname, e - fname); |
| 780 | lua_pushvalue(L, -2); |
| 781 | lua_settable(L, -4); /* set new table into field */ |
| 782 | } |
| 783 | else if (!lua_istable(L, -1)) { /* field has a non-table value? */ |
| 784 | lua_pop(L, 2); /* remove table and value */ |
| 785 | return fname; /* return problematic part of the name */ |
| 786 | } |
| 787 | lua_remove(L, -2); /* remove previous table */ |
| 788 | fname = e + 1; |
| 789 | } while (*e == '.'); |
| 790 | return NULL; |
| 791 | } |
| 792 | |
| 793 | |
| 794 | /* |
no test coverage detected