diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.228 2011/01/10 15:51:42 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.229 2011/03/03 16:34:46 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -758,8 +758,8 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { | |||
758 | */ | 758 | */ |
759 | #if defined(LUA_COMPAT_MODULE) | 759 | #if defined(LUA_COMPAT_MODULE) |
760 | 760 | ||
761 | static const char *luaL_findtablex (lua_State *L, int idx, | 761 | static const char *luaL_findtable (lua_State *L, int idx, |
762 | const char *fname, int szhint) { | 762 | const char *fname, int szhint) { |
763 | const char *e; | 763 | const char *e; |
764 | if (idx) lua_pushvalue(L, idx); | 764 | if (idx) lua_pushvalue(L, idx); |
765 | do { | 765 | do { |
@@ -803,13 +803,13 @@ static int libsize (const luaL_Reg *l) { | |||
803 | */ | 803 | */ |
804 | LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, | 804 | LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, |
805 | int sizehint) { | 805 | int sizehint) { |
806 | luaL_findtablex(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */ | 806 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */ |
807 | lua_getfield(L, -1, modname); /* get _LOADED[modname] */ | 807 | lua_getfield(L, -1, modname); /* get _LOADED[modname] */ |
808 | if (!lua_istable(L, -1)) { /* not found? */ | 808 | if (!lua_istable(L, -1)) { /* not found? */ |
809 | lua_pop(L, 1); /* remove previous result */ | 809 | lua_pop(L, 1); /* remove previous result */ |
810 | /* try global variable (and create one if it does not exist) */ | 810 | /* try global variable (and create one if it does not exist) */ |
811 | lua_pushglobaltable(L); | 811 | lua_pushglobaltable(L); |
812 | if (luaL_findtablex(L, 0, modname, sizehint) != NULL) | 812 | if (luaL_findtable(L, 0, modname, sizehint) != NULL) |
813 | luaL_error(L, "name conflict for module " LUA_QS, modname); | 813 | luaL_error(L, "name conflict for module " LUA_QS, modname); |
814 | lua_pushvalue(L, -1); | 814 | lua_pushvalue(L, -1); |
815 | lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ | 815 | lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ |
@@ -853,7 +853,7 @@ LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { | |||
853 | ** ensure that stack[idx][fname] has a table and push that table | 853 | ** ensure that stack[idx][fname] has a table and push that table |
854 | ** into the stack | 854 | ** into the stack |
855 | */ | 855 | */ |
856 | LUALIB_API int luaL_findtable (lua_State *L, int idx, const char *fname) { | 856 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
857 | lua_getfield(L, idx, fname); | 857 | lua_getfield(L, idx, fname); |
858 | if (lua_istable(L, -1)) return 1; /* table already there */ | 858 | if (lua_istable(L, -1)) return 1; /* table already there */ |
859 | else { | 859 | else { |
@@ -878,7 +878,7 @@ LUALIB_API void luaL_requiref (lua_State *L, const char *modname, | |||
878 | lua_pushcfunction(L, openf); | 878 | lua_pushcfunction(L, openf); |
879 | lua_pushstring(L, modname); /* argument to open function */ | 879 | lua_pushstring(L, modname); /* argument to open function */ |
880 | lua_call(L, 1, 1); /* open module */ | 880 | lua_call(L, 1, 1); /* open module */ |
881 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED"); | 881 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); |
882 | lua_pushvalue(L, -2); /* make copy of module (call result) */ | 882 | lua_pushvalue(L, -2); /* make copy of module (call result) */ |
883 | lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ | 883 | lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ |
884 | lua_pop(L, 1); /* remove _LOADED table */ | 884 | lua_pop(L, 1); /* remove _LOADED table */ |