aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-21 11:47:42 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-21 11:47:42 -0200
commit053e87314596e48588a929791012def7818ec989 (patch)
treee5ce2b8bdf03da3dbdac087bf62824b49e7d40f0 /lbaselib.c
parent9f4211310fcea9ebf08f4884f8665520c1b8d85f (diff)
downloadlua-053e87314596e48588a929791012def7818ec989.tar.gz
lua-053e87314596e48588a929791012def7818ec989.tar.bz2
lua-053e87314596e48588a929791012def7818ec989.zip
new macro luaL_opt to avoid evaluating defaults when no needed
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 35622402..1cd2e335 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.184 2005/10/03 14:36:45 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.185 2005/10/20 11:35:50 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*/
@@ -340,12 +340,10 @@ static int luaB_assert (lua_State *L) {
340 340
341 341
342static int luaB_unpack (lua_State *L) { 342static int luaB_unpack (lua_State *L) {
343 int i = luaL_optint(L, 2, 1); 343 int i, e, n;
344 int e = luaL_optint(L, 3, -1);
345 int n;
346 luaL_checktype(L, 1, LUA_TTABLE); 344 luaL_checktype(L, 1, LUA_TTABLE);
347 if (e == -1) 345 i = luaL_optint(L, 2, 1);
348 e = luaL_getn(L, 1); 346 e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
349 n = e - i + 1; /* number of elements */ 347 n = e - i + 1; /* number of elements */
350 if (n <= 0) return 0; /* empty range */ 348 if (n <= 0) return 0; /* empty range */
351 luaL_checkstack(L, n, "table too big to unpack"); 349 luaL_checkstack(L, n, "table too big to unpack");