From: Bruno Haible Date: Fri, 21 Apr 2017 13:41:54 +0000 (+0200) Subject: Fix test-mbrtowc5.sh failure on native Windows. X-Git-Tag: v1.0~6270 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=09352c508f8755345d4b67bf8e8a065c9fbd0ae0;p=gnulib.git Fix test-mbrtowc5.sh failure on native Windows. * lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for "C". --- diff --git a/ChangeLog b/ChangeLog index ff8b4e68a9..8840fca73c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-04-21 Bruno Haible + + 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 Avoid accidental use of native Windows APIs on Cygwin. diff --git a/lib/setlocale.c b/lib/setlocale.c index af8cc90b65..d2f203ed7a 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)