aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index bed22426..6f8037c5 100644
--- a/lapi.c
+++ b/lapi.c
@@ -567,18 +567,18 @@ LUA_API void lua_error (lua_State *L, const char *s) {
567 567
568LUA_API int lua_next (lua_State *L, int index) { 568LUA_API int lua_next (lua_State *L, int index) {
569 StkId t; 569 StkId t;
570 int more;
570 lua_lock(L); 571 lua_lock(L);
571 t = luaA_index(L, index); 572 t = luaA_index(L, index);
572 api_check(L, ttype(t) == LUA_TTABLE); 573 api_check(L, ttype(t) == LUA_TTABLE);
573 index = luaH_index(L, hvalue(t), luaA_index(L, -1)); 574 more = luaH_next(L, hvalue(t), L->top - 1);
574 index = (luaH_nexti(hvalue(t), index, L->top - 1) != -1); 575 if (more) {
575 if (index) {
576 api_incr_top(L); 576 api_incr_top(L);
577 } 577 }
578 else /* no more elements */ 578 else /* no more elements */
579 L->top -= 1; /* remove key */ 579 L->top -= 1; /* remove key */
580 lua_unlock(L); 580 lua_unlock(L);
581 return index; 581 return more;
582} 582}
583 583
584 584