Update from gnulib.
diff --git a/libcharset/ChangeLog b/libcharset/ChangeLog
index e71236b..638f43d 100644
--- a/libcharset/ChangeLog
+++ b/libcharset/ChangeLog
@@ -1,3 +1,14 @@
+2019-12-22  Bruno Haible  <bruno@clisp.org>
+
+	Update from gnulib.
+	* include/localcharset.h.in: Update from gnulib.
+	2019-12-20  Bruno Haible  <bruno@clisp.org>
+		* localcharset.h: Mention which encodings are used as locale
+		encodings on z/OS.
+	2019-12-17  Bruno Haible  <bruno@clisp.org>
+		* localcharset.h (locale_charset): Clarify when the result
+		becomes invalid.
+
 2019-12-02  Bruno Haible  <bruno@clisp.org>
 
 	build: Fix build error with --enable-relocatable on macOS
diff --git a/libcharset/include/localcharset.h.in b/libcharset/include/localcharset.h.in
index e6f2627..f6f3938 100644
--- a/libcharset/include/localcharset.h.in
+++ b/libcharset/include/localcharset.h.in
@@ -1,5 +1,5 @@
 /* Determine a canonical name for the current locale's character encoding.
-   Copyright (C) 2000-2003, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
    This file is part of the GNU CHARSET Library.
 
    This program is free software; you can redistribute it and/or modify it
@@ -26,7 +26,10 @@
 
 /* Determine the current locale's character encoding, and canonicalize it
    into one of the canonical names listed below.
-   The result must not be freed; it is statically allocated.
+   The result must not be freed; it is statically allocated.  The result
+   becomes invalid when setlocale() is used to change the global locale, or
+   when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
+   is changed; threads in multithreaded programs should not do this.
    If the canonical name cannot be determined, the result is a non-canonical
    name.  */
 extern const char * locale_charset (void);
@@ -45,15 +48,15 @@
                                     (darwin = Mac OS X, windows = native Windows)
 
    ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin minix cygwin
-   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
-   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
+   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
    ISO-8859-3              Y   glibc solaris cygwin
    ISO-8859-4              Y   hpux osf solaris freebsd netbsd openbsd darwin
-   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
    ISO-8859-6              Y   glibc aix hpux solaris cygwin
-   ISO-8859-7              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
-   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin
-   ISO-8859-9              Y   glibc aix hpux irix osf solaris freebsd darwin cygwin
+   ISO-8859-7              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
+   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin zos
+   ISO-8859-9              Y   glibc aix hpux irix osf solaris freebsd darwin cygwin zos
    ISO-8859-13                 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
    ISO-8859-14                 glibc cygwin
    ISO-8859-15                 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
@@ -76,7 +79,7 @@
    CP874                       windows dos
    CP922                       aix
    CP932                       aix cygwin windows dos
-   CP943                       aix
+   CP943                       aix zos
    CP949                       osf darwin windows dos
    CP950                       windows dos
    CP1046                      aix
@@ -92,17 +95,17 @@
    CP1255                      glibc windows
    CP1256                      windows
    CP1257                      windows
-   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin cygwin
+   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
    EUC-JP                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
-   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
    EUC-TW                      glibc aix hpux irix osf solaris netbsd
-   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin
+   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
    BIG5-HKSCS                  glibc hpux solaris netbsd darwin
    GBK                         glibc aix osf solaris freebsd darwin cygwin windows dos
    GB18030                     glibc hpux solaris freebsd netbsd darwin
    SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
    JOHAB                       glibc solaris windows
-   TIS-620                     glibc aix hpux osf solaris cygwin
+   TIS-620                     glibc aix hpux osf solaris cygwin zos
    VISCII                  Y   glibc
    TCVN5712-1                  glibc
    ARMSCII-8                   glibc freebsd netbsd darwin
@@ -116,7 +119,7 @@
    HP-KANA8                    hpux
    DEC-KANJI                   osf
    DEC-HANYU                   osf
-   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin
+   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin zos
 
    Note: Names which are not marked as being a MIME name should not be used in
    Internet protocols for information interchange (mail, news, etc.).
