* iconv/gconv.h (__GCONV_IS_LAST, __GCONV_IGNORE_ERRORS): Define.
	(struct __gconv_step_data): Rename __is_last to __flags.
	* iconv/gconv_close.c: Change all uses of __is_last.
	* iconv/skeleton.c: Likewise.
	* iconvdata/iso-2022-cn.c: Likewise.
	* iconvdata/iso-2022-jp.c: Likewise.
	* iconvdata/iso-2022-kr.c: Likewise.
	* iconv/gconv_open.c: Likewise.  Avoid unneeded initializations.
	Recognize IGNORE error handling, set flag, and remove from name.
	* iconv/loop.c (ignore_errors_p): Define.
	Add flags parameter to both functions.
	* iconv/skeleton.c: Pass flags to all conversion functions.
	* iconv/gconv_simple.c: Add flags parameter to all functions.
	Don't return error for invald error if ignore flag is set.
	(ucs4_internal_loop_single): Add missing pointer increment.
	(internal_ucs4le_loop_single): Likewise.
	* iconv/iconv_prog.c: Implement handling of -c parameter.
	* iconvdata/8bit-gap.c: Don't return error for invald error if
	ignore flag is set.
	* iconvdata/8bit-generic.c: Likewise.
	* iconvdata/ansi_x3.110.c: Likewise.
	* iconvdata/big5.c: Likewise.
	* iconvdata/big5hkscs.c: Likewise.
	* iconvdata/euc-cn.c: Likewise.
	* iconvdata/euc-jp.c: Likewise.
	* iconvdata/euc-kr.c: Likewise.
	* iconvdata/gbgbk.c: Likewise.
	* iconvdata/gbk.c: Likewise.
	* iconvdata/iso-2022-cn.c: Likewise.
	* iconvdata/iso-2022-jp.c: Likewise.
	* iconvdata/iso-2022-kr.c: Likewise.
	* iconvdata/iso646.c: Likewise.
	* iconvdata/iso8859-1.c: Likewise.
	* iconvdata/iso_6937-2.c: Likewise.
	* iconvdata/iso_6937.c: Likewise.
	* iconvdata/johab.c: Likewise.
	* iconvdata/sjis.c: Likewise.
	* iconvdata/t.61.c: Likewise.
	* iconvdata/uhc.c: Likewise.
	* iconvdata/unicode.c: Likewise.
	* iconvdata/utf-16.c: Likewise.
	* libio/fileops.c: Likewise.
	* libio/iofwide.c: Likewise.
	* wcsmbs/btowc.c: Likewise.
	* wcsmbs/mbrtowc.c: Likewise.
	* wcsmbs/mbsnrtowcs.c: Likewise.
	* wcsmbs/mbsrtowcs.c: Likewise.
	* wcsmbs/wcrtomb.c: Likewise.
	* wcsmbs/wcsnrtombs.c: Likewise.
	* wcsmbs/wcsrtombs.c: Likewise.
	* wcsmbs/wctob.c: Likewise.

	* iconvdata/ksc5601.h (ksc5601_to_ucs4): Undo *s change in all cases of
This commit is contained in:
Ulrich Drepper 2000-06-06 03:16:30 +00:00
parent b0f1ca6844
commit 85830c4c46
41 changed files with 1286 additions and 378 deletions

View File

@ -1,6 +1,58 @@
2000-06-05 Ulrich Drepper <drepper@redhat.com> 2000-06-05 Ulrich Drepper <drepper@redhat.com>
* iconvdata/ksc5601.h (ksc5601_to_ucs4): Undo *s in all cases of * iconv/gconv.h (__GCONV_IS_LAST, __GCONV_IGNORE_ERRORS): Define.
(struct __gconv_step_data): Rename __is_last to __flags.
* iconv/gconv_close.c: Change all uses of __is_last.
* iconv/skeleton.c: Likewise.
* iconvdata/iso-2022-cn.c: Likewise.
* iconvdata/iso-2022-jp.c: Likewise.
* iconvdata/iso-2022-kr.c: Likewise.
* iconv/gconv_open.c: Likewise. Avoid unneeded initializations.
Recognize IGNORE error handling, set flag, and remove from name.
* iconv/loop.c (ignore_errors_p): Define.
Add flags parameter to both functions.
* iconv/skeleton.c: Pass flags to all conversion functions.
* iconv/gconv_simple.c: Add flags parameter to all functions.
Don't return error for invald error if ignore flag is set.
(ucs4_internal_loop_single): Add missing pointer increment.
(internal_ucs4le_loop_single): Likewise.
* iconv/iconv_prog.c: Implement handling of -c parameter.
* iconvdata/8bit-gap.c: Don't return error for invald error if
ignore flag is set.
* iconvdata/8bit-generic.c: Likewise.
* iconvdata/ansi_x3.110.c: Likewise.
* iconvdata/big5.c: Likewise.
* iconvdata/big5hkscs.c: Likewise.
* iconvdata/euc-cn.c: Likewise.
* iconvdata/euc-jp.c: Likewise.
* iconvdata/euc-kr.c: Likewise.
* iconvdata/gbgbk.c: Likewise.
* iconvdata/gbk.c: Likewise.
* iconvdata/iso-2022-cn.c: Likewise.
* iconvdata/iso-2022-jp.c: Likewise.
* iconvdata/iso-2022-kr.c: Likewise.
* iconvdata/iso646.c: Likewise.
* iconvdata/iso8859-1.c: Likewise.
* iconvdata/iso_6937-2.c: Likewise.
* iconvdata/iso_6937.c: Likewise.
* iconvdata/johab.c: Likewise.
* iconvdata/sjis.c: Likewise.
* iconvdata/t.61.c: Likewise.
* iconvdata/uhc.c: Likewise.
* iconvdata/unicode.c: Likewise.
* iconvdata/utf-16.c: Likewise.
* libio/fileops.c: Likewise.
* libio/iofwide.c: Likewise.
* wcsmbs/btowc.c: Likewise.
* wcsmbs/mbrtowc.c: Likewise.
* wcsmbs/mbsnrtowcs.c: Likewise.
* wcsmbs/mbsrtowcs.c: Likewise.
* wcsmbs/wcrtomb.c: Likewise.
* wcsmbs/wcsnrtombs.c: Likewise.
* wcsmbs/wcsrtombs.c: Likewise.
* wcsmbs/wctob.c: Likewise.
* iconvdata/ksc5601.h (ksc5601_to_ucs4): Undo *s change in all cases of
an error. an error.
2000-06-04 Ulrich Drepper <drepper@redhat.com> 2000-06-04 Ulrich Drepper <drepper@redhat.com>

View File

@ -50,6 +50,14 @@ enum
}; };
/* Flags the `__gconv_open' function can set. */
enum
{
__GCONV_IS_LAST = 0x0001,
__GCONV_IGNORE_ERRORS = 0x0002
};
/* Forward declarations. */ /* Forward declarations. */
struct __gconv_step; struct __gconv_step;
struct __gconv_step_data; struct __gconv_step_data;
@ -103,7 +111,7 @@ struct __gconv_step_data
buffer. */ buffer. */
/* Is this the last module in the chain. */ /* Is this the last module in the chain. */
int __is_last; int __flags;
/* Counter for number of invocations of the module function for this /* Counter for number of invocations of the module function for this
descriptor. */ descriptor. */

View File

@ -1,5 +1,5 @@
/* Release any resource associated with given conversion descriptor. /* Release any resource associated with given conversion descriptor.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -38,10 +38,10 @@ __gconv_close (__gconv_t cd)
drunp = cd->__data; drunp = cd->__data;
do do
{ {
if (!drunp->__is_last && drunp->__outbuf != NULL) if (!(drunp->__flags & __GCONV_IS_LAST) && drunp->__outbuf != NULL)
free (drunp->__outbuf); free (drunp->__outbuf);
} }
while (!(drunp++)->__is_last); while (!((drunp++)->__flags & __GCONV_IS_LAST));
/* Free the data allocated for the descriptor. */ /* Free the data allocated for the descriptor. */
free (cd); free (cd);

View File

