From 26f7c43a55d4357a8d69120be31bca6d691fac9a Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Mon, 29 Jan 2024 22:14:59 +0100 Subject: [PATCH] fixup! base64: windows: ensure stdout is binary-clean --- bin/base64.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/base64.c b/bin/base64.c index f411369..77508c8 100644 --- a/bin/base64.c +++ b/bin/base64.c @@ -319,15 +319,6 @@ encode (const struct config *config, struct buffer *buf) size_t nread, nout; struct base64_state state; -#ifdef WIN - - // On Windows platforms, ensure that stdout is binary-clean, and - // newlines at the end of the line are not silently converted to CRLFs. - // This seems to be the portable way to do it. freopen() and - // SetConsoleMode() occasionally result in permission errors. - _setmode(1, _O_BINARY); -#endif - // Initialize the encoder's state structure. base64_stream_encode_init(&state, 0); @@ -658,6 +649,15 @@ main (int argc, char **argv) return 1; } +#ifdef WIN + + // On Windows platforms, ensure that stdout is binary-clean, and + // newlines at the end of the line are not silently converted to CRLFs. + // This seems to be the portable way to do it. freopen() and + // SetConsoleMode() occasionally result in permission errors. + _setmode(1, _O_BINARY); +#endif + // Encode or decode the input based on the user's choice. const bool ret = config.decode ? decode(&config, &buf)