diff options
-rw-r--r-- | lapi.c | 11 | ||||
-rw-r--r-- | ltable.c | 4 |
2 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.158 2001/10/31 19:40:14 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.159 2001/10/31 19:58:11 roberto Exp $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -608,19 +608,18 @@ LUA_API void lua_error (lua_State *L, const l_char *s) { | |||
608 | 608 | ||
609 | LUA_API int lua_next (lua_State *L, int index) { | 609 | LUA_API int lua_next (lua_State *L, int index) { |
610 | StkId t; | 610 | StkId t; |
611 | int more; | ||
612 | lua_lock(L); | 611 | lua_lock(L); |
613 | t = luaA_index(L, index); | 612 | t = luaA_index(L, index); |
614 | api_check(L, ttype(t) == LUA_TTABLE); | 613 | api_check(L, ttype(t) == LUA_TTABLE); |
615 | more = luaH_index(L, hvalue(t), luaA_index(L, -1)); | 614 | index = luaH_index(L, hvalue(t), luaA_index(L, -1)); |
616 | more = (luaH_nexti(hvalue(t), more, L->top - 1) != -1); | 615 | index = (luaH_nexti(hvalue(t), index, L->top - 1) != -1); |
617 | if (more) { | 616 | if (index) { |
618 | api_incr_top(L); | 617 | api_incr_top(L); |
619 | } | 618 | } |
620 | else /* no more elements */ | 619 | else /* no more elements */ |
621 | L->top -= 1; /* remove key */ | 620 | L->top -= 1; /* remove key */ |
622 | lua_unlock(L); | 621 | lua_unlock(L); |
623 | return more; | 622 | return index; |
624 | } | 623 | } |
625 | 624 | ||
626 | 625 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.86 2001/09/07 17:30:16 roberto Exp $ | 2 | ** $Id: ltable.c,v 1.87 2001/10/25 19:14:14 roberto Exp $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -96,7 +96,7 @@ int luaH_index (lua_State *L, Table *t, const TObject *key) { | |||
96 | if (ttype(key) == LUA_TNIL) return -1; /* first iteration */ | 96 | if (ttype(key) == LUA_TNIL) return -1; /* first iteration */ |
97 | i = arrayindex(key); | 97 | i = arrayindex(key); |
98 | if (0 <= i && i < t->sizearray) { /* is `key' inside array part? */ | 98 | if (0 <= i && i < t->sizearray) { /* is `key' inside array part? */ |
99 | return i; /* yes; that's the index */ | 99 | return i-1; /* yes; that's the index (corrected to C) */ |
100 | } | 100 | } |
101 | else { | 101 | else { |
102 | const TObject *v = luaH_get(t, key); | 102 | const TObject *v = luaH_get(t, key); |