/* Mapping tables for EUC-JP handling.
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <dlfcn.h>
#include <stdint.h>
else if (ch == 0xff) \
{ \
/* This is illegal. */ \
- if (! ignore_errors_p ()) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*irreversible; \
- continue; \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
else \
{ \
/* Two or more byte character. First test whether the next \
- character is also available. */ \
+ byte is also available. */ \
int ch2; \
\
- if (__builtin_expect (inptr + 1 >= inend, 0)) \
+ if (__glibc_unlikely (inptr + 1 >= inend)) \
{ \
- /* The second character is not available. Store the \
+ /* The second byte is not available. Store the \
intermediate result. */ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
ch2 = inptr[1]; \
\
/* All second bytes of a multibyte character must be >= 0xa1. */ \
- if (__builtin_expect (ch2, 0xa1) < 0xa1) \
- { \
- /* This is an illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*irreversible; \
- continue; \
- } \
+ if (__glibc_unlikely (ch2 < 0xa1)) \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
\
if (ch == 0x8e) \
{ \
/* This is code set 2: half-width katakana. */ \
ch = jisx0201_to_ucs4 (ch2); \
if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR) \
- { \
- /* Illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- } \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
\
inptr += 2; \
} \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
- if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR) \
- { \
- /* Illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \
+ /* Illegal character. */ \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
\
- inptr += 2; \
- ++*irreversible; \
- continue; \
- } \
inptr = endp; \
} \
} \
put32 (outptr, ch); \
outptr += 4; \
}
+#define ONEBYTE_BODY \
+ { \
+ if (c < 0x8e || (c >= 0x90 && c <= 0x9f)) \
+ return c; \
+ else \
+ return WEOF; \
+ }
#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
size_t found; \
\
/* See whether we have room for at least two characters. */ \
- if (__builtin_expect (outptr + 1 >= outend, 0)) \
+ if (__glibc_unlikely (outptr + 1 >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
UNICODE_TAG_HANDLER (ch, 4); \
\
/* Illegal character. */ \
- STANDARD_ERR_HANDLER (4); \
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
} \
} \