[glib] glib/tests/fileutils.c: Include unistd.h on *NIX only



commit 1079d30e1b5b9002ca5d4e5bef398e855a7c115f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Nov 4 12:23:30 2013 +0800

    glib/tests/fileutils.c: Include unistd.h on *NIX only
    
    ...and fix the test on non-English Windows, as gettext on Windows does
    not honor LC_ALL = "C" (the default CRT behavior) but requires using
    SetThreadLocale() to set the locale as it picks up the user's environment
    and the thread's locale.  Without doing so the g_format_size_for_display()
    et al will display the translated message if the gettext translations have
    been installed before, causing the test_format_size_for_display tests to
    fail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711047

 glib/tests/fileutils.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index be9acdb..5ac5340 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -20,7 +20,6 @@
  */
 
 #include <string.h>
-#include <unistd.h>
 #include <errno.h>
 
 /* We are testing some deprecated APIs here */
@@ -29,6 +28,13 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
+
 #define S G_DIR_SEPARATOR_S
 
 static void
@@ -496,6 +502,9 @@ test_mkdir_with_parents (void)
 static void
 test_format_size_for_display (void)
 {
+#ifdef G_OS_WIN32
+  SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
+#endif
   /* nobody called setlocale(), so we should get "C" behaviour... */
   check_string (g_format_size_for_display (0), "0 bytes");
   check_string (g_format_size_for_display (1), "1 byte");


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