aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 06c38da8..13e6c7b6 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.141 2004/03/26 13:25:17 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.142 2004/04/30 20:13:38 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -257,7 +257,7 @@ static int luaB_ipairs (lua_State *L) {
257 luaL_checktype(L, 1, LUA_TTABLE); 257 luaL_checktype(L, 1, LUA_TTABLE);
258 lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ 258 lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
259 lua_pushvalue(L, 1); /* state, */ 259 lua_pushvalue(L, 1); /* state, */
260 lua_pushinteger(L, 0); /* and initial value */ 260 lua_pushinteger(L, LUA_FIRSTINDEX - 1); /* and initial value */
261 return 3; 261 return 3;
262} 262}
263 263
@@ -347,11 +347,12 @@ static int luaB_assert (lua_State *L) {
347 347
348 348
349static int luaB_unpack (lua_State *L) { 349static int luaB_unpack (lua_State *L) {
350 int i = luaL_optint(L, 2, 1); 350 int i = luaL_optint(L, 2, LUA_FIRSTINDEX);
351 int e = luaL_optint(L, 3, -1); 351 int e = luaL_optint(L, 3, -1);
352 int n; 352 int n;
353 luaL_checktype(L, 1, LUA_TTABLE); 353 luaL_checktype(L, 1, LUA_TTABLE);
354 if (e == -1) e = luaL_getn(L, 1); 354 if (e == -1)
355 e = luaL_getn(L, 1) + LUA_FIRSTINDEX - 1;
355 n = e - i + 1; /* number of elements */ 356 n = e - i + 1; /* number of elements */
356 if (n <= 0) return 0; /* empty range */ 357 if (n <= 0) return 0; /* empty range */
357 luaL_checkstack(L, n, "table too big to unpack"); 358 luaL_checkstack(L, n, "table too big to unpack");