aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-11-16 13:51:03 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-11-16 13:51:03 -0200
commitc5050b1c4124967f695a22021c5fedfec381774c (patch)
treeb778612524b523b6e26300b0162285a1a67a83d3 /lbaselib.c
parentb9063a08f522a62a8fc3b282cd7782af3a30487d (diff)
downloadlua-c5050b1c4124967f695a22021c5fedfec381774c.tar.gz
lua-c5050b1c4124967f695a22021c5fedfec381774c.tar.bz2
lua-c5050b1c4124967f695a22021c5fedfec381774c.zip
functions 'getfenv' and 'setfenv' are deprecated
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 80c4e3fa..d9a61336 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.222 2009/11/09 18:55:17 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.223 2009/11/13 17:01:40 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*/
@@ -107,6 +107,9 @@ static int luaB_setmetatable (lua_State *L) {
107} 107}
108 108
109 109
110
111#if defined(LUA_COMPAT_FENV)
112
110static void getfunc (lua_State *L, int opt) { 113static void getfunc (lua_State *L, int opt) {
111 if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); 114 if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
112 else { 115 else {
@@ -121,7 +124,6 @@ static void getfunc (lua_State *L, int opt) {
121 } 124 }
122} 125}
123 126
124
125static int luaB_getfenv (lua_State *L) { 127static int luaB_getfenv (lua_State *L) {
126 getfunc(L, 1); 128 getfunc(L, 1);
127 if (lua_iscfunction(L, -1)) /* is a C function? */ 129 if (lua_iscfunction(L, -1)) /* is a C function? */
@@ -131,7 +133,6 @@ static int luaB_getfenv (lua_State *L) {
131 return 1; 133 return 1;
132} 134}
133 135
134
135static int luaB_setfenv (lua_State *L) { 136static int luaB_setfenv (lua_State *L) {
136 luaL_checktype(L, 2, LUA_TTABLE); 137 luaL_checktype(L, 2, LUA_TTABLE);
137 getfunc(L, 0); 138 getfunc(L, 0);
@@ -142,6 +143,16 @@ static int luaB_setfenv (lua_State *L) {
142 return 1; 143 return 1;
143} 144}
144 145
146#else
147
148static int luaB_getfenv (lua_State *L) {
149 return luaL_error(L, "getfenv/setfenv deprecated");
150}
151
152#define luaB_setfenv luaB_getfenv
153
154#endif
155
145 156
146static int luaB_rawequal (lua_State *L) { 157static int luaB_rawequal (lua_State *L) {
147 luaL_checkany(L, 1); 158 luaL_checkany(L, 1);