diff options
author | Lua Team <team@lua.org> | 2010-11-23 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2010-11-23 12:00:00 +0000 |
commit | 5a8a687c0df648162fc86f30ee9ff10c4af44225 (patch) | |
tree | 9bd44fad38d4cc8518a7e686ea2228666c90b3b5 | |
parent | fb0603dc21768ef06c36dfebe3e812010cbb759a (diff) | |
download | lua-github-5a8a687c0df648162fc86f30ee9ff10c4af44225.tar.gz |
Lua 5.2.0-alpha5.2.0-alpha-rc45.2.0-alpha
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | src/ltablib.c | 60 |
2 files changed, 8 insertions, 54 deletions
@@ -1,5 +1,5 @@ -This is Lua 5.2 (alpha), released on 16 Nov 2010. +This is Lua 5.2 (alpha), released on 23 Nov 2010. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/src/ltablib.c b/src/ltablib.c index 17ea33bc..faabfe53 100644 --- a/src/ltablib.c +++ b/src/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.57 2010/10/25 19:01:37 roberto Exp $ +** $Id: ltablib.c,v 1.58 2010/11/23 17:21:14 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -20,47 +20,8 @@ (luaL_checktype(L, n, LUA_TTABLE), (int)lua_rawlen(L, n)) -static int foreachi (lua_State *L) { - int n = aux_getn(L, 1); - int i; - if (lua_getctx(L, &i) == LUA_YIELD) goto poscall; - luaL_checktype(L, 2, LUA_TFUNCTION); - for (i = 1; i <= n; i++) { - lua_pushvalue(L, 2); /* function */ - lua_pushinteger(L, i); /* 1st argument */ - lua_rawgeti(L, 1, i); /* 2nd argument */ - lua_callk(L, 2, 1, i, foreachi); - poscall: - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 1); /* remove nil result */ - } - return 0; -} - - -static int foreachcont (lua_State *L) { - for (;;) { - if (!lua_isnil(L, -1)) - return 1; - lua_pop(L, 2); /* remove value and result */ - if (lua_next(L, 1) == 0) /* no more elements? */ - return 0; - lua_pushvalue(L, 2); /* function */ - lua_pushvalue(L, -3); /* key */ - lua_pushvalue(L, -3); /* value */ - lua_callk(L, 2, 1, 0, foreachcont); - } -} - - -static int foreach (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TFUNCTION); - lua_pushnil(L); /* first key */ - lua_pushnil(L); /* first value */ - lua_pushnil(L); /* first "return" */ - return foreachcont(L); +static int deprecatedfunc (lua_State *L) { + return luaL_error(L, "deprecated function"); } @@ -80,16 +41,9 @@ static int maxn (lua_State *L) { return 1; } #else -static int maxn (lua_State *L) { - return luaL_error(L, "function 'maxn' is deprecated"); -} +#define maxn deprecatedfunc #endif -static int getn (lua_State *L) { - lua_pushinteger(L, aux_getn(L, 1)); - return 1; -} - static int tinsert (lua_State *L) { int e = aux_getn(L, 1) + 1; /* first empty element */ @@ -311,9 +265,9 @@ static int sort (lua_State *L) { static const luaL_Reg tab_funcs[] = { {"concat", tconcat}, - {"foreach", foreach}, - {"foreachi", foreachi}, - {"getn", getn}, + {"foreach", deprecatedfunc}, + {"foreachi", deprecatedfunc}, + {"getn", deprecatedfunc}, {"maxn", maxn}, {"insert", tinsert}, {"pack", pack}, |