diff --git a/libcharset/lib/ChangeLog b/libcharset/lib/ChangeLog
index 2e08f78..5d57f1d 100644
--- a/libcharset/lib/ChangeLog
+++ b/libcharset/lib/ChangeLog
@@ -1,3 +1,21 @@
+2019-12-22  Bruno Haible  <bruno@clisp.org>
+
+	Update from gnulib.
+	2019-12-22  Bruno Haible  <bruno@clisp.org>
+		localcharset: Update support for OpenBSD.
+		* localcharset.c (alias_table): Map "US-ASCII" to "ASCII".
+	2019-12-17  Bruno Haible  <bruno@clisp.org>
+		localcharset: Fix multithread-safety bug on Windows and OS/2.
+		* localcharset.c (locale_charset): Use a stack-allocated buffer
+		to assemble the result.
+	2019-12-17  Bruno Haible  <bruno@clisp.org>
+		localcharset: Optimize code for native Windows.
+		* localcharset.c (locale_charset): Don't bother calling
+		setlocale (LC_ALL, NULL) since we're not interested in its
+		result.
+	2019-09-23  Paul Eggert  <eggert@cs.ucla.edu>
+		Update URLs and associated text
+
 2019-08-11  Bruno Haible  <bruno@clisp.org>
 
 	Update from gnulib.
diff --git a/libcharset/lib/localcharset.c b/libcharset/lib/localcharset.c
index 8b2750f..fdef2a3 100644
--- a/libcharset/lib/localcharset.c
+++ b/libcharset/lib/localcharset.c
@@ -150,7 +150,8 @@
     { "ISO8859-2",  "ISO-8859-2" },
     { "ISO8859-4",  "ISO-8859-4" },
     { "ISO8859-5",  "ISO-8859-5" },
-    { "ISO8859-7",  "ISO-8859-7" }
+    { "ISO8859-7",  "ISO-8859-7" },
+    { "US-ASCII",   "ASCII" }
 #   define alias_table_defined
 #  endif
 #  if defined __APPLE__ && defined __MACH__                 /* Mac OS X */
@@ -378,8 +379,6 @@
        by Alex Taylor:
        <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
        See also "__convcp() of kLIBC":
-       <http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/src/lib/locale/__convcp.c>,
-       or:
        <https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>.  */
     { "CP1004",        "CP1252" },
   /*{ "CP1041",        "CP943" },*/
@@ -814,8 +813,11 @@
 
 
 /* Determine the current locale's character encoding, and canonicalize it
-   into one of the canonical names listed in localcharset.h.
-   The result must not be freed; it is statically allocated.
+   into one of the canonical names listed below.
+   The result must not be freed; it is statically allocated.  The result
+   becomes invalid when setlocale() is used to change the global locale, or
+   when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
+   is changed; threads in multithreaded programs should not do this.
    If the canonical name cannot be determined, the result is a non-canonical
    name.  */
 
@@ -827,6 +829,13 @@
 {
   const char *codeset;
 
+  /* This function must be multithread-safe.  To achieve this without using
+     thread-local storage, we use a simple strcpy or memcpy to fill this static
+     buffer.  Filling it through, for example, strcpy + strcat would not be
+     guaranteed to leave the buffer's contents intact if another thread is
+     currently accessing it.  If necessary, the contents is first assembled in
+     a stack-allocated buffer.  */
+
 #if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
 
 # if HAVE_LANGINFO_CODESET
@@ -841,7 +850,7 @@
   if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
     {
       const char *locale;
-      static char buf[2 + 10 + 1];
+      static char resultbuf[2 + 10 + 1];
 
       locale = getenv ("LC_ALL");
       if (locale == NULL || locale[0] == '\0')
@@ -865,11 +874,12 @@
               modifier = strchr (dot, '@');
               if (modifier == NULL)
                 return dot;
-              if (modifier - dot < sizeof (buf))
+              if (modifier - dot < sizeof (resultbuf))
                 {
-                  memcpy (buf, dot, modifier - dot);
-                  buf [modifier - dot] = '\0';
-                  return buf;
+                  /* This way of filling resultbuf is multithread-safe.  */
+                  memcpy (resultbuf, dot, modifier - dot);
+                  resultbuf [modifier - dot] = '\0';
+                  return resultbuf;
                 }
             }
         }
