From c5050b1c4124967f695a22021c5fedfec381774c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 16 Nov 2009 13:51:03 -0200 Subject: functions 'getfenv' and 'setfenv' are deprecated --- lbaselib.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 80c4e3fa..d9a61336 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.222 2009/11/09 18:55:17 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.223 2009/11/13 17:01:40 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -107,6 +107,9 @@ static int luaB_setmetatable (lua_State *L) { } + +#if defined(LUA_COMPAT_FENV) + static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { @@ -121,7 +124,6 @@ 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? */ @@ -131,7 +133,6 @@ static int luaB_getfenv (lua_State *L) { return 1; } - static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); getfunc(L, 0); @@ -142,6 +143,16 @@ static int luaB_setfenv (lua_State *L) { return 1; } +#else + +static int luaB_getfenv (lua_State *L) { + return luaL_error(L, "getfenv/setfenv deprecated"); +} + +#define luaB_setfenv luaB_getfenv + +#endif + static int luaB_rawequal (lua_State *L) { luaL_checkany(L, 1); -- cgit v1.2.3-55-g6feb