* 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
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.
2000-06-04 Ulrich Drepper <drepper@redhat.com>
};
+/* Flags the `__gconv_open' function can set. */
+enum
+{
+ __GCONV_IS_LAST = 0x0001,
+ __GCONV_IGNORE_ERRORS = 0x0002
+};
+
+
/* Forward declarations. */
struct __gconv_step;
struct __gconv_step_data;
buffer. */
/* Is this the last module in the chain. */
- int __is_last;
+ int __flags;
/* Counter for number of invocations of the module function for this
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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
drunp = cd->__data;
do
{
- if (!drunp->__is_last && drunp->__outbuf != NULL)
+ if (!(drunp->__flags & __GCONV_IS_LAST) && drunp->__outbuf != NULL)
free (drunp->__outbuf);
}
- while (!(drunp++)->__is_last);
+ while (!((drunp++)->__flags & __GCONV_IS_LAST));
/* Free the data allocated for the descriptor. */
free (cd);
__gconv_t result = NULL;
size_t cnt = 0;
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);
if (res == __GCONV_OK)
{
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
output buffer. */
- result->__data[cnt].__is_last = 0;
+ result->__data[cnt].__flags = conv_flags;
+#if 0
/* Reset the counter. */
result->__data[cnt].__invocation_counter = 0;
/* It's a regular use. */
result->__data[cnt].__internal_use = 0;
+#endif
/* We use the `mbstate_t' member in DATA. */
result->__data[cnt].__statep = &result->__data[cnt].__state;
}
/* 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].__internal_use = 0;
+#endif
result->__data[cnt].__statep = &result->__data[cnt].__state;
}
static inline int
internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
internal_ucs4_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
internal_ucs4_loop_single (const unsigned char **inptrp,
const unsigned char *inend,
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;
(*outptrp)[1] = state->__value.__wchb[2];
(*outptrp)[2] = state->__value.__wchb[1];
(*outptrp)[3] = state->__value.__wchb[0];
+
+ *outptrp += 4;
#elif __BYTE_ORDER == __BIG_ENDIAN
/* XXX unaligned */
*(*((uint32_t **) outptrp)++) = state->__value.__wch;
static inline int
ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
if (inval > 0x7fffffff)
{
+ if (flags & __GCONV_IGNORE_ERRORS)
+ {
+ /* Just ignore this character. */
+ ++*converted;
+ continue;
+ }
+
*inptrp = inptr;
*outptrp = outptr;
return __GCONV_ILLEGAL_INPUT;
ucs4_internal_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
if (inptr[0] > 0x80)
{
/* The value is too large. */
+ if (flags & __GCONV_IGNORE_ERRORS)
+ {
+ /* Just ignore this character. */
+ ++*converted;
+ continue;
+ }
+
*inptrp = inptr;
*outptrp = outptr;
return __GCONV_ILLEGAL_INPUT;
ucs4_internal_loop_single (const unsigned char **inptrp,
const unsigned char *inend,
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;
}
if (((unsigned char *) state->__value.__wchb)[0] > 0x80)
- /* The value is too large. */
- return __GCONV_ILLEGAL_INPUT;
-
+ {
+ /* The value is too large. */
+ if (!(flags & __GCONV_IGNORE_ERRORS))
+ return __GCONV_ILLEGAL_INPUT;
+ }
+ else
+ {
#if __BYTE_ORDER == __LITTLE_ENDIAN
- (*outptrp)[0] = state->__value.__wchb[3];
- (*outptrp)[1] = state->__value.__wchb[2];
- (*outptrp)[2] = state->__value.__wchb[1];
- (*outptrp)[3] = state->__value.__wchb[0];
+ (*outptrp)[0] = state->__value.__wchb[3];
+ (*outptrp)[1] = state->__value.__wchb[2];
+ (*outptrp)[2] = state->__value.__wchb[1];
+ (*outptrp)[3] = state->__value.__wchb[0];
#elif __BYTE_ORDER == __BIG_ENDIAN
- (*outptrp)[0] = state->__value.__wchb[0];
- (*outptrp)[1] = state->__value.__wchb[1];
- (*outptrp)[2] = state->__value.__wchb[2];
- (*outptrp)[3] = state->__value.__wchb[3];
+ (*outptrp)[0] = state->__value.__wchb[0];
+ (*outptrp)[1] = state->__value.__wchb[1];
+ (*outptrp)[2] = state->__value.__wchb[2];
+ (*outptrp)[3] = state->__value.__wchb[3];
#endif
+ *outptrp += 4;
+ }
+
/* Clear the state buffer. */
state->__count &= ~7;
static inline int
internal_ucs4le_loop (const unsigned char **inptrp, const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
internal_ucs4le_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend,
- mbstate_t *state, void *data,
+ mbstate_t *state, int flags, void *data,
size_t *converted)
{
const unsigned char *inptr = *inptrp;
internal_ucs4le_loop_single (const unsigned char **inptrp,
const unsigned char *inend,
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;
(*outptrp)[1] = state->__value.__wchb[2];
(*outptrp)[2] = state->__value.__wchb[1];
(*outptrp)[3] = state->__value.__wchb[0];
+
+ *outptrp += 4;
#else
/* XXX unaligned */
*(*((uint32_t **) outptrp)++) = state->__value.__wch;
static inline int
ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
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;
unsigned char *outptr = *outptrp;
#endif
if (inval > 0x7fffffff)
- return __GCONV_ILLEGAL_INPUT;
+ {
+ if (flags & __GCONV_IGNORE_ERRORS)
+ {
+ /* Just ignore this character. */
+ ++*converted;
+ continue;
+ }
+
+ return __GCONV_ILLEGAL_INPUT;
+ }
*((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr);
}
ucs4le_internal_loop_unaligned (const unsigned char **inptrp,
const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend,
- mbstate_t *state, void *data,
+ mbstate_t *state, int flags, void *data,
size_t *converted)
{
const unsigned char *inptr = *inptrp;
if (inptr[3] > 0x80)
{
/* The value is too large. */
+ if (flags & __GCONV_IGNORE_ERRORS)
+ {
+ /* Just ignore this character. */
+ ++*converted;
+ continue;
+ }
+
*inptrp = inptr;
*outptrp = outptr;
return __GCONV_ILLEGAL_INPUT;
}
-
# if __BYTE_ORDER == __BIG_ENDIAN
outptr[3] = inptr[0];
outptr[2] = inptr[1];
outptr[2] = inptr[2];
outptr[3] = inptr[3];
# endif
+
+ outptr += 4;
}
*inptrp = inptr;
ucs4le_internal_loop_single (const unsigned char **inptrp,
const unsigned char *inend,
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;
}
if (((unsigned char *) state->__value.__wchb)[3] > 0x80)
- /* The value is too large. */
- return __GCONV_ILLEGAL_INPUT;
-
+ {
+ /* The value is too large. */
+ if (!(flags & __GCONV_IGNORE_ERRORS))
+ return __GCONV_ILLEGAL_INPUT;
+ }
+ else
+ {
#if __BYTE_ORDER == __BIG_ENDIAN
- (*outptrp)[0] = state->__value.__wchb[3];
- (*outptrp)[1] = state->__value.__wchb[2];
- (*outptrp)[2] = state->__value.__wchb[1];
- (*outptrp)[3] = state->__value.__wchb[0];
+ (*outptrp)[0] = state->__value.__wchb[3];
+ (*outptrp)[1] = state->__value.__wchb[2];
+ (*outptrp)[2] = state->__value.__wchb[1];
+ (*outptrp)[3] = state->__value.__wchb[0];
#elif __BYTE_ORDER == __BIG_ENDIAN
- (*outptrp)[0] = state->__value.__wchb[0];
- (*outptrp)[1] = state->__value.__wchb[1];
- (*outptrp)[2] = state->__value.__wchb[2];
- (*outptrp)[3] = state->__value.__wchb[3];
+ (*outptrp)[0] = state->__value.__wchb[0];
+ (*outptrp)[1] = state->__value.__wchb[1];
+ (*outptrp)[2] = state->__value.__wchb[2];
+ (*outptrp)[3] = state->__value.__wchb[3];
#endif
+ *outptrp += 4;
+ }
+
/* Clear the state buffer. */
state->__count &= ~7;
{ \
if (*inptr > '\x7f') \
{ \
- /* This is no correct ANSI_X3.4-1968 character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is no correct ANSI_X3.4-1968 character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- /* It's an one byte sequence. */ \
- /* XXX unaligned. */ \
- *((uint32_t *) outptr)++ = *inptr++; \
+ ++*converted; \
+ ++inptr; \
+ } \
+ else \
+ /* It's an one byte sequence. */ \
+ /* XXX unaligned. */ \
+ *((uint32_t *) outptr)++ = *inptr++; \
}
#include <iconv/loop.c>
#include <iconv/skeleton.c>
{ \
if (*((uint32_t *) inptr) > 0x7f) \
{ \
- /* This is no correct ANSI_X3.4-1968 character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is no correct ANSI_X3.4-1968 character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- /* It's an one byte sequence. */ \
- *outptr++ = *((uint32_t *) inptr)++; \
+ ++*converted; \
+ inptr += 4; \
+ } \
+ else \
+ /* It's an one byte sequence. */ \
+ /* XXX unaligned. */ \
+ *outptr++ = *((uint32_t *) inptr)++; \
}
#include <iconv/loop.c>
#include <iconv/skeleton.c>
} \
else \
{ \
- /* This is an illegal encoding. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ int skipped; \
+ \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal encoding. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ 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) \
for (i = 1; inptr + i < inend; ++i) \
if ((inptr[i] & 0xc0) != 0x80) \
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; \
} \
\
ch <<= 6; \
ch |= byte & 0x3f; \
} \
- \
+ \
/* If i < cnt, some trail byte was not >= 0x80, < 0xc0. \
If cnt > 2 and ch < 2^(5*cnt-4), the wide character ch could \
have been represented with fewer than cnt bytes. */ \
- 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. */ \
+ if (ignore_errors_p ()) \
+ { \
+ inptr += i; \
+ ++*converted; \
+ continue; \
+ } \
+ \
result = __GCONV_ILLEGAL_INPUT; \
break; \
} \
{ \
if (*((uint32_t *) inptr) >= 0x10000) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
} \
- *((uint16_t *) outptr)++ = *((uint32_t *) inptr)++; \
+ else \
+ *((uint16_t *) outptr)++ = *((uint32_t *) inptr)++; \
}
#include <iconv/loop.c>
#include <iconv/skeleton.c>
uint32_t val = *((uint32_t *) inptr); \
if (val >= 0x10000) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
} \
*((uint16_t *) outptr)++ = bswap_16 (val); \
inptr += 4; \
/* Nonzero if list of all coded character sets is wanted. */
static int list;
+/* If nonzero omit invalid character from output. */
+static int omit_invalid;
+
/* 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_fd (iconv_t cd, int fd, FILE *output);
int remaining;
FILE *output;
iconv_t cd;
+ const char *orig_to_code;
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
if (to_code == NULL)
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. */
cd = iconv_open (to_code, from_code);
if (cd == (iconv_t) -1)
{
if (errno == EINVAL)
- error (EXIT_FAILURE, 0, _("conversion from `%s' to `%s' not supported"),
- from_code, to_code);
+ error (EXIT_FAILURE, 0,
+ _("conversion from `%s' to `%s' not supported"),
+ from_code, orig_to_code);
else
- error (EXIT_FAILURE, errno, _("failed to start conversion processing"));
+ error (EXIT_FAILURE, errno,
+ _("failed to start conversion processing"));
}
/* Determine output file. */
about missing character or so. */
break;
case 'c':
- /* Omit invalid characters from output.
- XXX This option will become a meaning once we have different
- modes of operation for the conversion functions. */
+ /* Omit invalid characters from output. */
+ omit_invalid = 1;
break;
case OPT_VERBOSE:
verbose = 1;
#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. */
static inline int
FCTNAME (LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend,
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)
{
int result = __GCONV_OK;
static inline int
SINGLE(LOOPFCT) (const unsigned char **inptrp, const unsigned char *inend,
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)
{
int result = __GCONV_OK;
{
struct __gconv_step *next_step = step + 1;
struct __gconv_step_data *next_data = data + 1;
- __gconv_fct fct = data->__is_last ? NULL : next_step->__fct;
+ __gconv_fct fct;
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
to the initial state. The possibly partly converted input is
dropped. */
#endif
/* Call the steps down the chain if there are any but only if we
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,
written, 1, consume_incomplete));
}
# if MAX_NEEDED_FROM > 1
if (MAX_NEEDED_TO == 1 || FROM_DIRECTION)
status = SINGLE(FROM_LOOP) (inptrp, inend, &outbuf, outend,
- data->__statep, step->__data,
- &converted EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted
+ EXTRA_LOOP_ARGS);
# endif
# if MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1 && !ONE_DIRECTION
else
# endif
# if MAX_NEEDED_TO > 1 && !ONE_DIRECTION
status = SINGLE(TO_LOOP) (inptrp, inend, &outbuf, outend,
- data->__statep, step->__data,
- &converted EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted
+ EXTRA_LOOP_ARGS);
# endif
if (status != __GCONV_OK)
for all known and supported encodings. */
unaligned = ((FROM_DIRECTION
&& ((uintptr_t) inptr % MIN_NEEDED_FROM != 0
- || (data->__is_last
+ || ((data->__flags & __GCONV_IS_LAST)
&& (uintptr_t) outbuf % MIN_NEEDED_TO != 0)))
|| (!FROM_DIRECTION
- && ((data->__is_last
+ && (((data->__flags & __GCONV_IS_LAST)
&& (uintptr_t) outbuf % MIN_NEEDED_FROM != 0)
|| (uintptr_t) inptr % MIN_NEEDED_TO != 0)));
#endif
if (FROM_DIRECTION)
/* Run the conversion loop. */
status = FROM_LOOP (inptrp, inend, &outbuf, outend,
- data->__statep, step->__data, &converted
- EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
status = TO_LOOP (inptrp, inend, &outbuf, outend,
- data->__statep, step->__data, &converted
- EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted EXTRA_LOOP_ARGS);
}
#if !defined _STRING_ARCH_unaligned \
&& MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
/* Run the conversion loop. */
status = GEN_unaligned (FROM_LOOP) (inptrp, inend, &outbuf,
outend, data->__statep,
+ data->__flags,
step->__data, &converted
EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
status = GEN_unaligned (TO_LOOP) (inptrp, inend, &outbuf,
outend, data->__statep,
+ data->__flags,
step->__data, &converted
EXTRA_LOOP_ARGS);
}
/* If this is the last step leave the loop, there is nothing
we can do. */
- if (data->__is_last)
+ if (data->__flags & __GCONV_IS_LAST)
{
/* Store information about how many bytes are available. */
data->__outbuf = outbuf;
SAVE_RESET_STATE (0);
# endif
+ /* XXX Handle unaligned access here as well. */
if (FROM_DIRECTION)
/* Run the conversion loop. */
nstatus = FROM_LOOP ((const unsigned char **) inptrp,
(const unsigned char *) inend,
(unsigned char **) &outbuf,
(unsigned char *) outerr,
- data->__statep, step->__data,
- &converted EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted
+ EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
nstatus = TO_LOOP ((const unsigned char **) inptrp,
(const unsigned char *) inend,
(unsigned char **) &outbuf,
(unsigned char *) outerr,
- data->__statep, step->__data,
- &converted EXTRA_LOOP_ARGS);
+ data->__statep, data->__flags,
+ step->__data, &converted
+ EXTRA_LOOP_ARGS);
/* We must run out of output buffer space in this
rerun. */
if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ } \
+ else \
+ { \
+ put32 (outptr, ch); \
+ outptr += 4; \
} \
\
- put32 (outptr, ch); \
- outptr += 4; \
++inptr; \
}
#include <iconv/loop.c>
if (ch >= 0xffff) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
while (ch > rp->end) \
++rp; \
if (ch < rp->start) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
\
res = from_ucs4[ch + rp->idx]; \
if (ch != 0 && res == '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
\
*outptr++ = res; \
if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
\
put32 (outptr, ch); \
|| (ch != 0 && from_ucs4[ch] == '\0')) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
+ else \
+ *outptr++ = from_ucs4[ch]; \
\
- *outptr++ = from_ucs4[ch]; \
inptr += 4; \
}
#include <iconv/loop.c>
if (ch2 < 0x20 || ch2 >= 0x80) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- incr = 2; \
+ ++*converted; \
+ incr = 1; \
+ } \
+ else \
+ { \
+ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
+ incr = 2; \
+ } \
} \
else \
{ \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ } \
+ else \
+ { \
+ put32 (outptr, ch); \
+ outptr += 4; \
} \
\
inptr += incr; \
- put32 (outptr, ch); \
- outptr += 4; \
}
#include <iconv/loop.c>
if (tmp[0] == '\0') \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
tmp[1] = '\0'; \
cp = tmp; \
cp = "\xd7"; \
else if (ch == 0x253c) \
cp = "\xe5"; \
- else if (ch >= 0x2571 && ch <= 0x2572) \
+ else if (ch >= 0x2571 && ch <= 0x2572) \
{ \
tmp[0] = 0xd8 + ch - 0x2571; \
tmp[1] = '\0'; \
cp = tmp; \
} \
- else if (ch >= 0x25e2 && ch <= 0x25e3) \
+ else if (ch >= 0x25e2 && ch <= 0x25e3) \
{ \
tmp[0] = 0xda + ch - 0x25e2; \
tmp[1] = '\0'; \
else \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
} \
else \
\
if (cp[0] == '\0' && ch != 0) \
{ \
- /* Illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ /* Illegal characters. */ \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
} \
\
else \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* Get the value from the table. */ \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (cp[0] == '\0' && ch != 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- /* See whether there is enough room for the second byte we write. */ \
- if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
+ ++*converted; \
+ } \
+ else \
{ \
- /* We have not enough room. */ \
- result = __GCONV_FULL_OUTPUT; \
- break; \
+ /* See whether there is enough room for the second byte we write. */ \
+ if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
+ { \
+ /* We have not enough room. */ \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
+ \
+ *outptr++ = cp[0]; \
+ if (cp[1] != '\0') \
+ *outptr++ = cp[1]; \
} \
\
- *outptr++ = cp[0]; \
- if (cp[1] != '\0') \
- *outptr++ = cp[1]; \
inptr += 4; \
}
#include <iconv/loop.c>
else \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* Get the value from the table. */ \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (cp[0] == '\0' && ch != 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- /* See whether there is enough room for the second byte we write. */ \
- if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
+ ++*converted; \
+ } \
+ else \
{ \
- /* We have not enough room. */ \
- result = __GCONV_FULL_OUTPUT; \
- break; \
+ /* See whether there is enough room for the second byte we write. */ \
+ if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend) \
+ { \
+ /* We have not enough room. */ \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
+ \
+ *outptr++ = cp[0]; \
+ if (cp[1] != '\0') \
+ *outptr++ = cp[1]; \
} \
\
- *outptr++ = cp[0]; \
- if (cp[1] != '\0') \
- *outptr++ = cp[1]; \
inptr += 4; \
}
#include <iconv/loop.c>
if (ch <= 0x7f) \
++inptr; \
else \
- if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f) \
+ if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
/* All second bytes of a multibyte character must be >= 0xa1. */ \
if (ch < 0xa1) \
{ \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* This is code set 1: GB 2312-80. */ \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (found == __UNKNOWN_10646_CHAR) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
/* It's a GB 2312 character, adjust it for EUC-CN. */ \
\
if (ch <= 0x7f) \
++inptr; \
- else if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f) \
+ else if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (ch2 < 0xa1) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
if (ch == 0x8e) \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
inptr = endp; \
} \
else \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
} \
else if (ch <= 0xa0 || ch > 0xfe || ch == 0xc9) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
} \
\
if (cp[0] == '\0' && ch != 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
*outptr++ = cp[0]; \
ch = (ch << 8) | inptr[1]; \
\
/* 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. */ \
+ || (ch >= 0xa2a1 && ch <= 0xa2aa) \
+ || (ch >= 0xa6e0 && ch <= 0xa6f5) \
+ || (ch >= 0xa8bb && ch <= 0xa8c0)) \
{ \
- /* So far so good. Now test the exceptions. */ \
- if ((ch >= 0xa2a1 && ch <= 0xa2aa) \
- || (ch >= 0xa6e0 && ch <= 0xa6f5) \
- || (ch >= 0xa8bb && ch <= 0xa8c0)) \
+ /* One of the characters we cannot map. */ \
+ if (! ignore_errors_p ()) \
{ \
- /* One of the exceptions. */ \
result = __GCONV_ILLEGAL_INPUT; \
break; \
} \
+ \
+ inptr += 2; \
+ ++*converted; \
} \
else \
{ \
- /* One of the characters we cannot map. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ /* Copy the two bytes. */ \
+ *outptr++ = *inptr++; \
+ *outptr++ = *inptr++; \
} \
- \
- /* Copy the two bytes. */ \
- *outptr++ = *inptr++; \
- *outptr++ = *inptr++; \
} \
}
#include <iconv/loop.c>
if (ch <= 0x80 || ch > 0xfe) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (ch2 < 0x40) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* This is code set 1: GBK. */ \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (cp == NULL || (cp[0] == '\0' && ch != 0)) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
+ ++*converted; \
+ } \
/* 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. */ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
- \
- *outptr++ = cp[0]; \
- if (cp[1] != '\0') \
- *outptr++ = cp[1]; \
+ else \
+ { \
+ *outptr++ = cp[0]; \
+ if (cp[1] != '\0') \
+ *outptr++ = cp[1]; \
+ } \
} \
\
inptr += 4; \
{ \
/* Write out the shift sequence. */ \
*outbuf++ = SI; \
- if (data->__is_last) \
+ if (data->__flags & __GCONV_IS_LAST) \
*written += 1; \
data->__outbuf = outbuf; \
data->__statep->__count = ASCII_set; \
/* This is a 7bit character set, disallow all 8bit characters. */ \
if (ch > 0x7f) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* Recognize escape sequences. */ \
ch = cns11643l2_to_ucs4 (&inptr, 2, 0); \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
- inptr -= 2; \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ inptr -= 2; \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ continue; \
} \
} \
else if (set == ASCII_set) \
} \
else if (ch == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
} \
\
else \
{ \
/* Even this does not work. Error. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
} \
*outbuf++ = ESC; \
*outbuf++ = '('; \
*outbuf++ = 'B'; \
- if (data->__is_last) \
+ if (data->__flags & __GCONV_IS_LAST) \
*written += 3; \
data->__outbuf = outbuf; \
/* Note that this also clears the G2 designation. */ \
/* We use the table from the ISO 8859-7 module. */ \
if (inptr[2] < 0x20 || inptr[2] > 0x80) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
ch = iso88597_to_ucs4[inptr[2] - 0x20]; \
if (ch == 0) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 3; \
+ ++*converted; \
+ continue; \
} \
inptr += 3; \
} \
else \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
} \
else if (set == ASCII_set || (ch < 0x21 || ch == 0x7f)) \
ch = jisx0201_to_ucs4 (ch); \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
++inptr; \
} \
ch = jisx0201_to_ucs4 (ch + 0x80); \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
++inptr; \
} \
} \
else if (ch == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
} \
\
else if (var == iso2022jp) \
{ \
/* We have no other choice. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
else \
{ \
} \
else \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
} \
} \
{ \
/* Write out the shift sequence. */ \
*outbuf++ = SI; \
- if (data->__is_last) \
+ if (data->__flags & __GCONV_IS_LAST) \
*written += 1; \
data->__outbuf = outbuf; \
data->__statep->__count = ASCII_set; \
/* This is a 7bit character set, disallow all 8bit characters. */ \
if (ch > 0x7f) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
/* Recognize escape sequences. */ \
} \
else if (ch == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ ++inptr; \
+ continue; \
} \
} \
\
if (written == __UNKNOWN_10646_CHAR) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- assert (written == 2); \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- /* We use KSC 5601. */ \
- if (set != KSC5601_set) \
- { \
- *outptr++ = SO; \
- set = KSC5601_set; \
+ ++*converted; \
} \
- \
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ else \
{ \
- result = __GCONV_FULL_OUTPUT; \
- break; \
- } \
+ assert (written == 2); \
+ \
+ /* We use KSC 5601. */ \
+ if (set != KSC5601_set) \
+ { \
+ *outptr++ = SO; \
+ set = KSC5601_set; \
+ } \
+ \
+ if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ { \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
\
- *outptr++ = buf[0]; \
- *outptr++ = buf[1]; \
+ *outptr++ = buf[0]; \
+ *outptr++ = buf[1]; \
+ } \
} \
\
/* Now that we wrote the output increment the input pointer. */ \
when we reach the default case in the `switch' statement. */ \
if (failure == __GCONV_ILLEGAL_INPUT) \
{ \
- /* Exit the loop with an error. */ \
- result = failure; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* Exit the loop with an error. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ } \
+ else \
+ { \
+ put32 (outptr, ch); \
+ outptr += 4; \
} \
- put32 (outptr, ch); \
- outptr += 4; \
++inptr; \
}
#define EXTRA_LOOP_DECLS , enum variant var
\
if (failure == __GCONV_ILLEGAL_INPUT) \
{ \
- /* Exit the loop with an error. */ \
- result = failure; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* Exit the loop with an error. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
- *outptr++ = (unsigned char) ch; \
+ else \
+ *outptr++ = (unsigned char) ch; \
inptr += 4; \
}
#define EXTRA_LOOP_DECLS , enum variant var
/* 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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
if (ch > 0xff) \
{ \
/* We have an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
} \
- *outptr++ = (unsigned char) ch; \
+ else \
+ *outptr++ = (unsigned char) ch; \
inptr += 4; \
}
#include <iconv/loop.c>
if (ch2 < 0x20 || ch2 >= 0x80) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
if (ch == 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
++inptr; \
} \
if (fail) \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
else if (from_ucs4[ch][0] == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
else \
cp = from_ucs4[ch]; \
if (NEED_LENGTH_TEST && outptr >= outend) \
{ \
/* The result does not fit into the buffer. */ \
+ --outptr; \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
if (ch2 < 0x20 || ch2 >= 0x80) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
if (ch == 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
++inptr; \
} \
if (fail) \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
else if (from_ucs4[ch][0] == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
else \
cp = from_ucs4[ch]; \
if (NEED_LENGTH_TEST && outptr >= outend) \
{ \
/* The result does not fit into the buffer. */ \
+ --outptr; \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
|| (ch > 0xd3 && ch < 0xd9)) \
{ \
/* These are illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (i == -1 || m == -1 || f == -1) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else if (i > 0 && m > 0) \
ch = ((i - 1) * 21 + (m - 1)) * 28 + f + 0xac00; \
else \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
} \
else \
if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4) \
{ \
/* This is illegal. Modern Hangul Jaso is defined \
elsewhere in Johab */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (ch == 0) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
} \
if (written == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
outptr[0] -= 0x4a; \
} \
if (written == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
outptr[0] -= 0x4a; \
ch = halfkana_to_ucs4[ch - 0xa1]; \
++inptr; \
} \
- else if (ch > 0xea || ch == 0xa0 || ch == 0x7f || ch == 0x80) \
+ else if (ch > 0xea || ch == 0xa0 || ch <= 0x80) \
{ \
/* These are illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
|| (idx > 0x9ffc && idx < 0xe040) || idx > 0xeaa4) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (ch == 0) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
} \
\
else \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
else \
if (cp[0] == '\0' && ch != 0) \
{ \
/* Illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- *outptr++ = cp[0]; \
- /* Now test for a possible second byte and write this if possible. */ \
- if (cp[1] != '\0') \
+ ++*converted; \
+ } \
+ else \
{ \
- if (NEED_LENGTH_TEST && outptr >= outend) \
+ *outptr++ = cp[0]; \
+ /* Now test for a possible second byte and write this if possible. */\
+ if (cp[1] != '\0') \
{ \
- /* The result does not fit into the buffer. */ \
- result = __GCONV_FULL_OUTPUT; \
- break; \
+ if (NEED_LENGTH_TEST && outptr >= outend) \
+ { \
+ /* The result does not fit into the buffer. */ \
+ result = __GCONV_FULL_OUTPUT; \
+ break; \
+ } \
+ *outptr++ = cp[1]; \
} \
- *outptr++ = cp[1]; \
} \
\
inptr += 4; \
if (ch2 < 0x20 || ch2 >= 0x80) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ --inptr; \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- put32 (outptr, ch); \
- outptr += 4; \
+ ++*converted; \
+ } \
+ else \
+ { \
+ put32 (outptr, ch); \
+ outptr += 4; \
+ } \
}
#include <iconv/loop.c>
else if (ch < 0x2d8 || ch > 0x2dd || ch == 0x02dc) \
{ \
/* Illegal characters. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
if (cp[0] == '\0' && ch != 0) \
{ \
/* Illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
} \
\
else if (ch <= 0x80 || ch >= 0xfe || ch == 0xc9) \
{ \
/* This is illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
else \
{ \
|| (ch2 > 0x7a && ch2 < 0x81) || (ch == 0xc6 && ch2 > 0x52)) \
{ \
/* This is not legal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++inptr; \
+ ++*converted; \
+ continue; \
} \
\
ch = uhc_extra_to_ucs[ch2 - 0x41 \
if (ch == 0) \
{ \
/* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
\
inptr += 2; \
if (ch == __UNKNOWN_10646_CHAR) \
{ \
/* Illegal. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 2; \
+ ++*converted; \
+ continue; \
} \
} \
} \
} \
if (written == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
*outptr++ |= 0x80; \
} \
if (written == __UNKNOWN_10646_CHAR) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ inptr += 4; \
+ ++*converted; \
+ continue; \
} \
\
*outptr++ |= 0x80; \
\
if (c >= 0x10000) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
\
- put16 (outptr, c); \
+ ++*converted; \
+ } \
+ else \
+ { \
+ put16 (outptr, c); \
+ outptr += 2; \
+ } \
\
- outptr += 2; \
inptr += 4; \
}
#define EXTRA_LOOP_DECLS \
{ \
if (c >= 0x110000) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
\
/* Generate a surrogate character. */ \
{ \
if (c >= 0x110000) \
{ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ /* This is an illegal character. */ \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ inptr += 4; \
+ continue; \
} \
\
/* Generate a surrogate character. */ \
if (u2 < 0xdc00 || u2 >= 0xdfff) \
{ \
/* This is no valid second word for a surrogate. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- inptr -= 2; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ inptr -= 2; \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ continue; \
} \
\
put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \
if (u2 < 0xdc00 || u2 >= 0xdfff) \
{ \
/* This is no valid second word for a surrogate. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- inptr -= 2; \
- break; \
+ if (! ignore_errors_p ()) \
+ { \
+ inptr -= 2; \
+ result = __GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ++*converted; \
+ continue; \
} \
\
put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00)); \
cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
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_out.__cd.__nsteps = 1; /* Only one step allowed. */
cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
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;
/* Set the mode now. */
cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
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_out.__cd.__nsteps = 1; /* Only one step allowed. */
cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
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;
}
#else
data.__outbufend = data.__outbuf + sizeof (wchar_t);
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = &data.__state;
/* Make sure we start in the initial state. */
/* Set information for this step. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
/* A first special case is if S is NULL. This means put PS in the
/* Tell where we want the result. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
if (nmc == 0)
/* Tell where we want the result. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
/* Make sure we use the correct function. */
/* Set information for this step. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
/* A first special case is if S is NULL. This means put PS in the
/* Tell where we want the result. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
if (nwc == 0)
/* Tell where we want the result. */
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = ps ?: &state;
/* Make sure we use the correct function. */
data.__outbufend = buf + MB_LEN_MAX;
data.__invocation_counter = 0;
data.__internal_use = 1;
- data.__is_last = 1;
+ data.__flags = __GCONV_IS_LAST;
data.__statep = &data.__state;
/* Make sure we start in the initial state. */