Fix last patch.

This commit is contained in:
Ulrich Drepper 1999-07-28 18:51:36 +00:00
parent 00a8966944
commit f8ecfaf0f9
2 changed files with 33 additions and 33 deletions

View File

@ -40,16 +40,16 @@ __wcsrtombs (dst, src, len, ps)
size_t len;
mbstate_t *ps;
{
struct __gconv_step_data data;
struct gconv_step_data data;
int status;
size_t result;
struct __gconv_step *tomb;
struct gconv_step *tomb;
/* Tell where we want the result. */
data.__invocation_counter = 0;
data.__internal_use = 1;
data.__is_last = 1;
data.__statep = ps ?: &state;
data.invocation_counter = 0;
data.internal_use = 1;
data.is_last = 1;
data.statep = ps ?: &state;
/* Make sure we use the correct function. */
update_conversion_ptrs ();
@ -66,25 +66,25 @@ __wcsrtombs (dst, src, len, ps)
size_t dummy;
result = 0;
data.__outbufend = buf + sizeof (buf);
data.outbufend = buf + sizeof (buf);
do
{
data.__outbuf = buf;
data.outbuf = buf;
status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) &inbuf,
(const unsigned char *) srcend, &dummy, 0);
status = (*tomb->fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) &inbuf,
(const unsigned char *) srcend, &dummy, 0);
/* Count the number of bytes. */
result += data.__outbuf - buf;
result += data.outbuf - buf;
}
while (status == GCONV_FULL_OUTPUT);
if (status == GCONV_OK || status == GCONV_EMPTY_INPUT)
{
/* There better should be a NUL byte at the end. */
assert (data.__outbuf[-1] == '\0');
assert (data.outbuf[-1] == '\0');
/* Don't count the NUL character in. */
--result;
}
@ -97,24 +97,24 @@ __wcsrtombs (dst, src, len, ps)
const wchar_t *srcend = *src + __wcsnlen (*src, len) + 1;
size_t dummy;
data.__outbuf = dst;
data.__outbufend = dst + len;
data.outbuf = dst;
data.outbufend = dst + len;
status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) src,
(const unsigned char *) srcend, &dummy, 0);
status = (*tomb->fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) src,
(const unsigned char *) srcend, &dummy, 0);
/* Count the number of bytes. */
result = data.__outbuf - (unsigned char *) dst;
result = data.outbuf - (unsigned char *) dst;
/* We have to determine whether the last character converted
is the NUL character. */
if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT
|| status == GCONV_FULL_OUTPUT)
&& data.__outbuf[-1] == '\0')
&& data.outbuf[-1] == '\0')
{
assert (data.__outbuf != (unsigned char *) dst);
assert (__mbsinit (data.__statep));
assert (data.outbuf != (unsigned char *) dst);
assert (__mbsinit (data.statep));
*src = NULL;
--result;
}

View File

@ -29,19 +29,19 @@ wctob (c)
wint_t c;
{
char buf[MB_LEN_MAX];
struct __gconv_step_data data;
struct gconv_step_data data;
wchar_t inbuf[1];
wchar_t *inptr = inbuf;
size_t dummy;
int status;
/* Tell where we want the result. */
data.__outbuf = buf;
data.__outbufend = buf + MB_LEN_MAX;
data.__invocation_counter = 0;
data.__internal_use = 1;
data.__is_last = 1;
data.__statep = &data.__state;
data.outbuf = buf;
data.outbufend = buf + MB_LEN_MAX;
data.invocation_counter = 0;
data.internal_use = 1;
data.is_last = 1;
data.statep = &data.__state;
/* Make sure we start in the initial state. */
memset (&data.__state, '\0', sizeof (mbstate_t));
@ -52,14 +52,14 @@ wctob (c)
/* Create the input string. */
inbuf[0] = c;
status = (*__wcsmbs_gconv_fcts.tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) &inptr,
(const unsigned char *) &inbuf[1],
status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, &data,
(const unsigned char **) &inptr,
(const unsigned char *) &inbuf[1],
&dummy, 0);
/* The conversion failed or the output is too long. */
if ((status != GCONV_OK && status != GCONV_FULL_OUTPUT
&& status != GCONV_EMPTY_INPUT)
|| data.__outbuf != (unsigned char *) (buf + 1))
|| data.outbuf != (unsigned char *) (buf + 1))
return EOF;
return (unsigned char) buf[0];