]> Savannah Git Hosting - gnulib.git/commitdiff
Fix test-mbrtowc5.sh failure on native Windows.
authorBruno Haible <bruno@clisp.org>
Fri, 21 Apr 2017 13:41:54 +0000 (15:41 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 21 Apr 2017 13:41:54 +0000 (15:41 +0200)
* lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for
"C".

ChangeLog
lib/setlocale.c

index ff8b4e68a90fd2d3361dde3faacf08c3ea83596e..8840fca73c8ddd984915b6b0fe7477b9abaab3d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-21  Bruno Haible  <bruno@clisp.org>
+
+       Fix test-mbrtowc5.sh failure on native Windows.
+       * lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for
+       "C".
+
 2017-04-21  Bruno Haible  <bruno@clisp.org>
 
        Avoid accidental use of native Windows APIs on Cygwin.
index af8cc90b6527dc9678e2c2e2900c9d293053e830..d2f203ed7a69b81cb26f948ec5805145001ac0fe 100644 (file)
@@ -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)