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
committerLennart Poettering <lennart@poettering.net>2017-12-05 13:49:12 +0100
commitbb8ad9eacaaf08078ad08e289c4cef08c7c38663 (patch)
treefb03ac6998d850aea41debd76d37e54bf10436b3 /src/basic/string-util.h
parent1cfdbe293f0e6266fc63bd807393f0813b8119f0 (diff)
downloadsystemd-bb8ad9eacaaf08078ad08e289c4cef08c7c38663.tar.gz
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 684af0f3e4..09a737ad37 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -179,7 +179,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);