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