diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-04-27 06:47:02 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-04-27 06:47:02 +0000 |
commit | 1da6cab218fb9210547d8b5dbea06e142974dcee (patch) | |
tree | 61646e1d7dad4fc755908475beac9ce5a9946e03 /wcsmbs | |
parent | 316518d610789256841f929e3c5757d1e385fcd5 (diff) | |
download | glibc-1da6cab218fb9210547d8b5dbea06e142974dcee.zip glibc-1da6cab218fb9210547d8b5dbea06e142974dcee.tar.gz glibc-1da6cab218fb9210547d8b5dbea06e142974dcee.tar.bz2 |
Update.
* wcsmbs/mbsnrtowcs.c: Correctly compute number of converted
characters. Don't handle incomplete characters as errors.
* wcsmbs/mbsrtowcs.c: Don't handle incomplete characters as errors.
* localedata/Makefile (test-srcs): Add tst-mbswcs2.
Add rule to build tst-mbswcs2 before running tst-mbswcs.sh.
* localedata/tst-mbswcs.sh: Run tst-mbswcs2.
* localedata/tst-mbswcs2.c: New file.
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/mbsnrtowcs.c | 24 | ||||
-rw-r--r-- | wcsmbs/mbsrtowcs.c | 2 |
2 files changed, 16 insertions, 10 deletions
diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c index 94bd7b1..42b5879 100644 --- a/wcsmbs/mbsnrtowcs.c +++ b/wcsmbs/mbsnrtowcs.c @@ -46,9 +46,10 @@ __mbsnrtowcs (dst, src, nmc, len, ps) { const unsigned char *srcend; struct __gconv_step_data data; - size_t result = 0; + size_t result; int status; struct __gconv_step *towc; + size_t non_reversible; /* Tell where we want the result. */ data.__invocation_counter = 0; @@ -72,13 +73,16 @@ __mbsnrtowcs (dst, src, nmc, len, ps) wchar_t buf[64]; /* Just an arbitrary size. */ const unsigned char *inbuf = *src; - data.__outbufend = (char *) buf + sizeof (buf); + result = 0; + data.__outbufend = (unsigned char *) buf + sizeof (buf); do { - data.__outbuf = (char *) buf; + data.__outbuf = (unsigned char *) buf; status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, &inbuf, - srcend, &result, 0, 1); + srcend, &non_reversible, 0, 1); + + result += (wchar_t *) data.__outbuf - buf; } while (status == __GCONV_FULL_OUTPUT); @@ -97,14 +101,16 @@ __mbsnrtowcs (dst, src, nmc, len, ps) status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, (const unsigned char **) src, srcend, - &result, 0, 1); + &non_reversible, 0, 1); + + result = (wchar_t *) data.__outbuf - dst; /* We have to determine whether the last character converted is the NUL character. */ if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) - && ((wchar_t *) dst)[result - 1] == L'\0') + && (assert (result > 0), + ((wchar_t *) dst)[result - 1] == L'\0')) { - assert (result > 0); assert (__mbsinit (data.__statep)); *src = NULL; --result; @@ -113,13 +119,13 @@ __mbsnrtowcs (dst, src, nmc, len, ps) /* There must not be any problems with the conversion but illegal input characters. */ - assert (status == __GCONV_OK || status != __GCONV_EMPTY_INPUT + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT || status == __GCONV_ILLEGAL_INPUT || status == __GCONV_INCOMPLETE_INPUT || status == __GCONV_FULL_OUTPUT); if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT - && status != __GCONV_EMPTY_INPUT) + && status != __GCONV_EMPTY_INPUT && status != __GCONV_INCOMPLETE_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); diff --git a/wcsmbs/mbsrtowcs.c b/wcsmbs/mbsrtowcs.c index afa63a7..facec08 100644 --- a/wcsmbs/mbsrtowcs.c +++ b/wcsmbs/mbsrtowcs.c @@ -131,7 +131,7 @@ __mbsrtowcs (dst, src, len, ps) || status == __GCONV_FULL_OUTPUT); if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT - && status != __GCONV_EMPTY_INPUT) + && status != __GCONV_EMPTY_INPUT && status != __GCONV_INCOMPLETE_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); |