diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-07-28 19:37:40 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-07-28 19:37:40 +0000 |
commit | 9f097308c7465443765d1e25699a4cf33eff5455 (patch) | |
tree | f78dbcef1a0e630554b6d9e299c9767740d86485 /stdlib/mbstowcs.c | |
parent | 97a0d44d89e7724e104f3de8450112712767ec90 (diff) | |
download | glibc-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/mbstowcs.c')
-rw-r--r-- | stdlib/mbstowcs.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/stdlib/mbstowcs.c b/stdlib/mbstowcs.c index 7b9d84c..b7e6123 100644 --- a/stdlib/mbstowcs.c +++ b/stdlib/mbstowcs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1996, 1997, 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,11 +17,10 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> +#include <string.h> #include <wchar.h> -extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - /* Convert the string of multibyte characters in S to `wchar_t's in PWCS, writing no more than N. Return the number written, or (size_t) -1 if an invalid multibyte character is encountered. @@ -33,14 +32,9 @@ extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ size_t mbstowcs (wchar_t *pwcs, const char *s, size_t n) { - mbstate_t save_shift = __no_r_state; - size_t written; - - written = __mbsrtowcs (pwcs, &s, n, &__no_r_state); - - /* Restore the old shift state. */ - __no_r_state = save_shift; + mbstate_t state; + memset (&state, '\0', sizeof state); /* Return how many we wrote (or maybe an error). */ - return written; + return __mbsrtowcs (pwcs, &s, n, &state); } |