lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 6311e3109f4eb9a356b28d471e82d130d1198647
parent 9b854e6dbcf569113f68e63d87644b69eb00a228
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue, 15 Jun 2004 10:31:08 -0300

`setfenv' returns "self"

Diffstat:
Mlbaselib.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lbaselib.c b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.145 2004/06/02 14:20:08 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.146 2004/06/04 15:30:53 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -140,11 +140,13 @@ static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); getfunc(L); lua_pushvalue(L, 2); - if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { lua_replace(L, LUA_GLOBALSINDEX); + return 0; + } else if (lua_setfenv(L, -2) == 0) luaL_error(L, "`setfenv' cannot change environment of given function"); - return 0; + return 1; }