@ -35,6 +35,22 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
__gconv_t result = NULL; __gconv_t result = NULL;
size_t cnt = 0; size_t cnt = 0;
int res; int res;
int conv_flags = 0;
const char *runp;
/* Find out whether "IGNORE" is part of the options in the `toset'
name. If yes, remove the string and remember this in the flag. */
runp = __strchrnul (__strchrnul (toset, '/'), '/');
if (strcmp (runp, "IGNORE") == 0)
{
/* Found it. This means we should ignore conversion errors. */
char *newtoset = (char *) alloca (runp - toset + 1);
newtoset[runp - toset] = '\0';
toset = memcpy (newtoset, toset, runp - toset);
flags = __GCONV_IGNORE_ERRORS;
}
res = __gconv_find_transform (toset, fromset, &steps, &nsteps, flags); res = __gconv_find_transform (toset, fromset, &steps, &nsteps, flags);
if (res == __GCONV_OK) if (res == __GCONV_OK)
@ -61,15 +77,19 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
{ {
size_t size; size_t size;
/* Would have to be done if we would not clear the whole
array above. */
/* If this is the last step we must not allocate an /* If this is the last step we must not allocate an
output buffer. */ output buffer. */
result->__data[cnt].__is_last = 0; result->__data[cnt].__flags = conv_flags;
#if 0
/* Reset the counter. */ /* Reset the counter. */
result->__data[cnt].__invocation_counter = 0; result->__data[cnt].__invocation_counter = 0;
/* It's a regular use. */ /* It's a regular use. */
result->__data[cnt].__internal_use = 0; result->__data[cnt].__internal_use = 0;
#endif
/* We use the `mbstate_t' member in DATA. */ /* We use the `mbstate_t' member in DATA. */
result->__data[cnt].__statep = &result->__data[cnt].__state; result->__data[cnt].__statep = &result->__data[cnt].__state;
@ -88,9 +108,13 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
} }
/* Now handle the last entry. */ /* Now handle the last entry. */
result->__data[cnt].__is_last = 1; result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
/* Would have to be done if we would not clear the whole
array above. */
#if 0
result->__data[cnt].__invocation_counter = 0; result->__data[cnt].__invocation_counter = 0;
result->__data[cnt].__internal_use = 0; result->__data[cnt].__internal_use = 0;
#endif
result->__data[cnt].__statep = &result->__data[cnt].__state; result->__data[cnt].__statep = &result->__data[cnt].__state;
} }

View File

