diff options
| author | Simon Tatham <anakin@pobox.com> | 2012-06-03 20:51:47 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2012-06-03 20:51:47 +0000 |
| commit | 2de31b3b4b575ff35f63ef71433d649ed6390c3c (patch) | |
| tree | c201448ff381ce42076337032eb94ce9327a5df4 | |
| parent | ea4654d03324dd4feba49d616cbf13b4d6b808c6 (diff) | |
| download | halibut-2de31b3b4b575ff35f63ef71433d649ed6390c3c.zip halibut-2de31b3b4b575ff35f63ef71433d649ed6390c3c.tar.gz halibut-2de31b3b4b575ff35f63ef71433d649ed6390c3c.tar.bz2 halibut-2de31b3b4b575ff35f63ef71433d649ed6390c3c.tar.xz | |
Patch from Maciej Adamczyk to set standard output to binary mode in
the standalone deflate utility modes, so you can redirect output to a
file and end up with correct data in that file.
[originally from svn r9552]
| -rw-r--r-- | deflate.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -2601,6 +2601,15 @@ const char *const deflate_error_sym[DEFLATE_NUM_ERRORS] = { }; #undef A +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) +#define WINDOWS_IO +#endif + +#if defined(WINDOWS_IO) && (defined(STANDALONE) || defined(TESTMODE)) +#include <fcntl.h> +#include <io.h> +#endif + #ifdef STANDALONE int main(int argc, char **argv) @@ -2676,6 +2685,14 @@ int main(int argc, char **argv) fprintf(stderr, "unable to open '%s'\n", filename); return 1; } + +#ifdef WINDOWS_IO + if(_setmode(_fileno(stdout), _O_BINARY ) == -1) + { + fprintf(stderr, "Can't set stdout to binary mode\n"); + return 1; + } +#endif do { ret = fread(buf, 1, sizeof(buf), fp); @@ -2764,6 +2781,14 @@ int main(int argc, char **argv) chandle = deflate_compress_new(DEFLATE_TYPE_ZLIB); dhandle = deflate_decompress_new(DEFLATE_TYPE_ZLIB); + +#ifdef WINDOWS_IO + if(_setmode(_fileno(stdout), _O_BINARY ) == -1) + { + fprintf(stderr, "Can't set stdout to binary mode\n"); + return 1; + } +#endif do { ret = fread(buf, 1, sizeof(buf), fp); |