# HG changeset patch # User jbe # Date 1408829710 -7200 # Node ID 4fc9090ada1d6dfbdf00ad462cfb1969631cc2c1 # Parent 367fc70acc15cbf0aed04abf25595aab5f7c1a30 Mention 3 extra elements on stack in README; Changed order of two instructions in seqlualib.c diff -r 367fc70acc15 -r 4fc9090ada1d README --- a/README Sat Aug 23 23:13:17 2014 +0200 +++ b/README Sat Aug 23 23:35:10 2014 +0200 @@ -133,4 +133,11 @@ printcsv(assert(io.open("testfile")):lines()) -- prints: line1,line2,... of "testfile" +NOTE: During iteration using ``seqlua_iterloop``, ``seqlua_iterloopauto``, or +``seqlua_iterinit``, three extra elements are stored on the stack (additionally +to the value). These extra elements are removed automatically when the loop ends +(i.e. when ``seqlua_iternext`` returns zero). The value pushed onto the stack +for every iteration step has to be removed manually from the stack, unless +``seqlua_iterloopauto`` is used. + diff -r 367fc70acc15 -r 4fc9090ada1d seqlualib.c --- a/seqlualib.c Sat Aug 23 23:13:17 2014 +0200 +++ b/seqlualib.c Sat Aug 23 23:35:10 2014 +0200 @@ -20,8 +20,8 @@ luaL_getmetafield(L, idx, "__len") ) { lua_pop(L, 1); + iter->len = luaL_len(L, idx); iter->itertype = SEQLUA_ITERTYPE_INDEX; - iter->len = luaL_len(L, idx); } else { luaL_checktype(L, idx, LUA_TTABLE); iter->itertype = SEQLUA_ITERTYPE_RAW;