]> sigrok.org Git - sigrok-cli.git/commitdiff
Set stdout to binary mode on Windows as needed
authorDevan Lai <redacted>
Fri, 11 Oct 2019 03:16:01 +0000 (20:16 -0700)
committerUwe Hermann <redacted>
Sat, 9 Nov 2019 17:28:26 +0000 (18:28 +0100)
On Windows, stdout defaults to text mode, which attempts to perform
newline conversion such that if it sees a bare line feed (hex 0A),
it will insert a carriage return (hex 0D) before the line feed.

For textual output like normal annotation display or ASCII art, this is
desirable, but for binary output, this is likely to garble the output.

On Windows when using stdout as the output file destination or when
using the -B/--protocol-decoder-binary option, change the mode of stdout
to _O_BINARY to disable this newline conversion to ensure that the
binary output is faithfully delivered to stdout without modifications.

On all other platforms, setup_binary_stdout() is a no-op.

This fixes the original issue in bug #1427.

Further follow-up work might be needed to fix the reverse behavior that is
introduced by this change - now textual output sent to stdout on Windows
will only have Unix style line endings, rather than being converted to
Windows style line endings.


No differences found