]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext-runtime/intl/setlocale.c: Add fixes from gnulib.
authorBruno Haible <bruno@clisp.org>
Sat, 11 Aug 2018 15:35:51 +0000 (17:35 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 12 Aug 2018 14:33:10 +0000 (16:33 +0200)
2018-08-11  Bruno Haible  <bruno@clisp.org>

        setlocale: Trivial simplification.
        * lib/setlocale.c (setlocale_unixlike): Remove redundant #if.

2017-04-21  Bruno Haible  <bruno@clisp.org>

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

2016-03-22  Geert Janssens  <janssens-geert@telenet.be>

        setlocale: add "sv" to Windows language table
        * setlocale.c (language_table) [W32]: Add "sv".
        Reported in <https://savannah.gnu.org/bugs/?44588>.

2012-01-04  Bruno Haible  <bruno@clisp.org>

        Talk about "native Windows API", not "Win32".
        * setlocale.c: Update comments to mention native Windows.

gettext-runtime/intl/setlocale.c

index df1991825d60c6ac7af81f630fdaa345a226e7f2..edbce091a97f881aad8a6526bf7f07aaee32a9ac 100644 (file)
@@ -83,7 +83,7 @@ category_to_name (int category)
 
 # if defined _WIN32 && ! defined __CYGWIN__
 
-/* The native Win32 setlocale() function expects locale names of the form
+/* The native Windows setlocale() function expects locale names of the form
    "German" or "German_Germany" or "DEU", but not "de" or "de_DE".  We need
    to convert the names from the form with ISO 639 language code and ISO 3166
    country code to the form with English names or with three-letter identifier.
@@ -390,6 +390,7 @@ static const struct table_entry language_table[] =
     { "sq", "Albanian" },
     { "sr", "Serbian (Latin)" },
     { "sr@cyrillic", "SRB" }, /* Serbian (Cyrillic) */
+    { "sv", "Swedish" },
     { "sw", "Swahili" },
     { "syr", "Syriac" },
     { "ta", "Tamil" },
@@ -641,6 +642,11 @@ 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 (locale != NULL && strcmp (locale, "POSIX") == 0)
+    locale = "C";
+
   /* First, try setlocale with the original argument unchanged.  */
   result = setlocale (category, locale);
   if (result != NULL)