mirror of https://github.com/rusefi/lua.git
bug: `next' did not work for numeric indices
This commit is contained in:
parent
39395e1211
commit
657f65211a
11
lapi.c
11
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.158 2001/10/31 19:40:14 roberto Exp roberto $
|
** $Id: lapi.c,v 1.159 2001/10/31 19:58:11 roberto Exp $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -608,19 +608,18 @@ LUA_API void lua_error (lua_State *L, const l_char *s) {
|
||||||
|
|
||||||
LUA_API int lua_next (lua_State *L, int index) {
|
LUA_API int lua_next (lua_State *L, int index) {
|
||||||
StkId t;
|
StkId t;
|
||||||
int more;
|
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
t = luaA_index(L, index);
|
t = luaA_index(L, index);
|
||||||
api_check(L, ttype(t) == LUA_TTABLE);
|
api_check(L, ttype(t) == LUA_TTABLE);
|
||||||
more = luaH_index(L, hvalue(t), luaA_index(L, -1));
|
index = luaH_index(L, hvalue(t), luaA_index(L, -1));
|
||||||
more = (luaH_nexti(hvalue(t), more, L->top - 1) != -1);
|
index = (luaH_nexti(hvalue(t), index, L->top - 1) != -1);
|
||||||
if (more) {
|
if (index) {
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
}
|
}
|
||||||
else /* no more elements */
|
else /* no more elements */
|
||||||
L->top -= 1; /* remove key */
|
L->top -= 1; /* remove key */
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
return more;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
4
ltable.c
4
ltable.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 1.86 2001/09/07 17:30:16 roberto Exp $
|
** $Id: ltable.c,v 1.87 2001/10/25 19:14:14 roberto Exp $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +96,7 @@ int luaH_index (lua_State *L, Table *t, const TObject *key) {
|
||||||
if (ttype(key) == LUA_TNIL) return -1; /* first iteration */
|
if (ttype(key) == LUA_TNIL) return -1; /* first iteration */
|
||||||
i = arrayindex(key);
|
i = arrayindex(key);
|
||||||
if (0 <= i && i < t->sizearray) { /* is `key' inside array part? */
|
if (0 <= i && i < t->sizearray) { /* is `key' inside array part? */
|
||||||
return i; /* yes; that's the index */
|
return i-1; /* yes; that's the index (corrected to C) */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const TObject *v = luaH_get(t, key);
|
const TObject *v = luaH_get(t, key);
|
||||||
|
|
Loading…
Reference in New Issue