Skip to content

Commit 6bae6bc

Browse files
committed
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.
1 parent d20ea3c commit 6bae6bc

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/zopfli/zopfli_bin.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,13 @@ static void CompressFile(const ZopfliOptions* options,
112112
SaveFile(outfilename, out, outsize);
113113
} else {
114114
size_t i;
115-
/* Windows workaround for stdout output. */
116115
#if _WIN32
116+
/* Windows workaround for stdout output. */
117117
_setmode(_fileno(stdout), _O_BINARY);
118118
#endif
119119
for (i = 0; i < outsize; i++) {
120-
/* Works only if terminal does not convert newlines. */
121120
printf("%c", out[i]);
122121
}
123-
#if _WIN32
124-
_setmode(_fileno(stdout), _O_TEXT);
125-
#endif
126122
}
127123

128124
free(out);

0 commit comments

Comments
 (0)