summaryrefslogtreecommitdiff
path: root/src/basic/string-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-11-28 16:37:53 +0100
committerSven Eden <yamakuzure@gmx.net>2017-11-28 16:37:53 +0100
commit14728b9406dccbf6a74f21aaa1cc524273edbb15 (patch)
tree4fc519fe247975bf439aa82531799b18eb6de4de /src/basic/string-util.h
parent8a5a474e846f8810cb3861ed869da35db74f9a97 (diff)
string-util: rework strextend() to optionally inset separators between each appended string
This adds a new flavour of strextend(), called strextend_with_separator(), which takes an optional separator string. If specified, the separator is inserted between each appended string, as well as before the first one, but only if the original string was non-empty. This new call is particularly useful when appending new options to mount option strings and suchlike, which need to be comma-separated, and initially start out from an empty string.
Diffstat (limited to 'src/basic/string-util.h')
-rw-r--r--src/basic/string-util.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index f68b5f2f3..7276cfd6f 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -174,7 +174,9 @@ char *strreplace(const char *text, const char *old_string, const char *new_strin
char *strip_tab_ansi(char **p, size_t *l);
-char *strextend(char **x, ...) _sentinel_;
+char *strextend_with_separator(char **x, const char *separator, ...) _sentinel_;
+
+#define strextend(x, ...) strextend_with_separator(x, NULL, __VA_ARGS__)
char *strrep(const char *s, unsigned n);