client.c: remove trailing newline from output for '-o -'

The CLI option '-o file' redirects the received payload into the
given file, where '-' denotes stdout. As the function close_output()
used to append a newline to the end of the output, certain tools
such as cbor2pretty.rb have failed, complaining about the trailing
character.

This change now writes the newline if only if option '-o' was not
specified.
This commit is contained in:
Olaf Bergmann committed 2018-12-20 17:57:16 +01:00
1 parent d52de2b8e9
commit 23c60dee6f
1 file changed
+2 -2
+2 -2
View File
@@ -129,8 +129,8 @@ static void
close_output(void) {
if (file) {
/* add a newline before closing in case were writing to stdout */
if (!output_file.s || (output_file.length && output_file.s[0] == '-'))
/* add a newline before closing if no option '-o' was specified */
if (!output_file.s)
fwrite("\n", 1, 1, file);
fflush(file);