aboutsummaryrefslogtreecommitdiff
path: root/stdlib/mblen.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-28 19:37:40 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-28 19:37:40 +0000
commit9f097308c7465443765d1e25699a4cf33eff5455 (patch)
treef78dbcef1a0e630554b6d9e299c9767740d86485 /stdlib/mblen.c
parent97a0d44d89e7724e104f3de8450112712767ec90 (diff)
downloadglibc-9f097308c7465443765d1e25699a4cf33eff5455.zip
glibc-9f097308c7465443765d1e25699a4cf33eff5455.tar.gz
glibc-9f097308c7465443765d1e25699a4cf33eff5455.tar.bz2
Update.
1999-07-28 Ulrich Drepper <drepper@cygnus.com> * stdlib/mblen.c: Use static state. Reported by Bruno Haible <haible@ilog.fr>. * stdlib/mbtowc.c: Reset state for s == NULL. * stdlib/wctomb.c: Likewise. Reported by Bruno Haible <haible@ilog.fr>. * stdlib/mbstowcs.c: Do not use global state. Reported by Bruno Haible <haible@ilog.fr>.
Diffstat (limited to 'stdlib/mblen.c')
-rw-r--r--stdlib/mblen.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/stdlib/mblen.c b/stdlib/mblen.c
index 3a9755b..760da60 100644
--- a/stdlib/mblen.c
+++ b/stdlib/mblen.c
@@ -17,19 +17,22 @@
Boston, MA 02111-1307, USA. */
#include <stdlib.h>
+#include <string.h>
#include <wchar.h>
#include <gconv.h>
#include <wcsmbs/wcsmbsload.h>
+/* Internal state. */
+static mbstate_t state;
+
/* Return the length of the multibyte character (if there is one)
at S which is no longer than N characters.
The ISO C standard says that the `mblen' function must not change
- the global state. */
+ the state of the `mbtowc' function. */
int
mblen (const char *s, size_t n)
{
- mbstate_t state;
int result;
/* If S is NULL the function has to return null or not null
@@ -40,11 +43,13 @@ mblen (const char *s, size_t n)
/* Make sure we use the correct value. */
update_conversion_ptrs ();
+ /* Reset the state. */
+ memset (&state, '\0', sizeof state);
+
result = __wcsmbs_gconv_fcts.towc->__stateful;
}
else if (*s == '\0')
- /* According to the ISO C 89 standard this is the expected behaviour.
- Idiotic, but true. */
+ /* According to the ISO C 89 standard this is the expected behaviour. */
result = 0;
else
{