C functions and userdata also have environments

This commit is contained in:
Roberto Ierusalimschy
2005-02-18 10:40:02 -02:00
parent 73d7640244
commit 7d45a5f48f
17 changed files with 206 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: linit.c,v 1.7 2004/07/09 14:29:29 roberto Exp roberto $
** $Id: linit.c,v 1.8 2004/07/09 15:47:48 roberto Exp roberto $
** Initialization of libraries for lua.c
** See Copyright Notice in lua.h
*/
@@ -32,6 +32,8 @@ LUALIB_API int luaopen_stdlibs (lua_State *L) {
for (; lib->func; lib++) {
lib->func(L); /* open library */
lua_settop(L, 0); /* discard any results */
lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_replace(L, LUA_ENVIRONINDEX); /* restore environment */
}
return 0;
}