lua

A copy of the Lua development repository
Log | Files | Refs | README

commit f5073de0a72562e1998f23052715e56a3b9fde18
parent f6ed285cf2916765d7291af19a11292f4bb8689c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri, 23 Oct 2009 10:50:01 -0200

'ipairs' goes until length of array instead of stopping at the first nil

Diffstat:
Mlbaselib.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lbaselib.c b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.218 2009/08/04 18:20:18 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.219 2009/10/05 16:44:33 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -255,7 +255,7 @@ static int ipairsaux (lua_State *L) { i++; /* next value */ lua_pushinteger(L, i); lua_rawgeti(L, 1, i); - return (lua_isnil(L, -1)) ? 0 : 2; + return (lua_isnil(L, -1) && i > (int)lua_objlen(L, 1)) ? 0 : 2; }