From 23c60dee6fffd6d4748fbdd790f534e634343eff Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Thu, 20 Dec 2018 17:57:16 +0100 Subject: [PATCH] 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. --- examples/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/client.c b/examples/client.c index 4f842929..bac3d06b 100644 --- a/examples/client.c +++ b/examples/client.c @@ -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);