* src/SDCClrange.c (findPrevUse): fixed bug 1888147
[fw/sdcc] / support / makebin / makebin.c
index deb4e78febf8e8534d8c91066ff0cd7876343fb3..83d4ec6990991627f4fd0a36cbfd6f1a230e881d 100644 (file)
@@ -3,6 +3,13 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <string.h>
+
+#if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__CYGWIN__)
+  #include <fcntl.h>
+  #include <io.h>
+#endif
+
 
 typedef unsigned char BYTE;
 
@@ -29,6 +36,14 @@ void usage(void)
           "Usage: makebin [-p] [-s romsize] [-h]\n");
 }
 
+void fixStdout(void)
+{
+  #if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__CYGWIN__)
+    setmode(fileno(stdout), O_BINARY);
+  #endif
+}
+
+
 int main(int argc, char **argv)
 {
     int size = 32768, pack = 0, real_size = 0;
@@ -39,6 +54,8 @@ int main(int argc, char **argv)
     argc--;
     argv++;
 
+    fixStdout();
+    
     while (argc--) {
         if (**argv != '-') {
             usage();