diff options
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/mbrtowc.c | 9 | ||||
-rw-r--r-- | wcsmbs/wcrtomb.c | 3 |
2 files changed, 5 insertions, 7 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 diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c index ec75e579a4..ad0e0a98a1 100644 --- a/wcsmbs/wcrtomb.c +++ b/wcsmbs/wcrtomb.c @@ -37,7 +37,6 @@ 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; @@ -57,8 +56,6 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) { s = buf; wc = L'\0'; - temp_state = *data.__statep; - data.__statep = &temp_state; } /* Tell where we want to have the result. */ |