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)