fileio: fputs_with_space → _with_separator and modernization
This commit is contained in:
+16
-18
@@ -1327,33 +1327,31 @@ int read_timestamp_file(const char *fn, usec_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fputs_with_space(FILE *f, const char *s, const char *separator, bool *space) {
|
||||
int r;
|
||||
|
||||
int fputs_with_separator(FILE *f, const char *s, const char *separator, bool *space) {
|
||||
assert(s);
|
||||
assert(space);
|
||||
|
||||
/* Outputs the specified string with fputs(), but optionally prefixes it with a separator. The *space parameter
|
||||
* when specified shall initially point to a boolean variable initialized to false. It is set to true after the
|
||||
* first invocation. This call is supposed to be use in loops, where a separator shall be inserted between each
|
||||
* element, but not before the first one. */
|
||||
/* Outputs the specified string with fputs(), but optionally prefixes it with a separator.
|
||||
* The *space parameter when specified shall initially point to a boolean variable initialized
|
||||
* to false. It is set to true after the first invocation. This call is supposed to be use in loops,
|
||||
* where a separator shall be inserted between each element, but not before the first one. */
|
||||
|
||||
if (!f)
|
||||
f = stdout;
|
||||
|
||||
if (space) {
|
||||
if (!separator)
|
||||
separator = " ";
|
||||
if (!separator)
|
||||
separator = " ";
|
||||
|
||||
if (*space) {
|
||||
r = fputs(separator, f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (*space)
|
||||
if (fputs(separator, f) < 0)
|
||||
return -EIO;
|
||||
|
||||
*space = true;
|
||||
}
|
||||
*space = true;
|
||||
|
||||
return fputs(s, f);
|
||||
if (fputs(s, f) < 0)
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* A bitmask of the EOL markers we know */
|
||||
|
||||
Reference in New Issue
Block a user