seqlua
changeset 31:4fc9090ada1d
Mention 3 extra elements on stack in README; Changed order of two instructions in seqlualib.c
author | jbe |
---|---|
date | Sat Aug 23 23:35:10 2014 +0200 (2014-08-23) |
parents | 367fc70acc15 |
children | 3ff7cec8d3ce |
files | README seqlualib.c |
line diff
1.1 --- a/README Sat Aug 23 23:13:17 2014 +0200 1.2 +++ b/README Sat Aug 23 23:35:10 2014 +0200 1.3 @@ -133,4 +133,11 @@ 1.4 printcsv(assert(io.open("testfile")):lines()) 1.5 -- prints: line1,line2,... of "testfile" 1.6 1.7 +NOTE: During iteration using ``seqlua_iterloop``, ``seqlua_iterloopauto``, or 1.8 +``seqlua_iterinit``, three extra elements are stored on the stack (additionally 1.9 +to the value). These extra elements are removed automatically when the loop ends 1.10 +(i.e. when ``seqlua_iternext`` returns zero). The value pushed onto the stack 1.11 +for every iteration step has to be removed manually from the stack, unless 1.12 +``seqlua_iterloopauto`` is used. 1.13 1.14 +
2.1 --- a/seqlualib.c Sat Aug 23 23:13:17 2014 +0200 2.2 +++ b/seqlualib.c Sat Aug 23 23:35:10 2014 +0200 2.3 @@ -20,8 +20,8 @@ 2.4 luaL_getmetafield(L, idx, "__len") 2.5 ) { 2.6 lua_pop(L, 1); 2.7 + iter->len = luaL_len(L, idx); 2.8 iter->itertype = SEQLUA_ITERTYPE_INDEX; 2.9 - iter->len = luaL_len(L, idx); 2.10 } else { 2.11 luaL_checktype(L, idx, LUA_TTABLE); 2.12 iter->itertype = SEQLUA_ITERTYPE_RAW;