diff options
| -rw-r--r-- | lbaselib.c | 17 | ||||
| -rw-r--r-- | luaconf.h | 10 |
2 files changed, 23 insertions, 4 deletions
| @@ -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 | |||
| 110 | static void getfunc (lua_State *L, int opt) { | 113 | static 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 | |||
| 125 | static int luaB_getfenv (lua_State *L) { | 127 | static 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 | |||
| 135 | static int luaB_setfenv (lua_State *L) { | 136 | static 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 | |||
| 148 | static 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 | ||
| 146 | static int luaB_rawequal (lua_State *L) { | 157 | static int luaB_rawequal (lua_State *L) { |
| 147 | luaL_checkany(L, 1); | 158 | luaL_checkany(L, 1); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.111 2009/10/11 20:02:19 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.112 2009/10/23 12:31:12 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -329,6 +329,14 @@ | |||
| 329 | */ | 329 | */ |
| 330 | 330 | ||
| 331 | /* | 331 | /* |
| 332 | @@ LUA_COMPAT_FENV controls de presence of functions 'setfenv/getfenv'. | ||
| 333 | ** CHANGE it (undefine it) if as soon as you rewrite your code to | ||
| 334 | ** avoid using those functions. (You can replace them with lexical | ||
| 335 | ** environments, 'loadin', or the debug library.) | ||
| 336 | */ | ||
| 337 | /* #define LUA_COMPAT_FENV */ | ||
| 338 | |||
| 339 | /* | ||
| 332 | @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. | 340 | @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. |
| 333 | ** CHANGE it (undefine it) if as soon as you rewrite all calls 'log10(x)' | 341 | ** CHANGE it (undefine it) if as soon as you rewrite all calls 'log10(x)' |
| 334 | ** as 'log(x, 10)' | 342 | ** as 'log(x, 10)' |
