commit 5caf7f4a33938f482be78d1b4a807e86411706f0
parent 3b533ea7c7fd65c2c2e61cd4c0a00578152e450a
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 27 May 1999 17:20:41 -0300
tremove erases its previous last element (to avoid locking potential
garbagge).
Diffstat:
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.56 1999/03/04 21:17:26 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.57 1999/05/24 17:53:49 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -470,10 +470,10 @@ static void luaB_tinsert (void) {
v = luaL_nonnullarg(2);
pos = n+1;
}
- luaV_setn(a, n+1); /* increment field "n" */
+ luaV_setn(a, n+1); /* a.n = n+1 */
for ( ;n>=pos; n--)
- luaH_move(a, n, n+1);
- luaH_setint(a, pos, luaA_Address(v));
+ luaH_move(a, n, n+1); /* a[n+1] = a[n] */
+ luaH_setint(a, pos, luaA_Address(v)); /* a[pos] = v */
}
@@ -482,10 +482,11 @@ static void luaB_tremove (void) {
int n = (int)getnarg(a);
int pos = luaL_opt_int(2, n);
if (n <= 0) return; /* table is "empty" */
- luaA_pushobject(luaH_getint(a, pos)); /* push result */
- luaV_setn(a, n-1); /* decrement field "n" */
+ luaA_pushobject(luaH_getint(a, pos)); /* result = a[pos] */
for ( ;pos<n; pos++)
- luaH_move(a, pos+1, pos);
+ luaH_move(a, pos+1, pos); /* a[pos] = a[pos+1] */
+ luaV_setn(a, n-1); /* a.n = n-1 */
+ luaH_setint(a, n, &luaO_nilobject); /* a[n] = nil */
}
diff --git a/manual.tex b/manual.tex
@@ -1,4 +1,4 @@
-% $Id: manual.tex,v 1.31 1999/05/05 19:21:57 roberto Exp roberto $
+% $Id: manual.tex,v 1.32 1999/05/11 20:46:28 roberto Exp roberto $
\documentclass[11pt]{article}
\usepackage{fullpage,bnf}
@@ -41,7 +41,7 @@ Waldemar Celes
\tecgraf\ --- Computer Science Department --- PUC-Rio
}
-\date{{\small \tt\$Date: 1999/05/05 19:21:57 $ $}}
+\date{{\small \tt\$Date: 1999/05/11 20:46:28 $ $}}
\maketitle
@@ -2281,11 +2281,12 @@ except that the table accesses are all raw (that is, without tag methods):
pos = pos or n
local value = t[pos]
if n<=0 then return end
- t.n = n-1
while pos < n do
t[pos] = t[pos+1]
pos = pos+1
end
+ t[n] = nil
+ t.n = n-1
return value
end
\end{verbatim}