Skip to content

Commit

Permalink
fixup! base64: windows: ensure stdout is binary-clean
Browse files Browse the repository at this point in the history
  • Loading branch information
aklomp committed Jan 29, 2024
1 parent 469475a commit 26f7c43
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/base64.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 26f7c43

Please sign in to comment.