summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-28 19:40:24 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-28 19:40:24 +0000
commit087e27ff2210ea566a871efd7edbc0fdf7ab21ca (patch)
tree076cdfcdadd97eec5e48d0939cba90bd4ddd3db5 /stdlib
parenta41f8fd242899790adcb10717fb10dcc4c2a5083 (diff)
Use static state.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/mblen.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/stdlib/mblen.c b/stdlib/mblen.c
index 9d8d0ccc5a..760da60d73 100644
--- a/stdlib/mblen.c
+++ b/stdlib/mblen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1997, 1998, 1999 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
@@ -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 ();
- result = __wcsmbs_gconv_fcts.towc->stateful;
+ /* 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
{