no more LUA_FIRSTINDEX

This commit is contained in:
Roberto Ierusalimschy
2005-03-28 14:17:53 -03:00
parent 04c41444e2
commit ade585bdf9
6 changed files with 21 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.171 2005/03/16 16:58:41 roberto Exp roberto $
** $Id: lbaselib.c,v 1.172 2005/03/22 16:04:29 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -240,7 +240,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, LUA_FIRSTINDEX - 1); /* and initial value */
lua_pushinteger(L, 0); /* and initial value */
return 3;
}
@@ -340,12 +340,12 @@ static int luaB_getn (lua_State *L) {
static int luaB_unpack (lua_State *L) {
int i = luaL_optint(L, 2, LUA_FIRSTINDEX);
int i = luaL_optint(L, 2, 1);
int e = luaL_optint(L, 3, -1);
int n;
luaL_checktype(L, 1, LUA_TTABLE);
if (e == -1)
e = luaL_getn(L, 1) + LUA_FIRSTINDEX - 1;
e = luaL_getn(L, 1);
n = e - i + 1; /* number of elements */
if (n <= 0) return 0; /* empty range */
luaL_checkstack(L, n, "table too big to unpack");