diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-14 19:46:13 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-14 19:46:13 -0200 |
commit | 57fb51f975c39a063896bccbf4b2e3169f309941 (patch) | |
tree | f641bb2984a03f48cdb67b2815a03ebfc393d8db | |
parent | 1c423d266180a37fa00d433ec769b1420d591ba7 (diff) | |
download | lua-57fb51f975c39a063896bccbf4b2e3169f309941.tar.gz lua-57fb51f975c39a063896bccbf4b2e3169f309941.tar.bz2 lua-57fb51f975c39a063896bccbf4b2e3169f309941.zip |
`luaH_next' works like `next'
-rw-r--r-- | lapi.c | 8 | ||||
-rw-r--r-- | ltable.h | 3 |
2 files changed, 5 insertions, 6 deletions
@@ -567,18 +567,18 @@ LUA_API void lua_error (lua_State *L, const char *s) { | |||
567 | 567 | ||
568 | LUA_API int lua_next (lua_State *L, int index) { | 568 | LUA_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 | ||
@@ -24,8 +24,7 @@ const TObject *luaH_get (Table *t, const TObject *key); | |||
24 | void luaH_set (lua_State *L, Table *t, const TObject *key, const TObject *val); | 24 | void luaH_set (lua_State *L, Table *t, const TObject *key, const TObject *val); |
25 | Table *luaH_new (lua_State *L, int narray, int lnhash); | 25 | Table *luaH_new (lua_State *L, int narray, int lnhash); |
26 | void luaH_free (lua_State *L, Table *t); | 26 | void luaH_free (lua_State *L, Table *t); |
27 | int luaH_index (lua_State *L, Table *t, const TObject *key); | 27 | int luaH_next (lua_State *L, Table *t, TObject *key); |
28 | int luaH_nexti (Table *t, int i, TObject *where); | ||
29 | 28 | ||
30 | /* exported only for debugging */ | 29 | /* exported only for debugging */ |
31 | Node *luaH_mainposition (const Table *t, const TObject *key); | 30 | Node *luaH_mainposition (const Table *t, const TObject *key); |