@@ -885,8 +895,13 @@
          converting to GetConsoleOutputCP().  This leads to correct results,
          except when SetConsoleOutputCP has been called and a raster font is
          in use.  */
-      sprintf (buf, "CP%u", GetACP ());
-      codeset = buf;
+      {
+        char buf[2 + 10 + 1];
+
+        sprintf (buf, "CP%u", GetACP ());
+        strcpy (resultbuf, buf);
+        codeset = resultbuf;
+      }
     }
 #  endif
 
@@ -896,34 +911,28 @@
 
 # elif defined WINDOWS_NATIVE
 
-  static char buf[2 + 10 + 1];
+  char buf[2 + 10 + 1];
+  static char resultbuf[2 + 10 + 1];
 
   /* The Windows API has a function returning the locale's codepage as
      a number, but the value doesn't change according to what the
      'setlocale' call specified.  So we use it as a last resort, in
      case the string returned by 'setlocale' doesn't specify the
      codepage.  */
-  char *current_locale = setlocale (LC_ALL, NULL);
-  char *pdot;
+  char *current_locale = setlocale (LC_CTYPE, NULL);
+  char *pdot = strrchr (current_locale, '.');
 
-  /* If they set different locales for different categories,
-     'setlocale' will return a semi-colon separated list of locale
-     values.  To make sure we use the correct one, we choose LC_CTYPE.  */
-  if (strchr (current_locale, ';'))
-    current_locale = setlocale (LC_CTYPE, NULL);
-
-  pdot = strrchr (current_locale, '.');
   if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
     sprintf (buf, "CP%s", pdot + 1);
   else
     {
       /* The Windows API has a function returning the locale's codepage as a
-        number: GetACP().
-        When the output goes to a console window, it needs to be provided in
-        GetOEMCP() encoding if the console is using a raster font, or in
-        GetConsoleOutputCP() encoding if it is using a TrueType font.
-        But in GUI programs and for output sent to files and pipes, GetACP()
-        encoding is the best bet.  */
+         number: GetACP().
+         When the output goes to a console window, it needs to be provided in
+         GetOEMCP() encoding if the console is using a raster font, or in
+         GetConsoleOutputCP() encoding if it is using a TrueType font.
+         But in GUI programs and for output sent to files and pipes, GetACP()
+         encoding is the best bet.  */
       sprintf (buf, "CP%u", GetACP ());
     }
   /* For a locale name such as "French_France.65001", in Windows 10,
@@ -931,12 +940,15 @@
   if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
     codeset = "UTF-8";
   else
-    codeset = buf;
+    {
+      strcpy (resultbuf, buf);
+      codeset = resultbuf;
+    }
 
 # elif defined OS2
 
   const char *locale;
-  static char buf[2 + 10 + 1];
+  static char resultbuf[2 + 10 + 1];
   ULONG cp[3];
   ULONG cplen;
 
@@ -965,11 +977,12 @@
           modifier = strchr (dot, '@');
           if (modifier == NULL)
             return dot;
-          if (modifier - dot < sizeof (buf))
+          if (modifier - dot < sizeof (resultbuf))
             {
-              memcpy (buf, dot, modifier - dot);
-              buf [modifier - dot] = '\0';
-              return buf;
+              /* This way of filling resultbuf is multithread-safe.  */
+              memcpy (resultbuf, dot, modifier - dot);
+              resultbuf [modifier - dot] = '\0';
+              return resultbuf;
             }
         }
 
@@ -985,8 +998,11 @@
         codeset = "";
       else
         {
+          char buf[2 + 10 + 1];
+
           sprintf (buf, "CP%u", cp[0]);
-          codeset = buf;
+          strcpy (resultbuf, buf);
+          codeset = resultbuf;
         }
     }