84,92d83 < static void addfield (lua_State *L, luaL_Buffer *b, int i) { < lua_rawgeti(L, 1, i); < if (!lua_isstring(L, -1)) < luaL_error(L, "invalid value (%s) at index %d in table for " < LUA_QL("concat"), luaL_typename(L, -1), i); < luaL_addvalue(b); < } < < 94d84 < luaL_Buffer b; 96c86 < int i, last; --- > int i, last, n; 101,108c91,106 < luaL_buffinit(L, &b); < for (; i < last; i++) { < addfield(L, &b, i); < luaL_addlstring(&b, sep, lsep); < } < if (i == last) /* add last value (if interval was not empty) */ < addfield(L, &b, i); < luaL_pushresult(&b); --- > if (i>last) > lua_pushstring(L,""); > else { > lua_pushinteger(L,i); > lua_gettable(L,1); > n=1; > for (i++; i <= last; i++) { > lua_pushstring(L,sep); > lua_pushinteger(L,i); > lua_gettable(L,1); > n+=2; > if (i==last || lua_gettop(L)>LUA_MINSTACK-2) { > lua_concat(L,n); n=0; > } > } > }