test-mbrtowc5.sh fails on native Windows: The mingw or MSVC setlocale()
understands the special locale name "C", but not the special locale name
"POSIX". This fixes it.


2017-04-21  Bruno Haible  <[email protected]>

        Fix test-mbrtowc5.sh failure on native Windows.
        * lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for
        "C".

diff --git a/lib/setlocale.c b/lib/setlocale.c
index af8cc90..d2f203e 100644
--- a/lib/setlocale.c
+++ b/lib/setlocale.c
@@ -633,6 +633,13 @@ setlocale_unixlike (int category, const char *locale)
   char ll_buf[64];
   char CC_buf[64];
 
+  /* The native Windows implementation of setlocale understands the special
+     locale name "C", but not "POSIX".  Therefore map "POSIX" to "C".  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  if (locale != NULL && strcmp (locale, "POSIX") == 0)
+    locale = "C";
+#endif
+
   /* First, try setlocale with the original argument unchanged.  */
   result = setlocale (category, locale);
   if (result != NULL)


Reply via email to