From 6bae6bcad828cd3ed7a56bc3d3e98de6d0eba5ac Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sat, 22 Aug 2015 11:32:54 +1000 Subject: [PATCH] Fix _setmode usage for stdout new-line conversion 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. --- src/zopfli/zopfli_bin.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/zopfli/zopfli_bin.c b/src/zopfli/zopfli_bin.c index 747828db..b8db66e8 100644 --- a/src/zopfli/zopfli_bin.c +++ b/src/zopfli/zopfli_bin.c @@ -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);