diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-30 17:54:51 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-30 17:54:51 -0300 |
commit | b0d5bd8c70150e1887256683c3fd6312fc1775b6 (patch) | |
tree | e0fd373d89745f8673c6b4a3f6404684551db9a5 | |
parent | 9fca43f5b060507942346e841fd39386ced6822b (diff) | |
download | lua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.tar.gz lua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.tar.bz2 lua-b0d5bd8c70150e1887256683c3fd6312fc1775b6.zip |
tinsert gets 3d argument instead of last one
-rw-r--r-- | lbaselib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 | ||
546 | static int luaB_tinsert (lua_State *L) { | 546 | static 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); |