* wcsmbs/mbsrtowcs.c: Optimize a bit more.
	* wcsmbs/wcsrtombs.c: Likewise.
This commit is contained in:
Ulrich Drepper 1998-04-29 13:05:07 +00:00
parent 5e7a22c9c3
commit d079f32126
5 changed files with 49 additions and 28 deletions

View File

@ -10,6 +10,9 @@
it is not used. it is not used.
* wcsmbs/wctoc.c: Likewise. * wcsmbs/wctoc.c: Likewise.
* wcsmbs/mbsrtowcs.c: Optimize a bit more.
* wcsmbs/wcsrtombs.c: Likewise.
1998-04-29 Ulrich Drepper <drepper@cygnus.com> 1998-04-29 Ulrich Drepper <drepper@cygnus.com>
* iconv/skeleton.c: Correct counting of actually converted * iconv/skeleton.c: Correct counting of actually converted

View File

@ -66,12 +66,15 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
wchar_t buf[64]; /* Just an arbitrary size. */ wchar_t buf[64]; /* Just an arbitrary size. */
const char *inbuf = *src; const char *inbuf = *src;
data.outbuf = (char *) buf;
data.outbufend = data.outbuf + sizeof (buf); data.outbufend = data.outbuf + sizeof (buf);
do do
status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, {
&data, &inbuf, srcend, data.outbuf = (char *) buf;
&result, 0);
status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
&data, &inbuf, srcend,
&result, 0);
}
while (status == GCONV_FULL_OUTPUT); while (status == GCONV_FULL_OUTPUT);
if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT)

View File

@ -59,18 +59,24 @@ __mbsrtowcs (dst, src, len, ps)
const char *srcend = *src + strlen (*src) + 1; const char *srcend = *src + strlen (*src) + 1;
const char *inbuf = *src; const char *inbuf = *src;
data.outbuf = (char *) buf;
data.outbufend = data.outbuf + sizeof (buf); data.outbufend = data.outbuf + sizeof (buf);
do do
status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, {
&data, &inbuf, srcend, data.outbuf = (char *) buf;
&result, 0);
status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc,
&data, &inbuf, srcend,
&result, 0);
}
while (status == GCONV_FULL_OUTPUT); while (status == GCONV_FULL_OUTPUT);
if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) if (status == GCONV_OK || status == GCONV_EMPTY_INPUT)
&& ((wchar_t *) data.outbuf)[-1] == L'\0') {
/* Don't count the NUL character in. */ /* There better should be a NUL wide char at the end. */
--result; assert (((wchar_t *) data.outbuf)[-1] == L'\0');
/* Don't count the NUL character in. */
--result;
}
} }
else else
{ {

View File

@ -65,15 +65,18 @@ __wcsnrtombs (dst, src, nwc, len, ps)
char buf[256]; /* Just an arbitrary value. */ char buf[256]; /* Just an arbitrary value. */
const wchar_t *inbuf = *src; const wchar_t *inbuf = *src;
data.outbuf = buf;
data.outbufend = buf + sizeof (buf); data.outbufend = buf + sizeof (buf);
do do
status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, {
&data, data.outbuf = buf;
(const char **) &inbuf,
(const char *) srcend, status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
&result, 0); &data,
(const char **) &inbuf,
(const char *) srcend,
&result, 0);
}
while (status == GCONV_FULL_OUTPUT); while (status == GCONV_FULL_OUTPUT);
if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT)

View File

@ -58,21 +58,27 @@ __wcsrtombs (dst, src, len, ps)
const wchar_t *srcend = *src + __wcslen (*src) + 1; const wchar_t *srcend = *src + __wcslen (*src) + 1;
const wchar_t *inbuf = *src; const wchar_t *inbuf = *src;
data.outbuf = buf;
data.outbufend = buf + sizeof (buf); data.outbufend = buf + sizeof (buf);
do do
status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, {
&data, data.outbuf = buf;
(const char **) &inbuf,
(const char *) srcend, status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb,
&result, 0); &data,
(const char **) &inbuf,
(const char *) srcend,
&result, 0);
}
while (status == GCONV_FULL_OUTPUT); while (status == GCONV_FULL_OUTPUT);
if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) if (status == GCONV_OK || status == GCONV_EMPTY_INPUT)
&& data.outbuf[-1] == '\0') {
/* Don't count the NUL character in. */ /* There better should be a NUL byte at the end. */
--result; assert (data.outbuf[-1] == '\0');
/* Don't count the NUL character in. */
--result;
}
} }
else else
{ {