| 92 | |
| 93 | |
| 94 | static int tconcat (lua_State *L) { |
| 95 | luaL_Buffer b; |
| 96 | size_t lsep; |
| 97 | int i, last; |
| 98 | const char *sep = luaL_optlstring(L, 2, "", &lsep); |
| 99 | luaL_checktype(L, 1, LUA_TTABLE); |
| 100 | i = luaL_optint(L, 3, 1); |
| 101 | last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1)); |
| 102 | luaL_buffinit(L, &b); |
| 103 | for (; i < last; i++) { |
| 104 | addfield(L, &b, i); |
| 105 | luaL_addlstring(&b, sep, lsep); |
| 106 | } |
| 107 | if (i == last) /* add last value (if interval was not empty) */ |
| 108 | addfield(L, &b, i); |
| 109 | luaL_pushresult(&b); |
| 110 | return 1; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | /* |
nothing calls this directly
no test coverage detected