@ -64,7 +64,7 @@ static const unsigned char encoding_byte[] =
static inline int static inline int
internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend, internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data, size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -104,7 +104,8 @@ static inline int
internal_ucs4_loop_unaligned (const unsigned char **inptrp, internal_ucs4_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -150,7 +151,8 @@ static inline int
internal_ucs4_loop_single (const unsigned char **inptrp, internal_ucs4_loop_single (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
size_t cnt = state->__count & 7; size_t cnt = state->__count & 7;
@ -171,6 +173,8 @@ internal_ucs4_loop_single (const unsigned char **inptrp,
(*outptrp)[1] = state->__value.__wchb[2]; (*outptrp)[1] = state->__value.__wchb[2];
(*outptrp)[2] = state->__value.__wchb[1]; (*outptrp)[2] = state->__value.__wchb[1];
(*outptrp)[3] = state->__value.__wchb[0]; (*outptrp)[3] = state->__value.__wchb[0];
*outptrp += 4;
#elif __BYTE_ORDER == __BIG_ENDIAN #elif __BYTE_ORDER == __BIG_ENDIAN
/* XXX unaligned */ /* XXX unaligned */
*(*((uint32_t **) outptrp)++) = state->__value.__wch; *(*((uint32_t **) outptrp)++) = state->__value.__wch;
@ -202,7 +206,7 @@ internal_ucs4_loop_single (const unsigned char **inptrp,
static inline int static inline int
ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend, ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data, size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -222,6 +226,13 @@ ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
if (inval > 0x7fffffff) if (inval > 0x7fffffff)
{ {
if (flags & __GCONV_IGNORE_ERRORS)
{
/* Just ignore this character. */
++*converted;
continue;
}
*inptrp = inptr; *inptrp = inptr;
*outptrp = outptr; *outptrp = outptr;
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
@ -249,7 +260,8 @@ static inline int
ucs4_internal_loop_unaligned (const unsigned char **inptrp, ucs4_internal_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -262,6 +274,13 @@ ucs4_internal_loop_unaligned (const unsigned char **inptrp,
if (inptr[0] > 0x80) if (inptr[0] > 0x80)
{ {
/* The value is too large. */ /* The value is too large. */
if (flags & __GCONV_IGNORE_ERRORS)
{
/* Just ignore this character. */
++*converted;
continue;
}
*inptrp = inptr; *inptrp = inptr;
*outptrp = outptr; *outptrp = outptr;
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
@ -312,7 +331,8 @@ static inline int
ucs4_internal_loop_single (const unsigned char **inptrp, ucs4_internal_loop_single (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
size_t cnt = state->__count & 7; size_t cnt = state->__count & 7;
@ -329,9 +349,13 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
} }
if (((unsigned char *) state->__value.__wchb)[0] > 0x80) if (((unsigned char *) state->__value.__wchb)[0] > 0x80)
{
/* The value is too large. */ /* The value is too large. */
if (!(flags & __GCONV_IGNORE_ERRORS))
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
}
else
{
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
(*outptrp)[0] = state->__value.__wchb[3]; (*outptrp)[0] = state->__value.__wchb[3];
(*outptrp)[1] = state->__value.__wchb[2]; (*outptrp)[1] = state->__value.__wchb[2];
@ -344,6 +368,9 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
(*outptrp)[3] = state->__value.__wchb[3]; (*outptrp)[3] = state->__value.__wchb[3];
#endif #endif
*outptrp += 4;
}
/* Clear the state buffer. */ /* Clear the state buffer. */
state->__count &= ~7; state->__count &= ~7;
@ -367,7 +394,8 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
static inline int static inline int
internal_ucs4le_loop (const unsigned char **inptrp, const unsigned char *inend, internal_ucs4le_loop (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -407,7 +435,7 @@ static inline int
internal_ucs4le_loop_unaligned (const unsigned char **inptrp, internal_ucs4le_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, mbstate_t *state, int flags, void *data,
size_t *converted) size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
@ -454,7 +482,8 @@ static inline int
internal_ucs4le_loop_single (const unsigned char **inptrp, internal_ucs4le_loop_single (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
size_t cnt = state->__count & 7; size_t cnt = state->__count & 7;
@ -475,6 +504,8 @@ internal_ucs4le_loop_single (const unsigned char **inptrp,
(*outptrp)[1] = state->__value.__wchb[2]; (*outptrp)[1] = state->__value.__wchb[2];
(*outptrp)[2] = state->__value.__wchb[1]; (*outptrp)[2] = state->__value.__wchb[1];
(*outptrp)[3] = state->__value.__wchb[0]; (*outptrp)[3] = state->__value.__wchb[0];
*outptrp += 4;
#else #else
/* XXX unaligned */ /* XXX unaligned */
*(*((uint32_t **) outptrp)++) = state->__value.__wch; *(*((uint32_t **) outptrp)++) = state->__value.__wch;
@ -503,7 +534,8 @@ internal_ucs4le_loop_single (const unsigned char **inptrp,
static inline int static inline int
ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend, ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
unsigned char *outptr = *outptrp; unsigned char *outptr = *outptrp;
@ -522,7 +554,16 @@ ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
#endif #endif
if (inval > 0x7fffffff) if (inval > 0x7fffffff)
{
if (flags & __GCONV_IGNORE_ERRORS)
{
/* Just ignore this character. */
++*converted;
continue;
}
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
}
*((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr); *((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr);
} }
@ -546,7 +587,7 @@ static inline int
ucs4le_internal_loop_unaligned (const unsigned char **inptrp, ucs4le_internal_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, mbstate_t *state, int flags, void *data,
size_t *converted) size_t *converted)
{ {
const unsigned char *inptr = *inptrp; const unsigned char *inptr = *inptrp;
@ -560,12 +601,18 @@ ucs4le_internal_loop_unaligned (const unsigned char **inptrp,
if (inptr[3] > 0x80) if (inptr[3] > 0x80)
{ {
/* The value is too large. */ /* The value is too large. */
if (flags & __GCONV_IGNORE_ERRORS)
{
/* Just ignore this character. */
++*converted;
continue;
}
*inptrp = inptr; *inptrp = inptr;
*outptrp = outptr; *outptrp = outptr;
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
} }
# if __BYTE_ORDER == __BIG_ENDIAN # if __BYTE_ORDER == __BIG_ENDIAN
outptr[3] = inptr[0]; outptr[3] = inptr[0];
outptr[2] = inptr[1]; outptr[2] = inptr[1];
@ -577,6 +624,8 @@ ucs4le_internal_loop_unaligned (const unsigned char **inptrp,
outptr[2] = inptr[2]; outptr[2] = inptr[2];
outptr[3] = inptr[3]; outptr[3] = inptr[3];
# endif # endif
outptr += 4;
} }
*inptrp = inptr; *inptrp = inptr;
@ -599,7 +648,8 @@ static inline int
ucs4le_internal_loop_single (const unsigned char **inptrp, ucs4le_internal_loop_single (const unsigned char **inptrp,
const unsigned char *inend, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted) mbstate_t *state, int flags, void *data,
size_t *converted)
{ {
size_t cnt = state->__count & 7; size_t cnt = state->__count & 7;
@ -616,9 +666,13 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
} }
if (((unsigned char *) state->__value.__wchb)[3] > 0x80) if (((unsigned char *) state->__value.__wchb)[3] > 0x80)
{
/* The value is too large. */ /* The value is too large. */
if (!(flags & __GCONV_IGNORE_ERRORS))
return __GCONV_ILLEGAL_INPUT; return __GCONV_ILLEGAL_INPUT;
}
else
{
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
(*outptrp)[0] = state->__value.__wchb[3]; (*outptrp)[0] = state->__value.__wchb[3];
(*outptrp)[1] = state->__value.__wchb[2]; (*outptrp)[1] = state->__value.__wchb[2];
@ -631,6 +685,9 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
(*outptrp)[3] = state->__value.__wchb[3]; (*outptrp)[3] = state->__value.__wchb[3];
#endif #endif
*outptrp += 4;
}
/* Clear the state buffer. */ /* Clear the state buffer. */
state->__count &= ~7; state->__count &= ~7;
@ -657,12 +714,18 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define BODY \ #define BODY \
{ \ { \
if (*inptr > '\x7f') \ if (*inptr > '\x7f') \
{ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is no correct ANSI_X3.4-1968 character. */ \ /* This is no correct ANSI_X3.4-1968 character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
++inptr; \
} \
else \
/* It's an one byte sequence. */ \ /* It's an one byte sequence. */ \
/* XXX unaligned. */ \ /* XXX unaligned. */ \
*((uint32_t *) outptr)++ = *inptr++; \ *((uint32_t *) outptr)++ = *inptr++; \
@ -688,13 +751,20 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define BODY \ #define BODY \
{ \ { \
if (*((uint32_t *) inptr) > 0x7f) \ if (*((uint32_t *) inptr) > 0x7f) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is no correct ANSI_X3.4-1968 character. */ \ /* This is no correct ANSI_X3.4-1968 character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
inptr += 4; \
} \
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>
@ -828,12 +898,29 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
ch &= 0x01; \ ch &= 0x01; \
} \ } \
else \ else \
{ \
int skipped; \
\
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal encoding. */ \ /* This is an illegal encoding. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
/* Search the end of this ill-formed UTF-8 character. This \
is the next byte with (x & 0xc0) != 0x80. */ \
skipped = 0; \
do \
{ \
++inptr; \
++skipped; \
} \
while (inptr < inend && (*inptr & 0xc0) == 0x80 && skipped < 5); \
\
continue; \
} \
\
if (NEED_LENGTH_TEST && inptr + cnt > inend) \ if (NEED_LENGTH_TEST && inptr + cnt > inend) \
{ \ { \
/* We don't have enough input. But before we report that check \ /* We don't have enough input. But before we report that check \
@ -841,8 +928,23 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
for (i = 1; inptr + i < inend; ++i) \ for (i = 1; inptr + i < inend; ++i) \
if ((inptr[i] & 0xc0) != 0x80) \ if ((inptr[i] & 0xc0) != 0x80) \
break; \ break; \
result = (inptr + i == inend \ \
? __GCONV_INCOMPLETE_INPUT : __GCONV_ILLEGAL_INPUT); \ if (inptr + i == inend) \
{ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
\
/* This is an illegal character. */ \
if (ignore_errors_p ()) \
{ \
/* Ignore it. */ \
inptr += i; \
++*converted; \
continue; \
} \
\
result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
@ -865,6 +967,13 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
if (i < cnt || (cnt > 2 && (ch >> (5 * cnt - 4)) == 0)) \ if (i < cnt || (cnt > 2 && (ch >> (5 * cnt - 4)) == 0)) \
{ \ { \
/* This is an illegal encoding. */ \ /* This is an illegal encoding. */ \
if (ignore_errors_p ()) \
{ \
inptr += i; \
++*converted; \
continue; \
} \
\
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
@ -1020,10 +1129,17 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define BODY \ #define BODY \
{ \ { \
if (*((uint32_t *) inptr) >= 0x10000) \ if (*((uint32_t *) inptr) >= 0x10000) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\
inptr += 4; \
++*converted; \
} \
else \
*((uint16_t *) outptr)++ = *((uint32_t *) inptr)++; \ *((uint16_t *) outptr)++ = *((uint32_t *) inptr)++; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>
@ -1069,9 +1185,15 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
{ \ { \
uint32_t val = *((uint32_t *) inptr); \ uint32_t val = *((uint32_t *) inptr); \
if (val >= 0x10000) \ if (val >= 0x10000) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
} \ } \
*((uint16_t *) outptr)++ = bswap_16 (val); \ *((uint16_t *) outptr)++ = bswap_16 (val); \
inptr += 4; \ inptr += 4; \

View File

@ -97,6 +97,9 @@ static int verbose;
/* Nonzero if list of all coded character sets is wanted. */ /* Nonzero if list of all coded character sets is wanted. */
static int list; static int list;
/* If nonzero omit invalid character from output. */
static int omit_invalid;
/* Prototypes for the functions doing the actual work. */ /* Prototypes for the functions doing the actual work. */
static int process_block (iconv_t cd, char *addr, size_t len, FILE *output); static int process_block (iconv_t cd, char *addr, size_t len, FILE *output);
static int process_fd (iconv_t cd, int fd, FILE *output); static int process_fd (iconv_t cd, int fd, FILE *output);
@ -111,6 +114,7 @@ main (int argc, char *argv[])
int remaining; int remaining;
FILE *output; FILE *output;
iconv_t cd; iconv_t cd;
const char *orig_to_code;
/* Set locale via LC_ALL. */ /* Set locale via LC_ALL. */
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
@ -138,15 +142,48 @@ main (int argc, char *argv[])
if (to_code == NULL) if (to_code == NULL)
error (EXIT_FAILURE, 0, _("target encoding not specified using `-t'")); error (EXIT_FAILURE, 0, _("target encoding not specified using `-t'"));
/* If we have to ignore errors make sure we use the appropriate name for
the to-character-set. */
orig_to_code = to_code;
if (omit_invalid)
{
const char *errhand = strchrnul (to_code, '/');
int nslash = 2;
char *newp;
char *cp;
if (*errhand == '/')
{
--nslash;
errhand = strchrnul (errhand, '/');
if (*errhand == '/')
{
--nslash;
++errhand;
}
}
newp = (char *) alloca (errhand - to_code + nslash + 6 + 1);
cp = mempcpy (newp, to_code, errhand - to_code);
while (nslash > 0)
*cp++ = '/';
memcpy (cp, "NEEDED", sizeof ("NEEDED"));
to_code = newp;
}
/* Let's see whether we have these coded character sets. */ /* Let's see whether we have these coded character sets. */
cd = iconv_open (to_code, from_code); cd = iconv_open (to_code, from_code);
if (cd == (iconv_t) -1) if (cd == (iconv_t) -1)
{ {
if (errno == EINVAL) if (errno == EINVAL)
error (EXIT_FAILURE, 0, _("conversion from `%s' to `%s' not supported"), error (EXIT_FAILURE, 0,
from_code, to_code); _("conversion from `%s' to `%s' not supported"),
from_code, orig_to_code);
else else
error (EXIT_FAILURE, errno, _("failed to start conversion processing")); error (EXIT_FAILURE, errno,
_("failed to start conversion processing"));
} }
/* Determine output file. */ /* Determine output file. */
@ -274,9 +311,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
about missing character or so. */ about missing character or so. */
break; break;
case 'c': case 'c':
/* Omit invalid characters from output. /* Omit invalid characters from output. */
XXX This option will become a meaning once we have different omit_invalid = 1;
modes of operation for the conversion functions. */
break; break;
case OPT_VERBOSE: case OPT_VERBOSE:
verbose = 1; verbose = 1;

View File

@ -168,11 +168,16 @@
#endif #endif
/* To make it easier for the writers of the modules, we define a macro
to test whether we have to ignore errors. */
#define ignore_errors_p() (flags & __GCONV_IGNORE_ERRORS)
/* The function returns the status, as defined in gconv.h. */ /* The function returns the status, as defined in gconv.h. */
static inline int static inline int
FCTNAME (LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend, FCTNAME (LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted mbstate_t *state, int flags, void *data, size_t *converted
EXTRA_LOOP_DECLS) EXTRA_LOOP_DECLS)
{ {
int result = __GCONV_OK; int result = __GCONV_OK;
@ -285,7 +290,7 @@ FCTNAME (LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend,
static inline int static inline int
SINGLE(LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend, SINGLE(LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, unsigned char **outptrp, unsigned char *outend,
mbstate_t *state, void *data, size_t *converted mbstate_t *state, int flags, void *data, size_t *converted
EXTRA_LOOP_DECLS) EXTRA_LOOP_DECLS)
{ {
int result = __GCONV_OK; int result = __GCONV_OK;

View File

@ -275,9 +275,11 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
{ {
struct __gconv_step *next_step = step + 1; struct __gconv_step *next_step = step + 1;
struct __gconv_step_data *next_data = data + 1; struct __gconv_step_data *next_data = data + 1;
__gconv_fct fct = data->__is_last ? NULL : next_step->__fct; __gconv_fct fct;
int status; int status;
fct = (data->__flags & __GCONV_IS_LAST) ? NULL : next_step->__fct;
/* If the function is called with no input this means we have to reset /* If the function is called with no input this means we have to reset
to the initial state. The possibly partly converted input is to the initial state. The possibly partly converted input is
dropped. */ dropped. */
@ -291,7 +293,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
#endif #endif
/* Call the steps down the chain if there are any but only if we /* Call the steps down the chain if there are any but only if we
successfully emitted the escape sequence. */ successfully emitted the escape sequence. */
if (status == __GCONV_OK && ! data->__is_last) if (status == __GCONV_OK && ! (data->__flags & __GCONV_IS_LAST))
status = DL_CALL_FCT (fct, (next_step, next_data, NULL, NULL, status = DL_CALL_FCT (fct, (next_step, next_data, NULL, NULL,
written, 1, consume_incomplete)); written, 1, consume_incomplete));
} }
@ -332,16 +334,18 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
# if MAX_NEEDED_FROM > 1 # if MAX_NEEDED_FROM > 1
if (MAX_NEEDED_TO == 1 || FROM_DIRECTION) if (MAX_NEEDED_TO == 1 || FROM_DIRECTION)
status = SINGLE(FROM_LOOP) (inptrp, inend, &outbuf, outend, status = SINGLE(FROM_LOOP) (inptrp, inend, &outbuf, outend,
data->__statep, step->__data, data->__statep, data->__flags,
&converted EXTRA_LOOP_ARGS); step->__data, &converted
EXTRA_LOOP_ARGS);
# endif # endif
# if MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1 && !ONE_DIRECTION # if MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1 && !ONE_DIRECTION
else else
# endif # endif
# if MAX_NEEDED_TO > 1 && !ONE_DIRECTION # if MAX_NEEDED_TO > 1 && !ONE_DIRECTION
status = SINGLE(TO_LOOP) (inptrp, inend, &outbuf, outend, status = SINGLE(TO_LOOP) (inptrp, inend, &outbuf, outend,
data->__statep, step->__data, data->__statep, data->__flags,
&converted EXTRA_LOOP_ARGS); step->__data, &converted
EXTRA_LOOP_ARGS);
# endif # endif
if (status != __GCONV_OK) if (status != __GCONV_OK)
@ -359,10 +363,10 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
for all known and supported encodings. */ for all known and supported encodings. */
unaligned = ((FROM_DIRECTION unaligned = ((FROM_DIRECTION
&& ((uintptr_t) inptr % MIN_NEEDED_FROM != 0 && ((uintptr_t) inptr % MIN_NEEDED_FROM != 0
|| (data->__is_last || ((data->__flags & __GCONV_IS_LAST)
&& (uintptr_t) outbuf % MIN_NEEDED_TO != 0))) && (uintptr_t) outbuf % MIN_NEEDED_TO != 0)))
|| (!FROM_DIRECTION || (!FROM_DIRECTION
&& ((data->__is_last && (((data->__flags & __GCONV_IS_LAST)
&& (uintptr_t) outbuf % MIN_NEEDED_FROM != 0) && (uintptr_t) outbuf % MIN_NEEDED_FROM != 0)
|| (uintptr_t) inptr % MIN_NEEDED_TO != 0))); || (uintptr_t) inptr % MIN_NEEDED_TO != 0)));
#endif #endif
@ -383,13 +387,13 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
if (FROM_DIRECTION) if (FROM_DIRECTION)
/* Run the conversion loop. */ /* Run the conversion loop. */
status = FROM_LOOP (inptrp, inend, &outbuf, outend, status = FROM_LOOP (inptrp, inend, &outbuf, outend,
data->__statep, step->__data, &converted data->__statep, data->__flags,
EXTRA_LOOP_ARGS); step->__data, &converted EXTRA_LOOP_ARGS);
else else
/* Run the conversion loop. */ /* Run the conversion loop. */
status = TO_LOOP (inptrp, inend, &outbuf, outend, status = TO_LOOP (inptrp, inend, &outbuf, outend,
data->__statep, step->__data, &converted data->__statep, data->__flags,
EXTRA_LOOP_ARGS); step->__data, &converted EXTRA_LOOP_ARGS);
} }
#if !defined _STRING_ARCH_unaligned \ #if !defined _STRING_ARCH_unaligned \
&& MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \ && MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
@ -400,12 +404,14 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
/* Run the conversion loop. */ /* Run the conversion loop. */
status = GEN_unaligned (FROM_LOOP) (inptrp, inend, &outbuf, status = GEN_unaligned (FROM_LOOP) (inptrp, inend, &outbuf,
outend, data->__statep, outend, data->__statep,
data->__flags,
step->__data, &converted step->__data, &converted
EXTRA_LOOP_ARGS); EXTRA_LOOP_ARGS);
else else
/* Run the conversion loop. */ /* Run the conversion loop. */
status = GEN_unaligned (TO_LOOP) (inptrp, inend, &outbuf, status = GEN_unaligned (TO_LOOP) (inptrp, inend, &outbuf,
outend, data->__statep, outend, data->__statep,
data->__flags,
step->__data, &converted step->__data, &converted
EXTRA_LOOP_ARGS); EXTRA_LOOP_ARGS);
} }
@ -416,7 +422,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
/* If this is the last step leave the loop, there is nothing /* If this is the last step leave the loop, there is nothing
we can do. */ we can do. */
if (data->__is_last) if (data->__flags & __GCONV_IS_LAST)
{ {
/* Store information about how many bytes are available. */ /* Store information about how many bytes are available. */
data->__outbuf = outbuf; data->__outbuf = outbuf;
@ -457,22 +463,25 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
SAVE_RESET_STATE (0); SAVE_RESET_STATE (0);
# endif # endif
/* XXX Handle unaligned access here as well. */
if (FROM_DIRECTION) if (FROM_DIRECTION)
/* Run the conversion loop. */ /* Run the conversion loop. */
nstatus = FROM_LOOP ((const unsigned char **) inptrp, nstatus = FROM_LOOP ((const unsigned char **) inptrp,
(const unsigned char *) inend, (const unsigned char *) inend,
(unsigned char **) &outbuf, (unsigned char **) &outbuf,
(unsigned char *) outerr, (unsigned char *) outerr,
data->__statep, step->__data, data->__statep, data->__flags,
&converted EXTRA_LOOP_ARGS); step->__data, &converted
EXTRA_LOOP_ARGS);
else else
/* Run the conversion loop. */ /* Run the conversion loop. */
nstatus = TO_LOOP ((const unsigned char **) inptrp, nstatus = TO_LOOP ((const unsigned char **) inptrp,
(const unsigned char *) inend, (const unsigned char *) inend,
(unsigned char **) &outbuf, (unsigned char **) &outbuf,
(unsigned char *) outerr, (unsigned char *) outerr,
data->__statep, step->__data, data->__statep, data->__flags,
&converted EXTRA_LOOP_ARGS); step->__data, &converted
EXTRA_LOOP_ARGS);
/* We must run out of output buffer space in this /* We must run out of output buffer space in this
rerun. */ rerun. */

View File

@ -51,12 +51,20 @@ struct gap
if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \ if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
put32 (outptr, ch); \ put32 (outptr, ch); \
outptr += 4; \ outptr += 4; \
} \
\
++inptr; \ ++inptr; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>
@ -75,26 +83,47 @@ struct gap
if (ch >= 0xffff) \ if (ch >= 0xffff) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
while (ch > rp->end) \ while (ch > rp->end) \
++rp; \ ++rp; \
if (ch < rp->start) \ if (ch < rp->start) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
inptr += 4; \
continue; \
} \
\
res = from_ucs4[ch + rp->idx]; \ res = from_ucs4[ch + rp->idx]; \
if (ch != 0 && res == '\0') \ if (ch != 0 && res == '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
inptr += 4; \
continue; \
} \
\
*outptr++ = res; \ *outptr++ = res; \
inptr += 4; \ inptr += 4; \
} }

View File

@ -37,10 +37,15 @@
if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \ if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
\
put32 (outptr, ch); \ put32 (outptr, ch); \
outptr += 4; \ outptr += 4; \
++inptr; \ ++inptr; \
@ -60,11 +65,17 @@
|| (ch != 0 && from_ucs4[ch] == '\0')) \ || (ch != 0 && from_ucs4[ch] == '\0')) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
*outptr++ = from_ucs4[ch]; \ *outptr++ = from_ucs4[ch]; \
\
inptr += 4; \ inptr += 4; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>

View File

@ -419,14 +419,21 @@ static const char from_ucs4[][2] =
if (ch2 < 0x20 || ch2 >= 0x80) \ if (ch2 < 0x20 || ch2 >= 0x80) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
incr = 1; \
} \
else \
{ \
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
incr = 2; \ incr = 2; \
} \ } \
} \
else \ else \
{ \ { \
ch = to_ucs4[ch]; \ ch = to_ucs4[ch]; \
@ -436,13 +443,19 @@ static const char from_ucs4[][2] =
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ } \
inptr += incr; \ else \
{ \
put32 (outptr, ch); \ put32 (outptr, ch); \
outptr += 4; \ outptr += 4; \
} \
\
inptr += incr; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>
@ -480,8 +493,15 @@ static const char from_ucs4[][2] =
if (tmp[0] == '\0') \ if (tmp[0] == '\0') \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
tmp[1] = '\0'; \ tmp[1] = '\0'; \
cp = tmp; \ cp = tmp; \
@ -521,8 +541,15 @@ static const char from_ucs4[][2] =
else \ else \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
} \ } \
else \ else \
@ -531,9 +558,16 @@ static const char from_ucs4[][2] =
\ \
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
} \ } \
\ \

View File

@ -8455,10 +8455,17 @@ static const char from_ucs4_tab13[][2] =
else \ else \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* Get the value from the table. */ \ /* Get the value from the table. */ \
ch = big5_to_ucs[idx]; \ ch = big5_to_ucs[idx]; \
\ \
@ -8466,11 +8473,18 @@ static const char from_ucs4_tab13[][2] =
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
else \ else \
++inptr; \ ++inptr; \
@ -8567,10 +8581,16 @@ static const char from_ucs4_tab13[][2] =
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
/* See whether there is enough room for the second byte we write. */ \ /* See whether there is enough room for the second byte we write. */ \
if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \ if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
{ \ { \
@ -8582,6 +8602,8 @@ static const char from_ucs4_tab13[][2] =
*outptr++ = cp[0]; \ *outptr++ = cp[0]; \
if (cp[1] != '\0') \ if (cp[1] != '\0') \
*outptr++ = cp[1]; \ *outptr++ = cp[1]; \
} \
\
inptr += 4; \ inptr += 4; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>

View File

@ -12609,10 +12609,17 @@ static const char from_ucs4_tab14[][2] =
else \ else \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* Get the value from the table. */ \ /* Get the value from the table. */ \
ch = big5_to_ucs[idx]; \ ch = big5_to_ucs[idx]; \
\ \
@ -12620,11 +12627,18 @@ static const char from_ucs4_tab14[][2] =
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
else \ else \
++inptr; \ ++inptr; \
@ -12724,10 +12738,16 @@ static const char from_ucs4_tab14[][2] =
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
/* See whether there is enough room for the second byte we write. */ \ /* See whether there is enough room for the second byte we write. */ \
if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \ if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
{ \ { \
@ -12739,6 +12759,8 @@ static const char from_ucs4_tab14[][2] =
*outptr++ = cp[0]; \ *outptr++ = cp[0]; \
if (cp[1] != '\0') \ if (cp[1] != '\0') \
*outptr++ = cp[1]; \ *outptr++ = cp[1]; \
} \
\
inptr += 4; \ inptr += 4; \
} }
#include <iconv/loop.c> #include <iconv/loop.c>

View File

@ -44,11 +44,18 @@
if (ch <= 0x7f) \ if (ch <= 0x7f) \
++inptr; \ ++inptr; \
else \ else \
if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f) \ if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -68,17 +75,27 @@
\ \
/* All second bytes of a multibyte character must be >= 0xa1. */ \ /* All second bytes of a multibyte character must be >= 0xa1. */ \
if (ch < 0xa1) \ if (ch < 0xa1) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* This is code set 1: GB 2312-80. */ \ /* This is code set 1: GB 2312-80. */ \
endp = inptr; \ endp = inptr; \
\ \
ch = gb2312_to_ucs4 (&endp, 2, 0x80); \ ch = gb2312_to_ucs4 (&endp, 2, 0x80); \
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
@ -86,6 +103,11 @@
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
\ \
put32 (outptr, ch); \ put32 (outptr, ch); \
@ -118,10 +140,17 @@
if (found == __UNKNOWN_10646_CHAR) \ if (found == __UNKNOWN_10646_CHAR) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
/* It's a GB 2312 character, adjust it for EUC-CN. */ \ /* It's a GB 2312 character, adjust it for EUC-CN. */ \
*outptr++ += 0x80; \ *outptr++ += 0x80; \
*outptr++ += 0x80; \ *outptr++ += 0x80; \

View File

@ -46,11 +46,18 @@
\ \
if (ch <= 0x7f) \ if (ch <= 0x7f) \
++inptr; \ ++inptr; \
else if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f) \ else if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -72,10 +79,17 @@
if (ch2 < 0xa1) \ if (ch2 < 0xa1) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
if (ch == 0x8e) \ if (ch == 0x8e) \
{ \ { \
/* This is code set 2: half-width katakana. */ \ /* This is code set 2: half-width katakana. */ \
@ -114,8 +128,16 @@
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 2; \
++*converted; \
continue; \
} \ } \
inptr = endp; \ inptr = endp; \
} \ } \
@ -198,8 +220,15 @@
else \ else \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
} \ } \

View File

@ -81,8 +81,15 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
else if (ch <= 0xa0 || ch > 0xfe || ch == 0xc9) \ else if (ch <= 0xa0 || ch > 0xfe || ch == 0xc9) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -97,10 +104,18 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
break; \ break; \
} \ } \
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 2; \
++*converted; \
continue; \
} \ } \
} \ } \
\ \
@ -127,10 +142,17 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
*outptr++ = cp[0]; \ *outptr++ = cp[0]; \
/* Now test for a possible second byte and write this if possible. */ \ /* Now test for a possible second byte and write this if possible. */ \
if (cp[1] != '\0') \ if (cp[1] != '\0') \

View File

@ -89,29 +89,29 @@
ch = (ch << 8) | inptr[1]; \ ch = (ch << 8) | inptr[1]; \
\ \
/* Now determine whether the character is valid. */ \ /* Now determine whether the character is valid. */ \
if (ch >= 0xa1a1 && ch <= 0xf7fe && inptr[1] >= 0xa1) \ if (ch < 0xa1a1 || ch > 0xf7fe || inptr[1] < 0xa1 \
{ \ /* Now test the exceptions. */ \
/* So far so good. Now test the exceptions. */ \ || (ch >= 0xa2a1 && ch <= 0xa2aa) \
if ((ch >= 0xa2a1 && ch <= 0xa2aa) \
|| (ch >= 0xa6e0 && ch <= 0xa6f5) \ || (ch >= 0xa6e0 && ch <= 0xa6f5) \
|| (ch >= 0xa8bb && ch <= 0xa8c0)) \ || (ch >= 0xa8bb && ch <= 0xa8c0)) \
{ \
/* One of the exceptions. */ \
result = __GCONV_ILLEGAL_INPUT; \
break; \
} \
} \
else \
{ \ { \
/* One of the characters we cannot map. */ \ /* One of the characters we cannot map. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 2; \
++*converted; \
} \
else \
{ \
/* Copy the two bytes. */ \ /* Copy the two bytes. */ \
*outptr++ = *inptr++; \ *outptr++ = *inptr++; \
*outptr++ = *inptr++; \ *outptr++ = *inptr++; \
} \ } \
} \
} }
#include <iconv/loop.c> #include <iconv/loop.c>

View File

@ -13124,8 +13124,15 @@ static const char __gbk_from_ucs4_tab12[][2] =
if (ch <= 0x80 || ch > 0xfe) \ if (ch <= 0x80 || ch > 0xfe) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -13146,18 +13153,29 @@ static const char __gbk_from_ucs4_tab12[][2] =
\ \
/* All second bytes of a multibyte character must be >= 0x40. */ \ /* All second bytes of a multibyte character must be >= 0x40. */ \
if (ch2 < 0x40) \ if (ch2 < 0x40) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* This is code set 1: GBK. */ \ /* This is code set 1: GBK. */ \
idx = (ch - 0x81)*192 + (ch2 - 0x40); \ idx = (ch - 0x81)*192 + (ch2 - 0x40); \
\ \
ch = __gbk_to_ucs[idx]; \ ch = __gbk_to_ucs[idx]; \
\ \
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
@ -13165,6 +13183,11 @@ static const char __gbk_from_ucs4_tab12[][2] =
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
\ \
put32 (outptr, ch); \ put32 (outptr, ch); \
@ -13426,21 +13449,27 @@ static const char __gbk_from_ucs4_tab12[][2] =
if (cp == NULL || (cp[0] == '\0' && ch != 0)) \ if (cp == NULL || (cp[0] == '\0' && ch != 0)) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
/* See whether there is enough room for the second byte we write. */ \ /* See whether there is enough room for the second byte we write. */ \
if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \ else if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
{ \ { \
/* We have not enough room. */ \ /* We have not enough room. */ \
result = __GCONV_FULL_OUTPUT; \ result = __GCONV_FULL_OUTPUT; \
break; \ break; \
} \ } \
\ else \
{ \
*outptr++ = cp[0]; \ *outptr++ = cp[0]; \
if (cp[1] != '\0') \ if (cp[1] != '\0') \
*outptr++ = cp[1]; \ *outptr++ = cp[1]; \
} \
} \ } \
\ \
inptr += 4; \ inptr += 4; \

View File

@ -93,7 +93,7 @@ enum
{ \ { \
/* Write out the shift sequence. */ \ /* Write out the shift sequence. */ \
*outbuf++ = SI; \ *outbuf++ = SI; \
if (data->__is_last) \ if (data->__flags & __GCONV_IS_LAST) \
*written += 1; \ *written += 1; \
data->__outbuf = outbuf; \ data->__outbuf = outbuf; \
data->__statep->__count = ASCII_set; \ data->__statep->__count = ASCII_set; \
@ -122,11 +122,18 @@ enum
\ \
/* This is a 7bit character set, disallow all 8bit characters. */ \ /* This is a 7bit character set, disallow all 8bit characters. */ \
if (ch > 0x7f) \ if (ch > 0x7f) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* Recognize escape sequences. */ \ /* Recognize escape sequences. */ \
if (ch == ESC) \ if (ch == ESC) \
{ \ { \
@ -187,9 +194,16 @@ enum
ch = cns11643l2_to_ucs4 (&inptr, 2, 0); \ ch = cns11643l2_to_ucs4 (&inptr, 2, 0); \
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
inptr -= 2; \ inptr -= 2; \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
continue; \
} \ } \
} \ } \
else if (set == ASCII_set) \ else if (set == ASCII_set) \
@ -217,8 +231,16 @@ enum
} \ } \
else if (ch == __UNKNOWN_10646_CHAR) \ else if (ch == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
} \ } \
\ \
@ -305,8 +327,15 @@ enum
else \ else \
{ \ { \
/* Even this does not work. Error. */ \ /* Even this does not work. Error. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
} \ } \

View File

@ -217,7 +217,7 @@ gconv_end (struct __gconv_step *data)
*outbuf++ = ESC; \ *outbuf++ = ESC; \
*outbuf++ = '('; \ *outbuf++ = '('; \
*outbuf++ = 'B'; \ *outbuf++ = 'B'; \
if (data->__is_last) \ if (data->__flags & __GCONV_IS_LAST) \
*written += 3; \ *written += 3; \
data->__outbuf = outbuf; \ data->__outbuf = outbuf; \
/* Note that this also clears the G2 designation. */ \ /* Note that this also clears the G2 designation. */ \
@ -361,22 +361,43 @@ gconv_end (struct __gconv_step *data)
{ \ { \
/* We use the table from the ISO 8859-7 module. */ \ /* We use the table from the ISO 8859-7 module. */ \
if (inptr[2] < 0x20 || inptr[2] > 0x80) \ if (inptr[2] < 0x20 || inptr[2] > 0x80) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
ch = iso88597_to_ucs4[inptr[2] - 0x20]; \ ch = iso88597_to_ucs4[inptr[2] - 0x20]; \
if (ch == 0) \ if (ch == 0) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 3; \
++*converted; \
continue; \
} \ } \
inptr += 3; \ inptr += 3; \
} \ } \
else \ else \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
} \ } \
else if (set == ASCII_set || (ch < 0x21 || ch == 0x7f)) \ else if (set == ASCII_set || (ch < 0x21 || ch == 0x7f)) \
@ -387,9 +408,16 @@ gconv_end (struct __gconv_step *data)
/* Use the JIS X 0201 table. */ \ /* Use the JIS X 0201 table. */ \
ch = jisx0201_to_ucs4 (ch); \ ch = jisx0201_to_ucs4 (ch); \
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
++inptr; \ ++inptr; \
} \ } \
@ -398,9 +426,16 @@ gconv_end (struct __gconv_step *data)
/* Use the JIS X 0201 table. */ \ /* Use the JIS X 0201 table. */ \
ch = jisx0201_to_ucs4 (ch + 0x80); \ ch = jisx0201_to_ucs4 (ch + 0x80); \
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
++inptr; \ ++inptr; \
} \ } \
@ -436,9 +471,16 @@ gconv_end (struct __gconv_step *data)
break; \ break; \
} \ } \
else if (ch == __UNKNOWN_10646_CHAR) \ else if (ch == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
} \ } \
\ \
@ -672,8 +714,13 @@ gconv_end (struct __gconv_step *data)
else if (var == iso2022jp) \ else if (var == iso2022jp) \
{ \ { \
/* We have no other choice. */ \ /* We have no other choice. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
} \ } \
else \ else \
{ \ { \
@ -838,9 +885,14 @@ gconv_end (struct __gconv_step *data)
*outptr++ = gch; \ *outptr++ = gch; \
} \ } \
else \ else \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
} \ } \
} \ } \
} \ } \

View File

@ -95,7 +95,7 @@ enum
{ \ { \
/* Write out the shift sequence. */ \ /* Write out the shift sequence. */ \
*outbuf++ = SI; \ *outbuf++ = SI; \
if (data->__is_last) \ if (data->__flags & __GCONV_IS_LAST) \
*written += 1; \ *written += 1; \
data->__outbuf = outbuf; \ data->__outbuf = outbuf; \
data->__statep->__count = ASCII_set; \ data->__statep->__count = ASCII_set; \
@ -124,11 +124,18 @@ enum
\ \
/* This is a 7bit character set, disallow all 8bit characters. */ \ /* This is a 7bit character set, disallow all 8bit characters. */ \
if (ch > 0x7f) \ if (ch > 0x7f) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
/* Recognize escape sequences. */ \ /* Recognize escape sequences. */ \
if (ch == ESC) \ if (ch == ESC) \
{ \ { \
@ -187,8 +194,16 @@ enum
} \ } \
else if (ch == __UNKNOWN_10646_CHAR) \ else if (ch == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
++inptr; \
continue; \
} \ } \
} \ } \
\ \
@ -240,9 +255,16 @@ enum
if (written == __UNKNOWN_10646_CHAR) \ if (written == __UNKNOWN_10646_CHAR) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\
++*converted; \
} \
else \
{ \
assert (written == 2); \ assert (written == 2); \
\ \
/* We use KSC 5601. */ \ /* We use KSC 5601. */ \
@ -260,6 +282,7 @@ enum
\ \
*outptr++ = buf[0]; \ *outptr++ = buf[0]; \
*outptr++ = buf[1]; \ *outptr++ = buf[1]; \
} \
} \ } \
\ \
/* Now that we wrote the output increment the input pointer. */ \ /* Now that we wrote the output increment the input pointer. */ \

