about summary refs log tree commit diff
path: root/stdlib/mbtowc.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-04-21 19:09:49 +0000
committerUlrich Drepper <drepper@redhat.com>1998-04-21 19:09:49 +0000
commit9ce5071a3d3af1b7837b1a081548fdd945a66efe (patch)
treec9e8e02e1edb77de0cad9c39662b999cb28994a6 /stdlib/mbtowc.c
parent5aa8ff620ef68811c5a7dd5d5bbac1c078730a2a (diff)
downloadglibc-9ce5071a3d3af1b7837b1a081548fdd945a66efe.tar.gz
glibc-9ce5071a3d3af1b7837b1a081548fdd945a66efe.tar.xz
glibc-9ce5071a3d3af1b7837b1a081548fdd945a66efe.zip
Update.
1998-04-21 19:05  Ulrich Drepper  <drepper@cygnus.com>

	* iconv/gconv.h (struct gconv_step): Add element stateful.
	* iconv/gconv_builtin.c (__gconv_builtin_trans): Initialize stateful
	to zero for all internal conversions.
	* iconv/skeleton.c: Initialize stateful depending on whether or not
	RESET_STATE is defined to one or zero respectively.
	* stdlib/mblen.c: Use stateful element of currently selected
	converter for result if S is NULL.
	* stdlib/mbtowc.c: Likewise.
	* stdlib/wctomb.c: Likewise.
Diffstat (limited to 'stdlib/mbtowc.c')
-rw-r--r--stdlib/mbtowc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/stdlib/mbtowc.c b/stdlib/mbtowc.c
index 50e7c09834..938d54750c 100644
--- a/stdlib/mbtowc.c
+++ b/stdlib/mbtowc.c
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <wchar.h>
+#include <gconv.h>
+#include <wcsmbs/wcsmbsload.h>
 
 
 /* Common state for all non-restartable conversion functions.  */
@@ -38,12 +40,14 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
 
   /* If S is NULL the function has to return null or not null
      depending on the encoding having a state depending encoding or
-     not.  This is nonsense because any multibyte encoding has a
-     state.  The ISO C amendment 1 corrects this while introducing the
-     restartable functions.  We simply say here all encodings have a
-     state.  */
+     not.  */
   if (s == NULL)
-    result = 1;
+    {
+      /* Make sure we use the correct value.  */
+      update_conversion_ptrs ();
+
+      result = __wcsmbs_gconv_fcts.towc->stateful;
+    }
   else if (*s == '\0')
     {
       if (pwc != NULL)