1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00
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>.
This commit is contained in:
Ulrich Drepper
1999-07-28 19:37:40 +00:00
parent 97a0d44d89
commit 9f097308c7
5 changed files with 34 additions and 15 deletions

View File

@@ -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
{