diff options
Diffstat (limited to 'lbuiltin.c')
-rw-r--r-- | lbuiltin.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.56 1999/03/04 21:17:26 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.57 1999/05/24 17:53:49 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -470,10 +470,10 @@ static void luaB_tinsert (void) { | |||
470 | v = luaL_nonnullarg(2); | 470 | v = luaL_nonnullarg(2); |
471 | pos = n+1; | 471 | pos = n+1; |
472 | } | 472 | } |
473 | luaV_setn(a, n+1); /* increment field "n" */ | 473 | luaV_setn(a, n+1); /* a.n = n+1 */ |
474 | for ( ;n>=pos; n--) | 474 | for ( ;n>=pos; n--) |
475 | luaH_move(a, n, n+1); | 475 | luaH_move(a, n, n+1); /* a[n+1] = a[n] */ |
476 | luaH_setint(a, pos, luaA_Address(v)); | 476 | luaH_setint(a, pos, luaA_Address(v)); /* a[pos] = v */ |
477 | } | 477 | } |
478 | 478 | ||
479 | 479 | ||
@@ -482,10 +482,11 @@ static void luaB_tremove (void) { | |||
482 | int n = (int)getnarg(a); | 482 | int n = (int)getnarg(a); |
483 | int pos = luaL_opt_int(2, n); | 483 | int pos = luaL_opt_int(2, n); |
484 | if (n <= 0) return; /* table is "empty" */ | 484 | if (n <= 0) return; /* table is "empty" */ |
485 | luaA_pushobject(luaH_getint(a, pos)); /* push result */ | 485 | luaA_pushobject(luaH_getint(a, pos)); /* result = a[pos] */ |
486 | luaV_setn(a, n-1); /* decrement field "n" */ | ||
487 | for ( ;pos<n; pos++) | 486 | for ( ;pos<n; pos++) |
488 | luaH_move(a, pos+1, pos); | 487 | luaH_move(a, pos+1, pos); /* a[pos] = a[pos+1] */ |
488 | luaV_setn(a, n-1); /* a.n = n-1 */ | ||
489 | luaH_setint(a, n, &luaO_nilobject); /* a[n] = nil */ | ||
489 | } | 490 | } |
490 | 491 | ||
491 | 492 | ||