aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lbaselib.c b/lbaselib.c
index dac9fb23..7bf69c8f 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.121 2003/02/18 16:13:15 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.122 2003/02/24 16:50:41 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*/
@@ -127,31 +127,31 @@ static void getfunc (lua_State *L) {
127} 127}
128 128
129 129
130static int aux_getenvtable (lua_State *L) { 130static int aux_getfenv (lua_State *L) {
131 lua_getenvtable(L, -1); 131 lua_getfenv(L, -1);
132 lua_pushliteral(L, "__globals"); 132 lua_pushliteral(L, "__globals");
133 lua_rawget(L, -2); 133 lua_rawget(L, -2);
134 return !lua_isnil(L, -1); 134 return !lua_isnil(L, -1);
135} 135}
136 136
137 137
138static int luaB_getenvtable (lua_State *L) { 138static int luaB_getfenv (lua_State *L) {
139 getfunc(L); 139 getfunc(L);
140 if (!aux_getenvtable(L)) /* __globals not defined? */ 140 if (!aux_getfenv(L)) /* __globals not defined? */
141 lua_pop(L, 1); /* remove it, to return real environment */ 141 lua_pop(L, 1); /* remove it, to return real environment */
142 return 1; 142 return 1;
143} 143}
144 144
145 145
146static int luaB_setenvtable (lua_State *L) { 146static int luaB_setfenv (lua_State *L) {
147 luaL_checktype(L, 2, LUA_TTABLE); 147 luaL_checktype(L, 2, LUA_TTABLE);
148 getfunc(L); 148 getfunc(L);
149 if (aux_getenvtable(L)) /* __globals defined? */ 149 if (aux_getfenv(L)) /* __globals defined? */
150 luaL_error(L, "cannot change a protected global table"); 150 luaL_error(L, "cannot change a protected global table");
151 else 151 else
152 lua_pop(L, 2); /* remove __globals and real environment table */ 152 lua_pop(L, 2); /* remove __globals and real environment table */
153 lua_pushvalue(L, 2); 153 lua_pushvalue(L, 2);
154 if (lua_setenvtable(L, -2) == 0) 154 if (lua_setfenv(L, -2) == 0)
155 luaL_error(L, "cannot change environment of given function"); 155 luaL_error(L, "cannot change environment of given function");
156 return 0; 156 return 0;
157} 157}
@@ -247,8 +247,8 @@ static int load_aux (lua_State *L, int status) {
247 lua_Debug ar; 247 lua_Debug ar;
248 lua_getstack(L, 1, &ar); 248 lua_getstack(L, 1, &ar);
249 lua_getinfo(L, "f", &ar); /* get calling function */ 249 lua_getinfo(L, "f", &ar); /* get calling function */
250 lua_getenvtable(L, -1); /* get its environment */ 250 lua_getfenv(L, -1); /* get its environment */
251 lua_setenvtable(L, -3); /* set it as the environment of the new chunk */ 251 lua_setfenv(L, -3); /* set it as the environment of the new chunk */
252 lua_pop(L, 1); /* remove calling function */ 252 lua_pop(L, 1); /* remove calling function */
253 return 1; 253 return 1;
254 } 254 }
@@ -499,8 +499,8 @@ static const luaL_reg base_funcs[] = {
499 {"error", luaB_error}, 499 {"error", luaB_error},
500 {"getmetatable", luaB_getmetatable}, 500 {"getmetatable", luaB_getmetatable},
501 {"setmetatable", luaB_setmetatable}, 501 {"setmetatable", luaB_setmetatable},
502 {"getenvtable", luaB_getenvtable}, 502 {"getfenv", luaB_getfenv},
503 {"setenvtable", luaB_setenvtable}, 503 {"setfenv", luaB_setfenv},
504 {"next", luaB_next}, 504 {"next", luaB_next},
505 {"ipairs", luaB_ipairs}, 505 {"ipairs", luaB_ipairs},
506 {"pairs", luaB_pairs}, 506 {"pairs", luaB_pairs},