mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-06 17:52:54 +03:00
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:
1 parent
d52de2b8e9
commit
23c60dee6f
1 file changed
+2
-2
+2
-2
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user