From c4999bd59d5ec827d70d72789febe234fe9c4002 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 10 Aug 2008 17:23:08 +0200 Subject: [PATCH] lua: fix __next, must return 2 values Signed-off-by: Julien Danjou --- lua.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua.h b/lua.h index 34ea9547..ac5cdfb5 100644 --- a/lua.h +++ b/lua.h @@ -315,12 +315,20 @@ luaA_generic_pairs(lua_State *L) { \ int idx = lua_tonumber(L, 2); \ if(idx >= 0 && idx < value->len) \ - return ctor(L, value->tab[idx]); \ + { \ + lua_pushnumber(L, idx + 1); \ + ctor(L, value->tab[idx]); \ + return 2; \ + } \ } \ else if(lua_isnil(L, 2)) \ { \ if(value->len) \ - return ctor(L, value->tab[0]); \ + { \ + lua_pushnumber(L, 1); \ + ctor(L, value->tab[0]); \ + return 2; \ + } \ } \ } \ return 0; \