aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-19 18:14:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-19 18:14:34 -0300
commit5a144e891a4b8965fc9fa16fa1efa1eaa3da2390 (patch)
treebf0b0165f480ce0d67be75157935730ca40cd7b6
parentb12776f29cda9157ccf6fdd4776f4f4ae73a326a (diff)
downloadlua-5a144e891a4b8965fc9fa16fa1efa1eaa3da2390.tar.gz
lua-5a144e891a4b8965fc9fa16fa1efa1eaa3da2390.tar.bz2
lua-5a144e891a4b8965fc9fa16fa1efa1eaa3da2390.zip
`__globals' -> `__fenv'
-rw-r--r--lbaselib.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lbaselib.c b/lbaselib.c
index ffc8ec1e..1c02921a 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.127 2003/03/11 12:24:34 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.128 2003/03/11 18:17:43 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*/
@@ -132,7 +132,7 @@ static void getfunc (lua_State *L) {
132 132
133static int aux_getfenv (lua_State *L) { 133static int aux_getfenv (lua_State *L) {
134 lua_getfenv(L, -1); 134 lua_getfenv(L, -1);
135 lua_pushliteral(L, "__globals"); 135 lua_pushliteral(L, "__fenv");
136 lua_rawget(L, -2); 136 lua_rawget(L, -2);
137 return !lua_isnil(L, -1); 137 return !lua_isnil(L, -1);
138} 138}
@@ -140,7 +140,7 @@ static int aux_getfenv (lua_State *L) {
140 140
141static int luaB_getfenv (lua_State *L) { 141static int luaB_getfenv (lua_State *L) {
142 getfunc(L); 142 getfunc(L);
143 if (!aux_getfenv(L)) /* __globals not defined? */ 143 if (!aux_getfenv(L)) /* __fenv not defined? */
144 lua_pop(L, 1); /* remove it, to return real environment */ 144 lua_pop(L, 1); /* remove it, to return real environment */
145 return 1; 145 return 1;
146} 146}
@@ -149,15 +149,15 @@ static int luaB_getfenv (lua_State *L) {
149static int luaB_setfenv (lua_State *L) { 149static int luaB_setfenv (lua_State *L) {
150 luaL_checktype(L, 2, LUA_TTABLE); 150 luaL_checktype(L, 2, LUA_TTABLE);
151 getfunc(L); 151 getfunc(L);
152 if (aux_getfenv(L)) /* __globals defined? */ 152 if (aux_getfenv(L)) /* __fenv defined? */
153 luaL_error(L, "cannot change a protected global table"); 153 luaL_error(L, "`setfenv' cannot change a protected environment");
154 else 154 else
155 lua_pop(L, 2); /* remove __globals and real environment table */ 155 lua_pop(L, 2); /* remove __fenv and real environment table */
156 lua_pushvalue(L, 2); 156 lua_pushvalue(L, 2);
157 if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) 157 if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0)
158 lua_replace(L, LUA_GLOBALSINDEX); 158 lua_replace(L, LUA_GLOBALSINDEX);
159 else if (lua_setfenv(L, -2) == 0) 159 else if (lua_setfenv(L, -2) == 0)
160 luaL_error(L, "cannot change environment of given function"); 160 luaL_error(L, "`setfenv' cannot change environment of given function");
161 return 0; 161 return 0;
162} 162}
163 163
@@ -495,7 +495,8 @@ static int luaB_require (lua_State *L) {
495 lua_tostring(L, 1), getpath(L)); 495 lua_tostring(L, 1), getpath(L));
496 } 496 }
497 default: { 497 default: {
498 return luaL_error(L, "error loading package\n%s", lua_tostring(L, -1)); 498 return luaL_error(L, "error loading package `%s' (%s)",
499 lua_tostring(L, 1), lua_tostring(L, -1));
499 } 500 }
500 } 501 }
501} 502}