`setfenv' returns "self"
This commit is contained in:
@@ -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
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -140,11 +140,13 @@ static int luaB_setfenv (lua_State *L) {
|
|||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
getfunc(L);
|
getfunc(L);
|
||||||
lua_pushvalue(L, 2);
|
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);
|
lua_replace(L, LUA_GLOBALSINDEX);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if (lua_setfenv(L, -2) == 0)
|
else if (lua_setfenv(L, -2) == 0)
|
||||||
luaL_error(L, "`setfenv' cannot change environment of given function");
|
luaL_error(L, "`setfenv' cannot change environment of given function");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user