diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-06-28 21:46:28 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-06-28 21:46:28 +0000 |
commit | f1f1b6b95a3d2dee0d69eeb0ab606d3c3c0a4b5e (patch) | |
tree | 3262ef2e7d22ef3628d78787465beadca9946a72 /wcsmbs/mbrtowc.c | |
parent | 777e222ddbdffe54b5e344ac1cb40a6ab9ef621f (diff) | |
download | glibc-f1f1b6b95a3d2dee0d69eeb0ab606d3c3c0a4b5e.tar.gz glibc-f1f1b6b95a3d2dee0d69eeb0ab606d3c3c0a4b5e.tar.xz glibc-f1f1b6b95a3d2dee0d69eeb0ab606d3c3c0a4b5e.zip |
Update.
* wcsmbs/mbrtowc.c: Set flush to 1 for conversion function calls depending on whether the input string is empty or not. * wcsmbs/mbrtowc.c: Calling function without input means clearing the given state and not avoiding this by modifying a local object. * wcsmbs/wcrtomb.c: Likewise. * iconv/skeleton.c: If no EMIT_SHIFT_TO_INIT is defined clear state object since some incomplete characters might be in there.
Diffstat (limited to 'wcsmbs/mbrtowc.c')
-rw-r--r-- | wcsmbs/mbrtowc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c index d78a38bd43..034ccfec41 100644 --- a/wcsmbs/mbrtowc.c +++ b/wcsmbs/mbrtowc.c @@ -35,7 +35,6 @@ static mbstate_t state; size_t __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { - mbstate_t temp_state; wchar_t buf[1]; struct __gconv_step_data data; int status; @@ -43,6 +42,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) size_t dummy; const unsigned char *inbuf; char *outbuf = (char *) (pwc ?: buf); + int flush; /* Set information for this step. */ data.__invocation_counter = 0; @@ -58,9 +58,10 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) outbuf = (char *) buf; s = ""; n = 1; - temp_state = *data.__statep; - data.__statep = &temp_state; + flush = 1; } + else + flush = *s == '\0' ? 1 : 0; /* Tell where we want the result. */ data.__outbuf = outbuf; @@ -73,7 +74,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) inbuf = (const unsigned char *) s; status = DL_CALL_FCT (__wcsmbs_gconv_fcts.towc->__fct, (__wcsmbs_gconv_fcts.towc, &data, &inbuf, inbuf + n, - NULL, &dummy, 0, 1)); + NULL, &dummy, flush, 1)); /* There must not be any problems with the conversion but illegal input characters. The output buffer must be large enough, otherwise the |