summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@solidstatenetworks.com>2020-05-15 13:22:49 -0400
committerHans Kristian Rosbach <hk-github@circlestorm.org>2020-05-25 16:13:36 +0200
commit411fc07589eb4812390481eb12b2ef5eb8891998 (patch)
treefb3bd24f48a9eeac1171324f465118c69dde2d80 /test
parent7a107a1bc626406efe8c970ef53b5af68609bfe2 (diff)
downloadProject-Tick-411fc07589eb4812390481eb12b2ef5eb8891998.tar.gz
Project-Tick-411fc07589eb4812390481eb12b2ef5eb8891998.zip
Set binary mode for stdin and stdout in switchlevels.
Diffstat (limited to 'test')
-rw-r--r--test/switchlevels.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/switchlevels.c b/test/switchlevels.c
index 5c4770f8cd..f991a838cb 100644
--- a/test/switchlevels.c
+++ b/test/switchlevels.c
@@ -13,6 +13,14 @@
#include <stdlib.h>
#include <string.h>
+#if defined(WIN32) || defined(__CYGWIN__)
+# include <fcntl.h>
+# include <io.h>
+# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
+#else
+# define SET_BINARY_MODE(file)
+#endif
+
static int read_all(unsigned char *buf, size_t size) {
for (size_t total_read = 0; total_read < size;) {
size_t n_read = fread(buf + total_read, 1, size - total_read, stdin);
@@ -87,6 +95,8 @@ done:
int main(int argc, char **argv) {
int ret = EXIT_FAILURE;
PREFIX3(stream) strm;
+ SET_BINARY_MODE(stdin);
+ SET_BINARY_MODE(stdout);
memset(&strm, 0, sizeof(strm));
int err = PREFIX(deflateInit2)(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY);
if (err != Z_OK) {