aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-11-20 23:42:04 +0000
committerUlrich Drepper <drepper@redhat.com>2002-11-20 23:42:04 +0000
commiteb9dc2a22dbce7b03fb8efbdc67724ffd9b7d85d (patch)
tree6fc48c9f4f1c8e0a1d8a2cf975929aba2c858c85 /iconv
parent218d76e03413b532f72d47d2695be049d6a2aa64 (diff)
downloadglibc-eb9dc2a22dbce7b03fb8efbdc67724ffd9b7d85d.tar
glibc-eb9dc2a22dbce7b03fb8efbdc67724ffd9b7d85d.tar.gz
glibc-eb9dc2a22dbce7b03fb8efbdc67724ffd9b7d85d.tar.bz2
glibc-eb9dc2a22dbce7b03fb8efbdc67724ffd9b7d85d.zip
Update.
* iconv/gconv_simple.c (internal_ucs4le_loop_unaligned): Return __GCONV_EMPTY_INPUT only if input is really empty. Otherwise __GCONV_INCOMPLETE_INPUT. (ucs4le_internal_loop): Likewise. (ucs4le_internal_loop_unaligned): Likewise. * iconvdata/unicode.c (PREPARE_LOOP): Likewise. * iconvdata/utf-16.c (PREPARE_LOOP): Likewise. * iconvdata/utf-32.c (PREPARE_LOOP): Likewise. * iconv/loop.c (LOOPFCT): First test for empty input then for full output buffer.
Diffstat (limited to 'iconv')
-rw-r--r--iconv/gconv_simple.c29
-rw-r--r--iconv/loop.c16
2 files changed, 27 insertions, 18 deletions
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index fbdac832e0..35346aa498 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -489,12 +489,15 @@ internal_ucs4le_loop_unaligned (struct __gconv_step *step,
# endif
/* Determine the status. */
- if (*inptrp + 4 > inend)
+ if (*inptrp == inend)
result = __GCONV_EMPTY_INPUT;
- else if (*outptrp + 4 > outend)
- result = __GCONV_FULL_OUTPUT;
- else
+ else if (*inptrp + 4 > inend)
result = __GCONV_INCOMPLETE_INPUT;
+ else
+ {
+ assert (*outptrp + 4 > outend);
+ result = __GCONV_FULL_OUTPUT;
+ }
return result;
}
@@ -609,10 +612,13 @@ ucs4le_internal_loop (struct __gconv_step *step,
/* Determine the status. */
if (*inptrp == inend)
result = __GCONV_EMPTY_INPUT;
- else if (*outptrp + 4 > outend)
- result = __GCONV_FULL_OUTPUT;
- else
+ else if (*inptrp + 4 > inend)
result = __GCONV_INCOMPLETE_INPUT;
+ else
+ {
+ assert (*outptrp + 4 > outend);
+ result = __GCONV_FULL_OUTPUT;
+ }
return result;
}
@@ -678,10 +684,13 @@ ucs4le_internal_loop_unaligned (struct __gconv_step *step,
/* Determine the status. */
if (*inptrp == inend)
result = __GCONV_EMPTY_INPUT;
- else if (*outptrp + 4 > outend)
- result = __GCONV_FULL_OUTPUT;
- else
+ else if (*inptrp + 4 > inend)
result = __GCONV_INCOMPLETE_INPUT;
+ else
+ {
+ assert (*outptrp + 4 > outend);
+ result = __GCONV_FULL_OUTPUT;
+ }
return result;
}
diff --git a/iconv/loop.c b/iconv/loop.c
index 2fb73da7ea..deb0173930 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -282,6 +282,14 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step,
/* `if' cases for MIN_NEEDED_OUTPUT ==/!= 1 is made to help the
compiler generating better code. They will be optimized away
since MIN_NEEDED_OUTPUT is always a constant. */
+ if (MIN_NEEDED_INPUT > 1
+ && __builtin_expect (inptr + MIN_NEEDED_INPUT > inend, 0))
+ {
+ /* We don't have enough input for another complete input
+ character. */
+ result = __GCONV_INCOMPLETE_INPUT;
+ break;
+ }
if ((MIN_NEEDED_OUTPUT != 1
&& __builtin_expect (outptr + MIN_NEEDED_OUTPUT > outend, 0))
|| (MIN_NEEDED_OUTPUT == 1
@@ -291,14 +299,6 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step,
result = __GCONV_FULL_OUTPUT;
break;
}
- if (MIN_NEEDED_INPUT > 1
- && __builtin_expect (inptr + MIN_NEEDED_INPUT > inend, 0))
- {
- /* We don't have enough input for another complete input
- character. */
- result = __GCONV_INCOMPLETE_INPUT;
- break;
- }
/* Here comes the body the user provides. It can stop with
RESULT set to GCONV_INCOMPLETE_INPUT (if the size of the