diff options
Diffstat (limited to 'linit.c')
-rw-r--r-- | linit.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: linit.c,v 1.22 2009/12/17 12:26:09 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.23 2009/12/22 15:32:50 roberto Exp roberto $ |
3 | ** Initialization of libraries for lua.c and other clients | 3 | ** Initialization of libraries for lua.c and other clients |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -52,9 +52,9 @@ LUALIB_API void luaL_openlibs (lua_State *L) { | |||
52 | const luaL_Reg *lib; | 52 | const luaL_Reg *lib; |
53 | /* call open functions from 'loadedlibs' */ | 53 | /* call open functions from 'loadedlibs' */ |
54 | for (lib = loadedlibs; lib->func; lib++) { | 54 | for (lib = loadedlibs; lib->func; lib++) { |
55 | lua_pushcfunction(L, lib->func); | 55 | lua_settop(L, 0); |
56 | lua_pushstring(L, lib->name); | 56 | lua_pushstring(L, lib->name); |
57 | lua_call(L, 1, 0); | 57 | (lib->func)(L); |
58 | } | 58 | } |
59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ | 59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ |
60 | lua_pushglobaltable(L); | 60 | lua_pushglobaltable(L); |
@@ -65,8 +65,7 @@ LUALIB_API void luaL_openlibs (lua_State *L) { | |||
65 | } | 65 | } |
66 | lua_pop(L, 1); /* remove package.preload table */ | 66 | lua_pop(L, 1); /* remove package.preload table */ |
67 | #if defined(LUA_COMPAT_DEBUGLIB) | 67 | #if defined(LUA_COMPAT_DEBUGLIB) |
68 | lua_pushglobaltable(L); | 68 | lua_getglobal(L, "require"); |
69 | lua_getfield(L, -1, "require"); | ||
70 | lua_pushliteral(L, LUA_DBLIBNAME); | 69 | lua_pushliteral(L, LUA_DBLIBNAME); |
71 | lua_call(L, 1, 0); /* call 'require"debug"' */ | 70 | lua_call(L, 1, 0); /* call 'require"debug"' */ |
72 | lua_pop(L, 1); /* remove global table */ | 71 | lua_pop(L, 1); /* remove global table */ |