View File

@ -405,13 +405,21 @@ gconv_end (struct __gconv_step *data)
/* Hopefully gcc can recognize that the following `if' is only true \ /* Hopefully gcc can recognize that the following `if' is only true \
when we reach the default case in the `switch' statement. */ \ when we reach the default case in the `switch' statement. */ \
if (failure == __GCONV_ILLEGAL_INPUT) \ if (failure == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
/* Exit the loop with an error. */ \ /* Exit the loop with an error. */ \
result = failure; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\
++*converted; \
} \
else \
{ \
put32 (outptr, ch); \ put32 (outptr, ch); \
outptr += 4; \ outptr += 4; \
} \
++inptr; \ ++inptr; \
} }
#define EXTRA_LOOP_DECLS , enum variant var #define EXTRA_LOOP_DECLS , enum variant var
@ -874,11 +882,17 @@ gconv_end (struct __gconv_step *data)
} \ } \
\ \
if (failure == __GCONV_ILLEGAL_INPUT) \ if (failure == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \ { \
/* Exit the loop with an error. */ \ /* Exit the loop with an error. */ \
result = failure; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\
++*converted; \
} \
else \
*outptr++ = (unsigned char) ch; \ *outptr++ = (unsigned char) ch; \
inptr += 4; \ inptr += 4; \
} }

View File

@ -1,5 +1,5 @@
/* Conversion to and from ISO 8859-1. /* Conversion to and from ISO 8859-1.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -48,9 +48,15 @@
if (ch > 0xff) \ if (ch > 0xff) \
{ \ { \
/* We have an illegal character. */ \ /* We have an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\
++*converted; \
} \
else \
*outptr++ = (unsigned char) ch; \ *outptr++ = (unsigned char) ch; \
inptr += 4; \ inptr += 4; \
} }

View File

@ -418,30 +418,54 @@ static const char from_ucs4[][2] =
if (ch2 < 0x20 || ch2 >= 0x80) \ if (ch2 < 0x20 || ch2 >= 0x80) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\ \
if (ch == 0) \ if (ch == 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
else \ else \
{ \ { \
ch = to_ucs4[ch]; \ ch = to_ucs4[ch]; \
\ \
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
++inptr; \ ++inptr; \
} \ } \
@ -543,15 +567,30 @@ static const char from_ucs4[][2] =
if (fail) \ if (fail) \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
else if (from_ucs4[ch][0] == '\0' && ch != 0) \ else if (from_ucs4[ch][0] == '\0' && ch != 0) \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
else \ else \
cp = from_ucs4[ch]; \ cp = from_ucs4[ch]; \
@ -563,6 +602,7 @@ static const char from_ucs4[][2] =
if (NEED_LENGTH_TEST && outptr >= outend) \ if (NEED_LENGTH_TEST && outptr >= outend) \
{ \ { \
/* The result does not fit into the buffer. */ \ /* The result does not fit into the buffer. */ \
--outptr; \
result = __GCONV_FULL_OUTPUT; \ result = __GCONV_FULL_OUTPUT; \
break; \ break; \
} \ } \

View File

@ -410,30 +410,54 @@ static const char from_ucs4[][2] =
if (ch2 < 0x20 || ch2 >= 0x80) \ if (ch2 < 0x20 || ch2 >= 0x80) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\ \
if (ch == 0) \ if (ch == 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
else \ else \
{ \ { \
ch = to_ucs4[ch]; \ ch = to_ucs4[ch]; \
\ \
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
++inptr; \ ++inptr; \
} \ } \
@ -514,15 +538,30 @@ static const char from_ucs4[][2] =
if (fail) \ if (fail) \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
else if (from_ucs4[ch][0] == '\0' && ch != 0) \ else if (from_ucs4[ch][0] == '\0' && ch != 0) \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++*converted; \
inptr += 4; \
continue; \
} \ } \
else \ else \
cp = from_ucs4[ch]; \ cp = from_ucs4[ch]; \
@ -534,6 +573,7 @@ static const char from_ucs4[][2] =
if (NEED_LENGTH_TEST && outptr >= outend) \ if (NEED_LENGTH_TEST && outptr >= outend) \
{ \ { \
/* The result does not fit into the buffer. */ \ /* The result does not fit into the buffer. */ \
--outptr; \
result = __GCONV_FULL_OUTPUT; \ result = __GCONV_FULL_OUTPUT; \
break; \ break; \
} \ } \

View File

@ -183,8 +183,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
|| (ch > 0xd3 && ch < 0xd9)) \ || (ch > 0xd3 && ch < 0xd9)) \
{ \ { \
/* These are illegal. */ \ /* These are illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -215,8 +223,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
if (i == -1 || m == -1 || f == -1) \ if (i == -1 || m == -1 || f == -1) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else if (i > 0 && m > 0) \ else if (i > 0 && m > 0) \
ch = ((i - 1) * 21 + (m - 1)) * 28 + f + 0xac00; \ ch = ((i - 1) * 21 + (m - 1)) * 28 + f + 0xac00; \
@ -229,8 +245,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
else \ else \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
} \ } \
else \ else \
@ -238,15 +262,31 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff) \ if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4) \ else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4) \
{ \ { \
/* This is illegal. Modern Hangul Jaso is defined \ /* This is illegal. Modern Hangul Jaso is defined \
elsewhere in Johab */ \ elsewhere in Johab */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -265,6 +305,9 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \ } \
\ \
if (ch == 0) \ if (ch == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
@ -272,6 +315,11 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
\ \
put32 (outptr, ch); \ put32 (outptr, ch); \
@ -354,10 +402,18 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \ } \
if (written == __UNKNOWN_10646_CHAR) \ if (written == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
outptr[0] -= 0x4a; \ outptr[0] -= 0x4a; \
outptr[1] -= 0x21; \ outptr[1] -= 0x21; \
\ \
@ -383,10 +439,18 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \ } \
if (written == __UNKNOWN_10646_CHAR) \ if (written == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
outptr[0] -= 0x4a; \ outptr[0] -= 0x4a; \
outptr[1] += 0x80; \ outptr[1] += 0x80; \
\ \

View File

@ -4354,11 +4354,19 @@ static const char from_ucs4_extra[0x100][2] =
ch = halfkana_to_ucs4[ch - 0xa1]; \ ch = halfkana_to_ucs4[ch - 0xa1]; \
++inptr; \ ++inptr; \
} \ } \
else if (ch > 0xea || ch == 0xa0 || ch == 0x7f || ch == 0x80) \ else if (ch > 0xea || ch == 0xa0 || ch <= 0x80) \
{ \ { \
/* These are illegal. */ \ /* These are illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -4382,8 +4390,16 @@ static const char from_ucs4_extra[0x100][2] =
|| (idx > 0x9ffc && idx < 0xe040) || idx > 0xeaa4) \ || (idx > 0x9ffc && idx < 0xe040) || idx > 0xeaa4) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -4403,10 +4419,18 @@ static const char from_ucs4_extra[0x100][2] =
} \ } \
\ \
if (ch == 0) \ if (ch == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 2; \
++*converted; \
continue; \
} \ } \
} \ } \
\ \
@ -4437,8 +4461,16 @@ static const char from_ucs4_extra[0x100][2] =
else \ else \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
else \ else \
@ -4447,12 +4479,19 @@ static const char from_ucs4_extra[0x100][2] =
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal character. */ \ /* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
*outptr++ = cp[0]; \ *outptr++ = cp[0]; \
/* Now test for a possible second byte and write this if possible. */ \ /* Now test for a possible second byte and write this if possible. */\
if (cp[1] != '\0') \ if (cp[1] != '\0') \
{ \ { \
if (NEED_LENGTH_TEST && outptr >= outend) \ if (NEED_LENGTH_TEST && outptr >= outend) \
@ -4462,6 +4501,7 @@ static const char from_ucs4_extra[0x100][2] =
break; \ break; \
} \ } \
*outptr++ = cp[1]; \ *outptr++ = cp[1]; \
} \
} \ } \
\ \
inptr += 4; \ inptr += 4; \

View File

@ -401,10 +401,18 @@ static const char from_ucs4[][2] =
if (ch2 < 0x20 || ch2 >= 0x80) \ if (ch2 < 0x20 || ch2 >= 0x80) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\ \
inptr += 2; \ inptr += 2; \
@ -418,12 +426,21 @@ static const char from_ucs4[][2] =
if (ch == 0 && *inptr != '\0') \ if (ch == 0 && *inptr != '\0') \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
--inptr; \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
put32 (outptr, ch); \ put32 (outptr, ch); \
outptr += 4; \ outptr += 4; \
} \
} }
#include <iconv/loop.c> #include <iconv/loop.c>
@ -448,8 +465,16 @@ static const char from_ucs4[][2] =
else if (ch < 0x2d8 || ch > 0x2dd || ch == 0x02dc) \ else if (ch < 0x2d8 || ch > 0x2dd || ch == 0x02dc) \
{ \ { \
/* Illegal characters. */ \ /* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -467,8 +492,16 @@ static const char from_ucs4[][2] =
if (cp[0] == '\0' && ch != 0) \ if (cp[0] == '\0' && ch != 0) \
{ \ { \
/* Illegal. */ \ /* Illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 4; \
++*converted; \
continue; \
} \ } \
} \ } \
\ \

View File

@ -3066,8 +3066,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
else if (ch <= 0x80 || ch >= 0xfe || ch == 0xc9) \ else if (ch <= 0x80 || ch >= 0xfe || ch == 0xc9) \
{ \ { \
/* This is illegal. */ \ /* This is illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
++inptr; \
++*converted; \
continue; \
} \ } \
else \ else \
{ \ { \
@ -3109,10 +3117,18 @@ static const char uhc_hangul_from_ucs[11172][2] =
|| (ch2 > 0x7a && ch2 < 0x81) || (ch == 0xc6 && ch2 > 0x52)) \ || (ch2 > 0x7a && ch2 < 0x81) || (ch == 0xc6 && ch2 > 0x52)) \
{ \ { \
/* This is not legal. */ \ /* This is not legal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++inptr; \
++*converted; \
continue; \
} \
\
ch = uhc_extra_to_ucs[ch2 - 0x41 \ ch = uhc_extra_to_ucs[ch2 - 0x41 \
- (ch2 > 0x80 ? 12 : (ch2 > 0x60 ? 6 : 0)) \ - (ch2 > 0x80 ? 12 : (ch2 > 0x60 ? 6 : 0)) \
+ (ch < 0xa1 \ + (ch < 0xa1 \
@ -3120,6 +3136,9 @@ static const char uhc_hangul_from_ucs[11172][2] =
: 5696 + (ch - 0xa1) * 84)]; \ : 5696 + (ch - 0xa1) * 84)]; \
\ \
if (ch == 0) \ if (ch == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \ { \
/* This is an illegal character. */ \ /* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
@ -3127,6 +3146,11 @@ static const char uhc_hangul_from_ucs[11172][2] =
} \ } \
\ \
inptr += 2; \ inptr += 2; \
++*converted; \
continue; \
} \
\
inptr += 2; \
} \ } \
else \ else \
{ \ { \
@ -3134,8 +3158,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
if (ch == __UNKNOWN_10646_CHAR) \ if (ch == __UNKNOWN_10646_CHAR) \
{ \ { \
/* Illegal. */ \ /* Illegal. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \
\
inptr += 2; \
++*converted; \
continue; \
} \ } \
} \ } \
} \ } \
@ -3184,10 +3216,18 @@ static const char uhc_hangul_from_ucs[11172][2] =
} \ } \
if (written == __UNKNOWN_10646_CHAR) \ if (written == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
*outptr++ |= 0x80; \ *outptr++ |= 0x80; \
*outptr++ |= 0x80; \ *outptr++ |= 0x80; \
} \ } \
@ -3208,10 +3248,18 @@ static const char uhc_hangul_from_ucs[11172][2] =
} \ } \
if (written == __UNKNOWN_10646_CHAR) \ if (written == __UNKNOWN_10646_CHAR) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
inptr += 4; \
++*converted; \
continue; \
} \
\
*outptr++ |= 0x80; \ *outptr++ |= 0x80; \
*outptr++ |= 0x80; \ *outptr++ |= 0x80; \
} \ } \

View File

@ -151,13 +151,21 @@ gconv_end (struct __gconv_step *data)
\ \
if (c >= 0x10000) \ if (c >= 0x10000) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
} \
else \
{ \
put16 (outptr, c); \ put16 (outptr, c); \
\
outptr += 2; \ outptr += 2; \
} \
\
inptr += 4; \ inptr += 4; \
} }
#define EXTRA_LOOP_DECLS \ #define EXTRA_LOOP_DECLS \

View File

@ -201,10 +201,18 @@ gconv_end (struct __gconv_step *data)
{ \ { \
if (c >= 0x110000) \ if (c >= 0x110000) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
inptr += 4; \
continue; \
} \
\
/* Generate a surrogate character. */ \ /* Generate a surrogate character. */ \
if (NEED_LENGTH_TEST && outptr + 4 > outend) \ if (NEED_LENGTH_TEST && outptr + 4 > outend) \
{ \ { \
@ -226,10 +234,18 @@ gconv_end (struct __gconv_step *data)
{ \ { \
if (c >= 0x110000) \ if (c >= 0x110000) \
{ \ { \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
result = __GCONV_ILLEGAL_INPUT; \ result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
inptr += 4; \
continue; \
} \
\
/* Generate a surrogate character. */ \ /* Generate a surrogate character. */ \
if (NEED_LENGTH_TEST && outptr + 4 > outend) \ if (NEED_LENGTH_TEST && outptr + 4 > outend) \
{ \ { \
@ -291,11 +307,17 @@ gconv_end (struct __gconv_step *data)
if (u2 < 0xdc00 || u2 >= 0xdfff) \ if (u2 < 0xdc00 || u2 >= 0xdfff) \
{ \ { \
/* This is no valid second word for a surrogate. */ \ /* This is no valid second word for a surrogate. */ \
result = __GCONV_ILLEGAL_INPUT; \ if (! ignore_errors_p ()) \
{ \
inptr -= 2; \ inptr -= 2; \
result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
continue; \
} \
\
put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \ put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \
inptr += 2; \ inptr += 2; \
} \ } \
@ -327,11 +349,17 @@ gconv_end (struct __gconv_step *data)
if (u2 < 0xdc00 || u2 >= 0xdfff) \ if (u2 < 0xdc00 || u2 >= 0xdfff) \
{ \ { \
/* This is no valid second word for a surrogate. */ \ /* This is no valid second word for a surrogate. */ \
result = __GCONV_ILLEGAL_INPUT; \ if (! ignore_errors_p ()) \
{ \
inptr -= 2; \ inptr -= 2; \
result = __GCONV_ILLEGAL_INPUT; \
break; \ break; \
} \ } \
\ \
++*converted; \
continue; \
} \
\
put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \ put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \
inptr += 2; \ inptr += 2; \
} \ } \

View File

@ -299,7 +299,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
cc->__cd_in.__cd.__data[0].__invocation_counter = 0; cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
cc->__cd_in.__cd.__data[0].__internal_use = 1; cc->__cd_in.__cd.__data[0].__internal_use = 1;
cc->__cd_in.__cd.__data[0].__is_last = 1; cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST;
cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state; cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
cc->__cd_out.__cd.__nsteps = 1; /* Only one step allowed. */ cc->__cd_out.__cd.__nsteps = 1; /* Only one step allowed. */
@ -307,7 +307,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
cc->__cd_out.__cd.__data[0].__invocation_counter = 0; cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
cc->__cd_out.__cd.__data[0].__internal_use = 1; cc->__cd_out.__cd.__data[0].__internal_use = 1;
cc->__cd_out.__cd.__data[0].__is_last = 1; cc->__cd_out.__cd.__data[0].__flags = __GCONV_IS_LAST;
cc->__cd_out.__cd.__data[0].__statep = &result->_wide_data->_IO_state; cc->__cd_out.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
/* Set the mode now. */ /* Set the mode now. */

View File

@ -121,7 +121,7 @@ _IO_fwide (fp, mode)
cc->__cd_in.__cd.__data[0].__invocation_counter = 0; cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
cc->__cd_in.__cd.__data[0].__internal_use = 1; cc->__cd_in.__cd.__data[0].__internal_use = 1;
cc->__cd_in.__cd.__data[0].__is_last = 1; cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST;
cc->__cd_in.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; cc->__cd_in.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
cc->__cd_out.__cd.__nsteps = 1; /* Only one step allowed. */ cc->__cd_out.__cd.__nsteps = 1; /* Only one step allowed. */
@ -129,7 +129,7 @@ _IO_fwide (fp, mode)
cc->__cd_out.__cd.__data[0].__invocation_counter = 0; cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
cc->__cd_out.__cd.__data[0].__internal_use = 1; cc->__cd_out.__cd.__data[0].__internal_use = 1;
cc->__cd_out.__cd.__data[0].__is_last = 1; cc->__cd_out.__cd.__data[0].__flags = __GCONV_IS_LAST;
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
} }
#else #else

View File

@ -46,7 +46,7 @@ __btowc (c)
data.__outbufend = data.__outbuf + sizeof (wchar_t); data.__outbufend = data.__outbuf + sizeof (wchar_t);
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = &data.__state; data.__statep = &data.__state;
/* Make sure we start in the initial state. */ /* Make sure we start in the initial state. */

View File

@ -46,7 +46,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
/* Set information for this step. */ /* Set information for this step. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
/* A first special case is if S is NULL. This means put PS in the /* A first special case is if S is NULL. This means put PS in the

View File

@ -54,7 +54,7 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
if (nmc == 0) if (nmc == 0)

View File

@ -50,7 +50,7 @@ __mbsrtowcs (dst, src, len, ps)
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
/* Make sure we use the correct function. */ /* Make sure we use the correct function. */

View File

@ -46,7 +46,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
/* Set information for this step. */ /* Set information for this step. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
/* A first special case is if S is NULL. This means put PS in the /* A first special case is if S is NULL. This means put PS in the

View File

@ -52,7 +52,7 @@ __wcsnrtombs (dst, src, nwc, len, ps)
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
if (nwc == 0) if (nwc == 0)

View File

@ -48,7 +48,7 @@ __wcsrtombs (dst, src, len, ps)
/* Tell where we want the result. */ /* Tell where we want the result. */
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state; data.__statep = ps ?: &state;
/* Make sure we use the correct function. */ /* Make sure we use the correct function. */

View File

@ -40,7 +40,7 @@ wctob (c)
data.__outbufend = buf + MB_LEN_MAX; data.__outbufend = buf + MB_LEN_MAX;
data.__invocation_counter = 0; data.__invocation_counter = 0;
data.__internal_use = 1; data.__internal_use = 1;
data.__is_last = 1; data.__flags = __GCONV_IS_LAST;
data.__statep = &data.__state; data.__statep = &data.__state;
/* Make sure we start in the initial state. */ /* Make sure we start in the initial state. */