:: commit a3cce64543e48971469108f936505209765a6a30

tansy <40426919+tansy@users.noreply.github.com> — 2022-05-16 05:50

parents: 0766547508

set binary mode for standard in/output (#28)

diff --git a/src/main.c b/src/main.c
index e42cdeb..f2dc921 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,12 +18,17 @@
  */
 
 #include <ctype.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#if defined __MSVCRT__
+  #include <fcntl.h>
+  #include <io.h>
+#endif
 
 #include "common.h"
 #include "libbz3.h"
@@ -146,6 +151,13 @@ int main(int argc, char * argv[]) {
 #endif
         return args_status;
     }
+    #ifndef O_BINARY
+		#define O_BINARY 0
+    #endif
+    #if defined(__MSVCRT__)
+		setmode(STDIN_FILENO, O_BINARY);
+		setmode(STDOUT_FILENO, O_BINARY);
+    #endif
 
     if (mode != 2) {
         if (no_bz3_suffix || mode == 1) {
tab: 248 wrap: offon