From 09352c508f8755345d4b67bf8e8a065c9fbd0ae0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 21 Apr 2017 15:41:54 +0200 Subject: [PATCH] Fix test-mbrtowc5.sh failure on native Windows. * lib/setlocale.c (setlocale_unixlike): Accept "POSIX" as an alias for "C". --- ChangeLog | 6 ++++++ lib/setlocale.c | 7 +++++++ 2 files changed, 13 insertions(+) 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) -- 2.39.5