From 5bc91c640588ca77b9f84146fc88fcc9bdbfbcd1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 23 Oct 2009 17:12:19 -0200 Subject: no more one environment per thread: all threads share a single global environment --- lbaselib.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index a2ebaeb1..050ba6a6 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.219 2009/10/05 16:44:33 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.220 2009/10/23 12:50:25 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -125,7 +125,7 @@ static void getfunc (lua_State *L, int opt) { static int luaB_getfenv (lua_State *L) { getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ - lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the global env. */ else lua_getfenv(L, -1); return 1; @@ -136,14 +136,7 @@ static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); getfunc(L, 0); lua_pushvalue(L, 2); - if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { - /* change environment of current thread */ - lua_pushthread(L); - lua_insert(L, -2); - lua_setfenv(L, -2); - return 0; - } - else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) return luaL_error(L, LUA_QL("setfenv") " cannot change environment of given object"); return 1; -- cgit v1.2.3-55-g6feb