aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-08-30 17:54:51 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-08-30 17:54:51 -0300
commitb0d5bd8c70150e1887256683c3fd6312fc1775b6 (patch)
treee0fd373d89745f8673c6b4a3f6404684551db9a5 /lbaselib.c
parent9fca43f5b060507942346e841fd39386ced6822b (diff)
downloadlua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.tar.gz
lua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.tar.bz2
lua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.zip
tinsert gets 3d argument instead of last one
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 1710f4d5..873820d3 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.38 2001/06/20 17:25:30 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.39 2001/07/12 18:11:58 roberto Exp $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -544,14 +544,16 @@ static int luaB_getn (lua_State *L) {
544 544
545 545
546static int luaB_tinsert (lua_State *L) { 546static int luaB_tinsert (lua_State *L) {
547 int v = lua_gettop(L); /* last argument: to be inserted */ 547 int v = lua_gettop(L); /* number of arguments */
548 int n, pos; 548 int n, pos;
549 luaL_checktype(L, 1, LUA_TTABLE); 549 luaL_checktype(L, 1, LUA_TTABLE);
550 n = lua_getn(L, 1); 550 n = lua_getn(L, 1);
551 if (v == 2) /* called with only 2 arguments */ 551 if (v == 2) /* called with only 2 arguments */
552 pos = n+1; 552 pos = n+1;
553 else 553 else {
554 v = 3; /* function may be called with more than 3 args */
554 pos = luaL_check_int(L, 2); /* 2nd argument is the position */ 555 pos = luaL_check_int(L, 2); /* 2nd argument is the position */
556 }
555 aux_setn(L, 1, n+1); /* t.n = n+1 */ 557 aux_setn(L, 1, n+1); /* t.n = n+1 */
556 for (; n>=pos; n--) { 558 for (; n>=pos; n--) {
557 lua_rawgeti(L, 1, n); 559 lua_rawgeti(L, 1, n);