[glib: 1/8] testsuite: use binary mode for stdout on Windows



commit fb37239b20e7ec5be77c847950a0f3c72fbbed88
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Fri Feb 8 20:15:19 2019 +0000

    testsuite: use binary mode for stdout on Windows
    
    It's much easier than adjusting the test logic to account for the extra \r.

 glib/tests/testing-helper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/glib/tests/testing-helper.c b/glib/tests/testing-helper.c
index 43127e8dd..b0e1f4a98 100644
--- a/glib/tests/testing-helper.c
+++ b/glib/tests/testing-helper.c
@@ -17,6 +17,11 @@
  */
 
 #include <glib.h>
+#ifdef G_OS_WIN32
+#include <fcntl.h>
+#include <io.h>
+#include <stdio.h>
+#endif
 
 static void
 test_pass (void)
@@ -47,6 +52,14 @@ main (int   argc,
 {
   char *argv1;
 
+#ifdef G_OS_WIN32
+  /* Windows opens std streams in text mode, with \r\n EOLs.
+   * Sometimes it's easier to force a switch to binary mode than
+   * to account for extra \r in testcases.
+   */
+  setmode (fileno (stdout), O_BINARY);
+#endif
+
   g_return_val_if_fail (argc > 1, 1);
   argv1 = argv[1];
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]