join_strv() -> strv_join(), take a string argument

This commit is contained in:
Přemysl Eric Janouch 2017-01-23 23:03:46 +01:00
parent 5552ce1dbe
commit 349a0fc3b1
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -2957,7 +2957,7 @@ cstr_cut_until (const char *s, const char *alphabet)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static char * static char *
join_strv (const struct strv *v, char delimiter) strv_join (const struct strv *v, const char *delimiter)
{ {
if (!v->len) if (!v->len)
return xstrdup (""); return xstrdup ("");
@ -2966,7 +2966,7 @@ join_strv (const struct strv *v, char delimiter)
str_init (&result); str_init (&result);
str_append (&result, v->vector[0]); str_append (&result, v->vector[0]);
for (size_t i = 1; i < v->len; i++) for (size_t i = 1; i < v->len; i++)
str_append_printf (&result, "%c%s", delimiter, v->vector[i]); str_append_printf (&result, "%s%s", delimiter, v->vector[i]);
return str_steal (&result); return str_steal (&result);
} }