1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00
* iconv/gconv_simple.c: Fix various small bugs in several
	functions.
This commit is contained in:
Ulrich Drepper
2000-06-10 18:20:09 +00:00
parent 3f912ceeba
commit 3593973b3b
2 changed files with 15 additions and 21 deletions

View File

@ -1,5 +1,8 @@
2000-06-10 Ulrich Drepper <drepper@redhat.com> 2000-06-10 Ulrich Drepper <drepper@redhat.com>
* iconv/gconv_simple.c: Fix various small bugs in several
functions.
* iconv/loop.c: Fix comment. * iconv/loop.c: Fix comment.
2000-06-10 Jakub Jelinek <jakub@redhat.com> 2000-06-10 Jakub Jelinek <jakub@redhat.com>

View File

@ -238,7 +238,7 @@ ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
} }
*((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr); *((uint32_t *) outptr)++ = inval;
} }
*inptrp = inptr; *inptrp = inptr;
@ -286,18 +286,6 @@ ucs4_internal_loop_unaligned (const unsigned char **inptrp,
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
} }
# if __BYTE_ORDER == __LITTLE_ENDIAN
outptr[3] = inptr[0];
outptr[2] = inptr[1];
outptr[1] = inptr[2];
outptr[0] = inptr[3];
# else
outptr[0] = inptr[0];
outptr[1] = inptr[1];
outptr[2] = inptr[2];
outptr[3] = inptr[3];
# endif
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
outptr[3] = inptr[0]; outptr[3] = inptr[0];
outptr[2] = inptr[1]; outptr[2] = inptr[1];
@ -353,8 +341,11 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
{ {
/* The value is too large. */ /* The value is too large. */
if (!(flags & __GCONV_IGNORE_ERRORS)) if (!(flags & __GCONV_IGNORE_ERRORS))
{
*inptrp -= cnt - (state->__count & 7);
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
} }
}
else else
{ {
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
@ -448,7 +439,7 @@ internal_ucs4le_loop_unaligned (const unsigned char **inptrp,
/* Sigh, we have to do some real work. */ /* Sigh, we have to do some real work. */
size_t cnt; size_t cnt;
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4)
{ {
outptr[0] = inptr[3]; outptr[0] = inptr[3];
outptr[1] = inptr[2]; outptr[1] = inptr[2];
@ -566,7 +557,7 @@ ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
} }
*((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr); *((uint32_t *) outptr)++ = inval;
} }
*inptrp = inptr; *inptrp = inptr;
@ -752,6 +743,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define LOOPFCT FROM_LOOP #define LOOPFCT FROM_LOOP
#define BODY \ #define BODY \
{ \ { \
/* XXX unaligned. */ \
if (__builtin_expect (*((uint32_t *) inptr), 0) > 0x7f) \ if (__builtin_expect (*((uint32_t *) inptr), 0) > 0x7f) \
{ \ { \
if (! ignore_errors_p ()) \ if (! ignore_errors_p ()) \
@ -766,7 +758,6 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
} \ } \
else \ else \
/* It's an one byte sequence. */ \ /* It's an one byte sequence. */ \
/* XXX unaligned. */ \
*outptr++ = *((uint32_t *) inptr)++; \ *outptr++ = *((uint32_t *) inptr)++; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>
@ -875,13 +866,13 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
cnt = 2; \ cnt = 2; \
ch &= 0x1f; \ ch &= 0x1f; \
} \ } \
else if (__builtin_expect (ch & 0xf0, 0xf0) == 0xe0) \ else if (__builtin_expect (ch & 0xf0, 0xe0) == 0xe0) \
{ \ { \
/* We expect three bytes. */ \ /* We expect three bytes. */ \
cnt = 3; \ cnt = 3; \
ch &= 0x0f; \ ch &= 0x0f; \
} \ } \
else if (__builtin_expect (ch & 0xf8, 0xf8) == 0xf0) \ else if (__builtin_expect (ch & 0xf8, 0xf0) == 0xf0) \
{ \ { \
/* We expect four bytes. */ \ /* We expect four bytes. */ \
cnt = 4; \ cnt = 4; \
@ -1012,13 +1003,13 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
cnt = 3; \ cnt = 3; \
ch &= 0x0f; \ ch &= 0x0f; \
} \ } \
else if (__builtin_expect (ch & 0xf8, 0xf8) == 0xf0) \ else if (__builtin_expect (ch & 0xf8, 0xf0) == 0xf0) \
{ \ { \
/* We expect four bytes. */ \ /* We expect four bytes. */ \
cnt = 4; \ cnt = 4; \
ch &= 0x07; \ ch &= 0x07; \
} \ } \
else if (__builtin_expect (ch & 0xfc, 0xfc) == 0xf8) \ else if (__builtin_expect (ch & 0xfc, 0xf8) == 0xf8) \
{ \ { \
/* We expect five bytes. */ \ /* We expect five bytes. */ \
cnt = 5; \ cnt = 5; \