Browse Source

clearing some old compatibility code

Roberto Ierusalimschy 18 years ago
parent
commit
e85515958b
1 changed files with 4 additions and 13 deletions
  1. 4 13
      ltablib.c

+ 4 - 13
ltablib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltablib.c,v 1.37 2005/10/21 13:47:42 roberto Exp roberto $
+** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp roberto $
 ** Library for Table Manipulation
 ** See Copyright Notice in lua.h
 */
@@ -16,7 +16,7 @@
 #include "lualib.h"
 
 
-#define aux_getn(L,n)	(luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
+#define aux_getn(L,n)	(luaL_checktype(L, n, LUA_TTABLE), lua_objlen(L, n))
 
 
 static int foreachi (lua_State *L) {
@@ -76,14 +76,7 @@ static int getn (lua_State *L) {
 
 
 static int setn (lua_State *L) {
-  luaL_checktype(L, 1, LUA_TTABLE);
-#ifndef luaL_setn
-  luaL_setn(L, 1, luaL_checkint(L, 2));
-#else
-  luaL_error(L, LUA_QL("setn") " is obsolete");
-#endif
-  lua_pushvalue(L, 1);
-  return 1;
+  return luaL_error(L, LUA_QL("setn") " is obsolete");
 }
 
 
@@ -109,7 +102,6 @@ static int tinsert (lua_State *L) {
       return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
     }
   }
-  luaL_setn(L, 1, e);  /* new size */
   lua_rawseti(L, 1, pos);  /* t[pos] = v */
   return 0;
 }
@@ -119,7 +111,6 @@ static int tremove (lua_State *L) {
   int e = aux_getn(L, 1);
   int pos = luaL_optint(L, 2, e);
   if (e == 0) return 0;  /* table is `empty' */
-  luaL_setn(L, 1, e - 1);  /* t.n = n-1 */
   lua_rawgeti(L, 1, pos);  /* result = t[pos] */
   for ( ;pos<e; pos++) {
     lua_rawgeti(L, 1, pos+1);
@@ -138,7 +129,7 @@ static int tconcat (lua_State *L) {
   const char *sep = luaL_optlstring(L, 2, "", &lsep);
   luaL_checktype(L, 1, LUA_TTABLE);
   i = luaL_optint(L, 3, 1);
-  last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
+  last = luaL_opt(L, luaL_checkint, 4, lua_objlen(L, 1));
   luaL_buffinit(L, &b);
   for (; i <= last; i++) {
     lua_rawgeti(L, 1, i);