Add 'join' method for string
This commit is contained in:
1 parent
1925c90812
commit
ddf0203ad5
1 file changed
+14
+14
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user