aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-11-16 14:29:51 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-11-16 14:29:51 -0200
commit657f65211a5d836899d29b0a020a9ea4dff8cf51 (patch)
tree767d77883c9c2998b5cf23ddaf4ee5e98843fb7b /lapi.c
parent39395e12118539d983fdefbbc50d3aac3f53ccad (diff)
downloadlua-657f65211a5d836899d29b0a020a9ea4dff8cf51.tar.gz
lua-657f65211a5d836899d29b0a020a9ea4dff8cf51.tar.bz2
lua-657f65211a5d836899d29b0a020a9ea4dff8cf51.zip
bug: `next' did not work for numeric indices
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lapi.c b/lapi.c
index 36b77abe..ffeaf285 100644
--- a/lapi.c
+++ b/lapi.c
@@ -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
609LUA_API int lua_next (lua_State *L, int index) { 609LUA_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