Add 'join' method for string

This commit is contained in:
Patrick Pelissier committed 2017-05-03 22:51:22 +02:00
1 parent 1925c90812
commit ddf0203ad5
1 file changed
+14
+14
View File
@@ -696,6 +696,20 @@ string_in_str(string_t v, FILE *f)
/* inserted the items in the wrong order (aka for a list) */ \
M_IF_METHOD(REVERSE, oplist) (M_GET_REVERSE oplist (cont);, ) \
string_clear(tmp); \
} \
\
static inline void M_C(name, _join)(string_t dst, M_GET_TYPE oplist cont, \
const string_t str) \
{ \
bool init_done = false; \
string_clean (dst); \
for M_EACH(item, cont, oplist) { \
if (init_done) { \
string_cat(dst, str); \
} \
string_cat (dst, *item); \
init_done = true; \
} \
} \
/* Use of Compound Literals to init a constant string.