aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-06-15 10:31:30 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-06-15 10:31:30 -0300
commit6311e3109f4eb9a356b28d471e82d130d1198647 (patch)
tree0a4f63a1cde9d78685c398825d552c8d2a134ab4 /lbaselib.c
parent9b854e6dbcf569113f68e63d87644b69eb00a228 (diff)
downloadlua-6311e3109f4eb9a356b28d471e82d130d1198647.tar.gz
lua-6311e3109f4eb9a356b28d471e82d130d1198647.tar.bz2
lua-6311e3109f4eb9a356b28d471e82d130d1198647.zip
`setfenv' returns "self"
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index aa9a6f1e..aea02d47 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.145 2004/06/02 14:20:08 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.146 2004/06/04 15:30:53 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -140,11 +140,13 @@ static int luaB_setfenv (lua_State *L) {
140 luaL_checktype(L, 2, LUA_TTABLE); 140 luaL_checktype(L, 2, LUA_TTABLE);
141 getfunc(L); 141 getfunc(L);
142 lua_pushvalue(L, 2); 142 lua_pushvalue(L, 2);
143 if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) 143 if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
144 lua_replace(L, LUA_GLOBALSINDEX); 144 lua_replace(L, LUA_GLOBALSINDEX);
145 return 0;
146 }
145 else if (lua_setfenv(L, -2) == 0) 147 else if (lua_setfenv(L, -2) == 0)
146 luaL_error(L, "`setfenv' cannot change environment of given function"); 148 luaL_error(L, "`setfenv' cannot change environment of given function");
147 return 0; 149 return 1;
148} 150}
149 151
150 152