| 167 | |
| 168 | |
| 169 | static int tconcat (lua_State *L) { |
| 170 | luaL_Buffer b; |
| 171 | lua_Integer last = aux_getn(L, 1, TAB_R); |
| 172 | size_t lsep; |
| 173 | const char *sep = luaL_optlstring(L, 2, "", &lsep); |
| 174 | lua_Integer i = luaL_optinteger(L, 3, 1); |
| 175 | last = luaL_optinteger(L, 4, last); |
| 176 | luaL_buffinit(L, &b); |
| 177 | for (; i < last; i++) { |
| 178 | addfield(L, &b, i); |
| 179 | luaL_addlstring(&b, sep, lsep); |
| 180 | } |
| 181 | if (i == last) /* add last value (if interval was not empty) */ |
| 182 | addfield(L, &b, i); |
| 183 | luaL_pushresult(&b); |
| 184 | return 1; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | /* |
nothing calls this directly
no test coverage detected