]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdlib/wctomb.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / stdlib / wctomb.c
index ae73d5f75d09bf0ac12a741400b8e3a96784ab96..06c3753f9acb873beaa4aabd66e7b929595fe656 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1995-1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdlib.h>
 #include <string.h>
@@ -23,7 +22,8 @@
 #include <wcsmbs/wcsmbsload.h>
 
 
-extern mbstate_t __no_r_state attribute_hidden;        /* Defined in mbtowc.c.  */
+/* Shared with __wctomb_chk.  */
+mbstate_t __wctomb_state attribute_hidden;
 
 /* Convert WCHAR into its multibyte character representation,
    putting this in S and returning its length.
@@ -40,15 +40,18 @@ wctomb (char *s, wchar_t wchar)
      not.  */
   if (s == NULL)
     {
-      /* Make sure we use the correct value.  */
-      update_conversion_ptrs ();
+      const struct gconv_fcts *fcts;
+
+      /* Get the conversion functions.  */
+      fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
 
       /* This is an extension in the Unix standard which does not directly
         violate ISO C.  */
-      memset (&__no_r_state, '\0', sizeof __no_r_state);
+      memset (&__wctomb_state, '\0', sizeof __wctomb_state);
 
-      return __wcsmbs_gconv_fcts.tomb->__stateful;
+      return fcts->tomb->__stateful;
     }
 
-  return __wcrtomb (s, wchar, &__no_r_state);
+  return __wcrtomb (s, wchar, &__wctomb_state);
 }
+libc_hidden_def (wctomb)