From: Ulrich Drepper Date: Wed, 29 Apr 1998 13:05:07 +0000 (+0000) Subject: Update. X-Git-Tag: upstream/2.30~28522 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d079f32126a4d1005a646dd907b4c791df7b0934;p=external%2Fglibc.git Update. * wcsmbs/mbsrtowcs.c: Optimize a bit more. * wcsmbs/wcsrtombs.c: Likewise. --- diff --git a/ChangeLog b/ChangeLog index c8c4a1e..78adbee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ it is not used. * wcsmbs/wctoc.c: Likewise. + * wcsmbs/mbsrtowcs.c: Optimize a bit more. + * wcsmbs/wcsrtombs.c: Likewise. + 1998-04-29 Ulrich Drepper * iconv/skeleton.c: Correct counting of actually converted diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c index 790e777..a73fcd1 100644 --- a/wcsmbs/mbsnrtowcs.c +++ b/wcsmbs/mbsnrtowcs.c @@ -66,12 +66,15 @@ __mbsnrtowcs (dst, src, nmc, len, ps) wchar_t buf[64]; /* Just an arbitrary size. */ const char *inbuf = *src; - data.outbuf = (char *) buf; data.outbufend = data.outbuf + sizeof (buf); do - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, &inbuf, srcend, - &result, 0); + { + data.outbuf = (char *) buf; + + status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, + &data, &inbuf, srcend, + &result, 0); + } while (status == GCONV_FULL_OUTPUT); if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) diff --git a/wcsmbs/mbsrtowcs.c b/wcsmbs/mbsrtowcs.c index 5043fd1..bad27ba 100644 --- a/wcsmbs/mbsrtowcs.c +++ b/wcsmbs/mbsrtowcs.c @@ -59,18 +59,24 @@ __mbsrtowcs (dst, src, len, ps) const char *srcend = *src + strlen (*src) + 1; const char *inbuf = *src; - data.outbuf = (char *) buf; data.outbufend = data.outbuf + sizeof (buf); do - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, &inbuf, srcend, - &result, 0); + { + data.outbuf = (char *) buf; + + status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, + &data, &inbuf, srcend, + &result, 0); + } while (status == GCONV_FULL_OUTPUT); - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) - && ((wchar_t *) data.outbuf)[-1] == L'\0') - /* Don't count the NUL character in. */ - --result; + if (status == GCONV_OK || status == GCONV_EMPTY_INPUT) + { + /* There better should be a NUL wide char at the end. */ + assert (((wchar_t *) data.outbuf)[-1] == L'\0'); + /* Don't count the NUL character in. */ + --result; + } } else { diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c index 815d7ad..eb4a96d 100644 --- a/wcsmbs/wcsnrtombs.c +++ b/wcsmbs/wcsnrtombs.c @@ -65,15 +65,18 @@ __wcsnrtombs (dst, src, nwc, len, ps) char buf[256]; /* Just an arbitrary value. */ 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) diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c index ba2d8dc..27b1df8 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 {