From d079f32126a4d1005a646dd907b4c791df7b0934 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 29 Apr 1998 13:05:07 +0000 Subject: Update. * wcsmbs/mbsrtowcs.c: Optimize a bit more. * wcsmbs/wcsrtombs.c: Likewise. --- wcsmbs/wcsrtombs.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'wcsmbs/wcsrtombs.c') diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c index ba2d8dc3e2..27b1df8f6d 100644 --- a/wcsmbs/wcsrtombs.c +++ b/wcsmbs/wcsrtombs.c @@ -58,21 +58,27 @@ __wcsrtombs (dst, src, len, ps) const wchar_t *srcend = *src + __wcslen (*src) + 1; const wchar_t *inbuf = *src; - data.outbuf = buf; data.outbufend = buf + sizeof (buf); do - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, - (const char **) &inbuf, - (const char *) srcend, - &result, 0); + { + data.outbuf = buf; + + status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, + &data, + (const char **) &inbuf, + (const char *) srcend, + &result, 0); + } while (status == GCONV_FULL_OUTPUT); - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) - && data.outbuf[-1] == '\0') - /* Don't count the NUL character in. */ - --result; + if (status == GCONV_OK || status == GCONV_EMPTY_INPUT) + { + /* There better should be a NUL byte at the end. */ + assert (data.outbuf[-1] == '\0'); + /* Don't count the NUL character in. */ + --result; + } } else { -- cgit v1.2.3