From 446087ed7ab0c401f98b588cc334c163428a445b Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Mon, 4 Dec 2023 01:40:35 -0500 Subject: [PATCH] use binary mode for win files --- configure.ac | 2 +- src/pixz.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e867519..fee6b12 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_STRTOD AC_CHECK_FUNCS([memchr memmove memset strerror strtol sched_getaffinity sysconf - GetSystemInfo]) + GetSystemInfo _setmode]) AC_CHECK_HEADER([sys/endian.h], [ AC_CHECK_DECLS([htole64, le64toh], [], [], [ diff --git a/src/pixz.c b/src/pixz.c index f93e458..1f823cb 100644 --- a/src/pixz.c +++ b/src/pixz.c @@ -164,6 +164,12 @@ int main(int argc, char **argv) { } } +#ifdef HAVE__SETMODE + // Set files to binary encoding + _setmode(_fileno(gInFile), O_BINARY); + _setmode(_fileno(gOutFile), O_BINARY); +#endif + switch (op) { case OP_WRITE: if (isatty(fileno(gOutFile)) == 1)