diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-12-08 10:58:04 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-12-08 10:58:04 -0200 |
| commit | 81646af13b5dc0c36388616b9ea6087952d9b57e (patch) | |
| tree | b71d3ab33c3134e4625a8fb2c27213c6b774ad9b | |
| parent | 233b71c092b742ef4b133cd2eb0adbe4f73d4ece (diff) | |
| download | lua-81646af13b5dc0c36388616b9ea6087952d9b57e.tar.gz lua-81646af13b5dc0c36388616b9ea6087952d9b57e.tar.bz2 lua-81646af13b5dc0c36388616b9ea6087952d9b57e.zip | |
'loadstring' deprecated; use 'load' instead
| -rw-r--r-- | lbaselib.c | 23 | ||||
| -rw-r--r-- | luaconf.h | 8 |
2 files changed, 18 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.252 2010/12/06 16:25:48 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.253 2010/12/07 11:40:42 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 | */ |
| @@ -114,12 +114,10 @@ static int luaB_setmetatable (lua_State *L) { | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | 116 | ||
| 117 | static int luaB_getfenv (lua_State *L) { | 117 | static int luaB_deprecated (lua_State *L) { |
| 118 | return luaL_error(L, "getfenv/setfenv deprecated"); | 118 | return luaL_error(L, "deprecated function"); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | #define luaB_setfenv luaB_getfenv | ||
| 122 | |||
| 123 | 121 | ||
| 124 | static int luaB_rawequal (lua_State *L) { | 122 | static int luaB_rawequal (lua_State *L) { |
| 125 | luaL_checkany(L, 1); | 123 | luaL_checkany(L, 1); |
| @@ -348,12 +346,13 @@ static int luaB_loadin (lua_State *L) { | |||
| 348 | } | 346 | } |
| 349 | 347 | ||
| 350 | 348 | ||
| 351 | static int luaB_loadstring (lua_State *L) { | 349 | #if defined(LUA_COMPAT_LOADSTRING) |
| 352 | lua_settop(L, 2); | 350 | #define luaB_loadstring luaB_load |
| 353 | lua_pushliteral(L, "tb"); | 351 | #else |
| 354 | return luaB_load(L); /* loadstring(s, n) == load(s, n, "tb") */ | 352 | #define luaB_loadstring luaB_deprecated |
| 353 | #endif | ||
| 354 | |||
| 355 | 355 | ||
| 356 | } | ||
| 357 | /* }====================================================== */ | 356 | /* }====================================================== */ |
| 358 | 357 | ||
| 359 | 358 | ||
| @@ -473,7 +472,7 @@ static const luaL_Reg base_funcs[] = { | |||
| 473 | {"collectgarbage", luaB_collectgarbage}, | 472 | {"collectgarbage", luaB_collectgarbage}, |
| 474 | {"dofile", luaB_dofile}, | 473 | {"dofile", luaB_dofile}, |
| 475 | {"error", luaB_error}, | 474 | {"error", luaB_error}, |
| 476 | {"getfenv", luaB_getfenv}, | 475 | {"getfenv", luaB_deprecated}, |
| 477 | {"getmetatable", luaB_getmetatable}, | 476 | {"getmetatable", luaB_getmetatable}, |
| 478 | {"ipairs", luaB_ipairs}, | 477 | {"ipairs", luaB_ipairs}, |
| 479 | {"loadfile", luaB_loadfile}, | 478 | {"loadfile", luaB_loadfile}, |
| @@ -488,7 +487,7 @@ static const luaL_Reg base_funcs[] = { | |||
| 488 | {"rawget", luaB_rawget}, | 487 | {"rawget", luaB_rawget}, |
| 489 | {"rawset", luaB_rawset}, | 488 | {"rawset", luaB_rawset}, |
| 490 | {"select", luaB_select}, | 489 | {"select", luaB_select}, |
| 491 | {"setfenv", luaB_setfenv}, | 490 | {"setfenv", luaB_deprecated}, |
| 492 | {"setmetatable", luaB_setmetatable}, | 491 | {"setmetatable", luaB_setmetatable}, |
| 493 | {"tonumber", luaB_tonumber}, | 492 | {"tonumber", luaB_tonumber}, |
| 494 | {"tostring", luaB_tostring}, | 493 | {"tostring", luaB_tostring}, |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.150 2010/11/10 17:38:10 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.151 2010/11/12 15:48:30 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 | */ |
| @@ -254,6 +254,12 @@ | |||
| 254 | #define LUA_COMPAT_LOG10 | 254 | #define LUA_COMPAT_LOG10 |
| 255 | 255 | ||
| 256 | /* | 256 | /* |
| 257 | @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base | ||
| 258 | ** library. You can rewrite 'loadstring(s)' as 'load(s)'. | ||
| 259 | */ | ||
| 260 | #define LUA_COMPAT_LOADSTRING | ||
| 261 | |||
| 262 | /* | ||
| 257 | @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. | 263 | @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. |
| 258 | */ | 264 | */ |
| 259 | #define LUA_COMPAT_MAXN | 265 | #define LUA_COMPAT_MAXN |
