diff options
Diffstat (limited to 'loadlib.c')
-rw-r--r-- | loadlib.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.49 2005/12/07 15:42:32 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.50 2005/12/19 20:56:39 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -550,7 +550,7 @@ static int ll_module (lua_State *L) { | |||
550 | if (!lua_istable(L, -1)) { /* not found? */ | 550 | if (!lua_istable(L, -1)) { /* not found? */ |
551 | lua_pop(L, 1); /* remove previous result */ | 551 | lua_pop(L, 1); /* remove previous result */ |
552 | /* try global variable (and create one if it does not exist) */ | 552 | /* try global variable (and create one if it does not exist) */ |
553 | if (luaL_findtable(L, LUA_GLOBALSINDEX, modname) != NULL) | 553 | if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) |
554 | return luaL_error(L, "name conflict for module " LUA_QS, modname); | 554 | return luaL_error(L, "name conflict for module " LUA_QS, modname); |
555 | lua_pushvalue(L, -1); | 555 | lua_pushvalue(L, -1); |
556 | lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ | 556 | lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ |
@@ -573,7 +573,7 @@ static int ll_module (lua_State *L) { | |||
573 | static int ll_seeall (lua_State *L) { | 573 | static int ll_seeall (lua_State *L) { |
574 | luaL_checktype(L, 1, LUA_TTABLE); | 574 | luaL_checktype(L, 1, LUA_TTABLE); |
575 | if (!lua_getmetatable(L, 1)) { | 575 | if (!lua_getmetatable(L, 1)) { |
576 | lua_newtable(L); /* create new metatable */ | 576 | lua_createtable(L, 0, 1); /* create new metatable */ |
577 | lua_pushvalue(L, -1); | 577 | lua_pushvalue(L, -1); |
578 | lua_setmetatable(L, 1); | 578 | lua_setmetatable(L, 1); |
579 | } | 579 | } |
@@ -640,7 +640,7 @@ LUALIB_API int luaopen_package (lua_State *L) { | |||
640 | lua_pushvalue(L, -1); | 640 | lua_pushvalue(L, -1); |
641 | lua_replace(L, LUA_ENVIRONINDEX); | 641 | lua_replace(L, LUA_ENVIRONINDEX); |
642 | /* create `loaders' table */ | 642 | /* create `loaders' table */ |
643 | lua_newtable(L); | 643 | lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); |
644 | /* fill it with pre-defined loaders */ | 644 | /* fill it with pre-defined loaders */ |
645 | for (i=0; loaders[i] != NULL; i++) { | 645 | for (i=0; loaders[i] != NULL; i++) { |
646 | lua_pushcfunction(L, loaders[i]); | 646 | lua_pushcfunction(L, loaders[i]); |
@@ -654,7 +654,7 @@ LUALIB_API int luaopen_package (lua_State *L) { | |||
654 | LUA_EXECDIR "\n" LUA_IGMARK); | 654 | LUA_EXECDIR "\n" LUA_IGMARK); |
655 | lua_setfield(L, -2, "config"); | 655 | lua_setfield(L, -2, "config"); |
656 | /* set field `loaded' */ | 656 | /* set field `loaded' */ |
657 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED"); | 657 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); |
658 | lua_setfield(L, -2, "loaded"); | 658 | lua_setfield(L, -2, "loaded"); |
659 | /* set field `preload' */ | 659 | /* set field `preload' */ |
660 | lua_newtable(L); | 660 | lua_newtable(L); |