From 7d45a5f48ff32a4e09a1734de23823943d6a6b28 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 18 Feb 2005 10:40:02 -0200 Subject: C functions and userdata also have environments --- linit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'linit.c') diff --git a/linit.c b/linit.c index a50b894e..da414468 100644 --- a/linit.c +++ b/linit.c @@ -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; } -- cgit v1.2.3-55-g6feb