diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-06-21 10:48:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-06-21 10:48:04 -0300 |
commit | e85515958b0910e932cd50d5366c7406401d5236 (patch) | |
tree | 1a5bcfe766054c83d9c6faa327b69a1714b3ac90 /ltablib.c | |
parent | dc59444cd120e38d0babaeb3a7ad3d36f63225e6 (diff) | |
download | lua-e85515958b0910e932cd50d5366c7406401d5236.tar.gz lua-e85515958b0910e932cd50d5366c7406401d5236.tar.bz2 lua-e85515958b0910e932cd50d5366c7406401d5236.zip |
clearing some old compatibility code
Diffstat (limited to 'ltablib.c')
-rw-r--r-- | ltablib.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.37 2005/10/21 13:47:42 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -16,7 +16,7 @@ | |||
16 | #include "lualib.h" | 16 | #include "lualib.h" |
17 | 17 | ||
18 | 18 | ||
19 | #define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) | 19 | #define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), lua_objlen(L, n)) |
20 | 20 | ||
21 | 21 | ||
22 | static int foreachi (lua_State *L) { | 22 | static int foreachi (lua_State *L) { |
@@ -76,14 +76,7 @@ static int getn (lua_State *L) { | |||
76 | 76 | ||
77 | 77 | ||
78 | static int setn (lua_State *L) { | 78 | static int setn (lua_State *L) { |
79 | luaL_checktype(L, 1, LUA_TTABLE); | 79 | return luaL_error(L, LUA_QL("setn") " is obsolete"); |
80 | #ifndef luaL_setn | ||
81 | luaL_setn(L, 1, luaL_checkint(L, 2)); | ||
82 | #else | ||
83 | luaL_error(L, LUA_QL("setn") " is obsolete"); | ||
84 | #endif | ||
85 | lua_pushvalue(L, 1); | ||
86 | return 1; | ||
87 | } | 80 | } |
88 | 81 | ||
89 | 82 | ||
@@ -109,7 +102,6 @@ static int tinsert (lua_State *L) { | |||
109 | return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); | 102 | return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); |
110 | } | 103 | } |
111 | } | 104 | } |
112 | luaL_setn(L, 1, e); /* new size */ | ||
113 | lua_rawseti(L, 1, pos); /* t[pos] = v */ | 105 | lua_rawseti(L, 1, pos); /* t[pos] = v */ |
114 | return 0; | 106 | return 0; |
115 | } | 107 | } |
@@ -119,7 +111,6 @@ static int tremove (lua_State *L) { | |||
119 | int e = aux_getn(L, 1); | 111 | int e = aux_getn(L, 1); |
120 | int pos = luaL_optint(L, 2, e); | 112 | int pos = luaL_optint(L, 2, e); |
121 | if (e == 0) return 0; /* table is `empty' */ | 113 | if (e == 0) return 0; /* table is `empty' */ |
122 | luaL_setn(L, 1, e - 1); /* t.n = n-1 */ | ||
123 | lua_rawgeti(L, 1, pos); /* result = t[pos] */ | 114 | lua_rawgeti(L, 1, pos); /* result = t[pos] */ |
124 | for ( ;pos<e; pos++) { | 115 | for ( ;pos<e; pos++) { |
125 | lua_rawgeti(L, 1, pos+1); | 116 | lua_rawgeti(L, 1, pos+1); |
@@ -138,7 +129,7 @@ static int tconcat (lua_State *L) { | |||
138 | const char *sep = luaL_optlstring(L, 2, "", &lsep); | 129 | const char *sep = luaL_optlstring(L, 2, "", &lsep); |
139 | luaL_checktype(L, 1, LUA_TTABLE); | 130 | luaL_checktype(L, 1, LUA_TTABLE); |
140 | i = luaL_optint(L, 3, 1); | 131 | i = luaL_optint(L, 3, 1); |
141 | last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1)); | 132 | last = luaL_opt(L, luaL_checkint, 4, lua_objlen(L, 1)); |
142 | luaL_buffinit(L, &b); | 133 | luaL_buffinit(L, &b); |
143 | for (; i <= last; i++) { | 134 | for (; i <= last; i++) { |
144 | lua_rawgeti(L, 1, i); | 135 | lua_rawgeti(L, 1, i); |