Fix test file comparisons on MinGW
authorPetri Lehtinen <petri@digip.org>
Tue, 1 Nov 2011 17:52:20 +0000 (19:52 +0200)
committerPetri Lehtinen <petri@digip.org>
Tue, 1 Nov 2011 18:49:52 +0000 (20:49 +0200)
Don't output any DOS line terminators from json_process.

Issue GH-39.

test/bin/json_process.c

index 66c34d1..4ec22e6 100644 (file)
 #include <locale.h>
 #endif
 
+#if _WIN32
+#include <io.h>  /* for _setmode() */
+#include <fcntl.h>  /* for _O_BINARY */
+#endif
+
 static int getenv_int(const char *name)
 {
     char *value, *end;
@@ -72,6 +77,13 @@ int main(int argc, char *argv[])
         return 2;
     }
 
+#ifdef _WIN32
+    /* On Windows, set stdout and stderr to binary mode to avoid
+       outputting DOS line terminators */
+    _setmode(_fileno(stdout), _O_BINARY);
+    _setmode(_fileno(stderr), _O_BINARY);
+#endif
+
     indent = getenv_int("JSON_INDENT");
     if(indent < 0 || indent > 255) {
         fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent);