From 7e41612eb28ff0fba282bd419781fcbc9bd94776 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 May 2004 14:50:51 -0300 Subject: code parameterized by LUA_FIRSTINDEX (first index of an array) --- lbaselib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 06c38da8..13e6c7b6 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.141 2004/03/26 13:25:17 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.142 2004/04/30 20:13:38 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -257,7 +257,7 @@ static int luaB_ipairs (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ lua_pushvalue(L, 1); /* state, */ - lua_pushinteger(L, 0); /* and initial value */ + lua_pushinteger(L, LUA_FIRSTINDEX - 1); /* and initial value */ return 3; } @@ -347,11 +347,12 @@ static int luaB_assert (lua_State *L) { static int luaB_unpack (lua_State *L) { - int i = luaL_optint(L, 2, 1); + int i = luaL_optint(L, 2, LUA_FIRSTINDEX); int e = luaL_optint(L, 3, -1); int n; luaL_checktype(L, 1, LUA_TTABLE); - if (e == -1) e = luaL_getn(L, 1); + if (e == -1) + e = luaL_getn(L, 1) + LUA_FIRSTINDEX - 1; n = e - i + 1; /* number of elements */ if (n <= 0) return 0; /* empty range */ luaL_checkstack(L, n, "table too big to unpack"); -- cgit v1.2.3-55-g6feb