changeset 18789:3f6f9c557296

Fix test-mbrtowc5.sh failure on native Windows. * lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for "C".
author Bruno Haible <bruno@clisp.org>
date Fri, 21 Apr 2017 15:41:54 +0200
parents 5c66611bdd66
children 55a3507c8342
files ChangeLog lib/setlocale.c
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 21 15:28:40 2017 +0200
+++ b/ChangeLog	Fri Apr 21 15:41:54 2017 +0200
@@ -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.
--- a/lib/setlocale.c	Fri Apr 21 15:28:40 2017 +0200
+++ b/lib/setlocale.c	Fri Apr 21 15:41:54 2017 +0200
@@ -633,6 +633,13 @@
   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)