mirror of
https://github.com/lua/lua.git
synced 2025-02-04 06:13:04 +08:00
details
This commit is contained in:
parent
192d185492
commit
2d5b923759
11
linit.c
11
linit.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: linit.c,v 1.8 2004/07/09 15:47:48 roberto Exp roberto $
|
** $Id: linit.c,v 1.9 2005/02/18 12:40:02 roberto Exp roberto $
|
||||||
** Initialization of libraries for lua.c
|
** Initialization of libraries for lua.c
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -29,12 +29,15 @@ static const luaL_reg lualibs[] = {
|
|||||||
|
|
||||||
LUALIB_API int luaopen_stdlibs (lua_State *L) {
|
LUALIB_API int luaopen_stdlibs (lua_State *L) {
|
||||||
const luaL_reg *lib = lualibs;
|
const luaL_reg *lib = lualibs;
|
||||||
|
int t = lua_gettop(L);
|
||||||
|
lua_pushvalue(L, LUA_ENVIRONINDEX); /* save original environment */
|
||||||
for (; lib->func; lib++) {
|
for (; lib->func; lib++) {
|
||||||
lib->func(L); /* open library */
|
lib->func(L); /* open library */
|
||||||
lua_settop(L, 0); /* discard any results */
|
lua_settop(L, t + 1); /* discard any results */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, -1);
|
||||||
lua_replace(L, LUA_ENVIRONINDEX); /* restore environment */
|
lua_replace(L, LUA_ENVIRONINDEX); /* restore environment */
|
||||||
}
|
}
|
||||||
return 0;
|
lua_pop(L, 1);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user