diff options
Diffstat (limited to 'linit.c')
-rw-r--r-- | linit.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: linit.c,v 1.15 2007/06/22 16:59:11 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.16 2008/01/02 16:16:28 roberto Exp roberto $ |
3 | ** Initialization of libraries for lua.c | 3 | ** Initialization of libraries for lua.c |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | /* | 17 | /* |
18 | ** these libs are preloaded in Lua and are readily available to any program | 18 | ** these libs are loaded by lua.c and are readily available to any program |
19 | */ | 19 | */ |
20 | static const luaL_Reg lualibs[] = { | 20 | static const luaL_Reg lualibs[] = { |
21 | {"_G", luaopen_base}, | 21 | {"_G", luaopen_base}, |
@@ -30,7 +30,7 @@ static const luaL_Reg lualibs[] = { | |||
30 | 30 | ||
31 | 31 | ||
32 | /* | 32 | /* |
33 | ** these libs must be required before used | 33 | ** these libs are preloaded and must be required before used |
34 | */ | 34 | */ |
35 | static const luaL_Reg luareqlibs[] = { | 35 | static const luaL_Reg luareqlibs[] = { |
36 | {LUA_DBLIBNAME, luaopen_debug}, | 36 | {LUA_DBLIBNAME, luaopen_debug}, |
@@ -39,12 +39,14 @@ static const luaL_Reg luareqlibs[] = { | |||
39 | 39 | ||
40 | 40 | ||
41 | LUALIB_API void luaL_openlibs (lua_State *L) { | 41 | LUALIB_API void luaL_openlibs (lua_State *L) { |
42 | /* call open functions from 'lualibs' */ | ||
42 | const luaL_Reg *lib = lualibs; | 43 | const luaL_Reg *lib = lualibs; |
43 | for (; lib->func; lib++) { | 44 | for (; lib->func; lib++) { |
44 | lua_pushcfunction(L, lib->func); | 45 | lua_pushcfunction(L, lib->func); |
45 | lua_pushstring(L, lib->name); | 46 | lua_pushstring(L, lib->name); |
46 | lua_call(L, 1, 0); | 47 | lua_call(L, 1, 0); |
47 | } | 48 | } |
49 | /* add open functions from 'luareqlibs' into 'package.preload' table */ | ||
48 | lib = luareqlibs; | 50 | lib = luareqlibs; |
49 | luaL_findtable(L, LUA_GLOBALSINDEX, "package.preload", 0); | 51 | luaL_findtable(L, LUA_GLOBALSINDEX, "package.preload", 0); |
50 | for (; lib->func; lib++) { | 52 | for (; lib->func; lib++) { |