diff options
Diffstat (limited to 'lbaselib.c')
| -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); |
