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) --- lauxlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 9a8fe02b..6ff2940f 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.110 2004/03/23 16:38:43 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.111 2004/04/30 20:13:38 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -308,13 +308,13 @@ LUALIB_API int luaL_getn (lua_State *L, int t) { if ((n = checkint(L, 2)) >= 0) return n; lua_getfield(L, t, "n"); /* else try t.n */ if ((n = checkint(L, 1)) >= 0) return n; - for (n = 1; ; n++) { /* else must count elements */ + for (n = LUA_FIRSTINDEX; ; n++) { /* else must count elements */ lua_rawgeti(L, t, n); if (lua_isnil(L, -1)) break; lua_pop(L, 1); } lua_pop(L, 1); - return n - 1; + return n - LUA_FIRSTINDEX; } /* }====================================================== */ -- cgit v1.2.3-55-g6feb