Skip to content

Commit

Permalink
Fix _setmode usage for stdout new-line conversion
Browse files Browse the repository at this point in the history
The previous fix didn't work in all situations. I suspect it's because
it was changing the state of the fd back to _O_TEXT mode without
synchronising with fflush(). Changing the mode back to _O_TEXT isn't
actually needed (see discussion in #56,) so just remove the call.
  • Loading branch information
rossy committed Aug 22, 2015
1 parent d20ea3c commit 6bae6bc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/zopfli/zopfli_bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,13 @@ static void CompressFile(const ZopfliOptions* options,
SaveFile(outfilename, out, outsize);
} else {
size_t i;
/* Windows workaround for stdout output. */
#if _WIN32
/* Windows workaround for stdout output. */
_setmode(_fileno(stdout), _O_BINARY);
#endif
for (i = 0; i < outsize; i++) {
/* Works only if terminal does not convert newlines. */
printf("%c", out[i]);
}
#if _WIN32
_setmode(_fileno(stdout), _O_TEXT);
#endif
}

free(out);
Expand Down

0 comments on commit 6bae6bc

Please sign in to comment.