From f67ccfbdeb9595b0549a733d229a02a7c3205ddc Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 26 Jun 2002 16:28:44 -0300 Subject: no more `lua_getn' function --- lbaselib.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index aeb213b9..40567969 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.85 2002/06/25 19:19:33 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.86 2002/06/26 16:37:13 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -257,11 +257,20 @@ static int luaB_assert (lua_State *L) { static int luaB_unpack (lua_State *L) { int n, i; luaL_check_type(L, 1, LUA_TTABLE); - n = lua_getn(L, 1); - luaL_check_stack(L, n+LUA_MINSTACK, "table too big to unpack"); - for (i=1; i<=n; i++) /* push arg[1...n] */ - lua_rawgeti(L, 1, i); - return n; + lua_pushliteral(L, "n"); + lua_rawget(L, 1); + n = (lua_isnumber(L, -1)) ? (int)lua_tonumber(L, -1) : -1; + for (i=0; i