diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-01-25 22:42:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-01-26 14:42:04 +0100 |
commit | d390f8ef2dc0cd041914d3c2fd3e1081605cbfc8 (patch) | |
tree | baea925afd20e984696718b5813c2441444184ab /src/basic/strv.c | |
parent | b2a81c0b524fee0a1713720462b6db5c302c3933 (diff) |
util: introduce fputs_with_space() and make use of it at various places
The call combines outputing a string with prefixing it with a space, optionally. This is useful to shorten the logic
for outputing lists of strings, that are space separated.
Diffstat (limited to 'src/basic/strv.c')
-rw-r--r-- | src/basic/strv.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/basic/strv.c b/src/basic/strv.c index dc5bafcf24..5532c53ad1 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -29,6 +29,7 @@ #include "alloc-util.h" #include "escape.h" #include "extract-word.h" +#include "fileio.h" #include "string-util.h" #include "strv.h" #include "util.h" @@ -879,25 +880,13 @@ int fputstrv(FILE *f, char **l, const char *separator, bool *space) { /* Like fputs(), but for strv, and with a less stupid argument order */ - if (!f) - f = stdout; - if (!separator) - separator = " "; if (!space) space = &b; STRV_FOREACH(s, l) { - if (*space) { - r = fputs(separator, f); - if (r < 0) - return r; - } - - r = fputs(*s, f); + r = fputs_with_space(f, *s, separator, space); if (r < 0) return r; - - *space = true; } return 0; |