From de86fc8c82b0ccaeb6acde6a27f6e6b7f54a489d Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sun, 1 Jun 2008 17:28:44 -0700 Subject: [PATCH] Reopen stdout in binary mode for -O -. --- src/ChangeLog | 5 +++++ src/main.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index d82f1fcd..49c8506c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-06-01 Micah Cowan + + * main.c [WINDOWS]: Reopen stdout in binary mode, when -O - is + given. + 2008-05-31 Micah Cowan * html-url.c, http.c: Avoid casts in a couple spots. diff --git a/src/main.c b/src/main.c index 009aa5e6..28b04b30 100644 --- a/src/main.c +++ b/src/main.c @@ -991,7 +991,19 @@ for details.\n\n")); if (opt.output_document) { if (HYPHENP (opt.output_document)) - output_stream = stdout; + { +#ifdef WINDOWS + FILE *result; + result = freopen (NULL, "wb", stdout); + if (result == NULL) + { + logputs (LOG_NOTQUIET, _("\ +WARNING: Can't reopen standard output in binary mode;\n\ + downloaded file may contain inappropriate line endings.\n")); + } +#endif + output_stream = stdout; + } else { struct_fstat st;