summaryrefslogtreecommitdiff
path: root/ltablib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-11-23 15:21:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-11-23 15:21:14 -0200
commit5b33e398557d7afad4a916bb483e9894e4b9b3d4 (patch)
tree8bd6479713c634faf882948f6e027a418d327692 /ltablib.c
parenta64cf8fac97d59ae782625fa1aedae3b5f3331d4 (diff)
downloadlua-github-5b33e398557d7afad4a916bb483e9894e4b9b3d4.tar.gz
removed deprecated functions getn-foreach-foreachiv5.2-alphav5-2-alpha
Diffstat (limited to 'ltablib.c')
-rw-r--r--ltablib.c60
1 files changed, 7 insertions, 53 deletions
diff --git a/ltablib.c b/ltablib.c
index 9aa7d5c9..f1fb9cdd 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.56 2010/07/02 11:38:13 roberto Exp roberto $
+** $Id: ltablib.c,v 1.57 2010/10/25 19:01:37 roberto Exp roberto $
** 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},