aboutsummaryrefslogtreecommitdiff
path: root/wcsmbs/wcrtomb.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-01-19 07:29:43 +0000
committerUlrich Drepper <drepper@redhat.com>2000-01-19 07:29:43 +0000
commit6a07e1f8df9bee9a7d8bd87f27d796bd671a5109 (patch)
tree3e4d935fe8a8662db3048b9abf32332888322ba7 /wcsmbs/wcrtomb.c
parenta5334a6807f9ee2b321c78483a0519e82aa667aa (diff)
downloadglibc-6a07e1f8df9bee9a7d8bd87f27d796bd671a5109.tar
glibc-6a07e1f8df9bee9a7d8bd87f27d796bd671a5109.tar.gz
glibc-6a07e1f8df9bee9a7d8bd87f27d796bd671a5109.tar.bz2
glibc-6a07e1f8df9bee9a7d8bd87f27d796bd671a5109.zip
Update.
* wcsmbs/mbrtowc.c: Create temporary state object if no output is written. * wcsmbs/mbsrtowcs.c: Likewise. * wcsmbs/wcrtomb.c: Likewise. * wcsmbs/wcsrtombs.c: Likewise. * wcsmbs/wcrtomb.c: Compute result correctly for successful call with s == NULL.
Diffstat (limited to 'wcsmbs/wcrtomb.c')
-rw-r--r--wcsmbs/wcrtomb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c
index 91daf4d94c..fb91167769 100644
--- a/wcsmbs/wcrtomb.c
+++ b/wcsmbs/wcrtomb.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -36,6 +36,7 @@ static mbstate_t state;
size_t
__wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
{
+ mbstate_t temp_state;
char buf[MB_CUR_MAX];
struct __gconv_step_data data;
int status;
@@ -56,6 +57,8 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
{
data.__outbuf = buf;
wc = L'\0';
+ temp_state = *data.__statep;
+ data.__statep = &temp_state;
}
/* Make sure we use the correct function. */
@@ -95,7 +98,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
|| status == __GCONV_FULL_OUTPUT)
- result = data.__outbuf - (unsigned char *) s;
+ result = data.__outbuf - (unsigned char *) (s ?: buf);
else
{
result = (size_t) -1;