diff options
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 11 |
1 files changed, 5 insertions, 6 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 | ||
