/* Mapping tables for EUC-KR 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 Jungshik Shin <jshin@pantheon.yale.edu>
and 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>
static inline void
+__attribute ((always_inline))
euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
{
if (ch > 0x9f)
cp[1] |= 0x80;
}
else
- cp[0] = '\0';
+ cp[0] = cp[1] = '\0';
}
else
{
++inptr; \
/* 0xfe(->0x7e : row 94) and 0xc9(->0x59 : row 41) are \
user-defined areas. */ \
- else if (__builtin_expect (ch, 0xa1) == 0xa0 \
- || __builtin_expect (ch, 0xa1) > 0xfe \
- || __builtin_expect (ch, 0xa1) == 0xc9) \
+ else if (__builtin_expect (ch == 0xa0, 0) \
+ || __builtin_expect (ch > 0xfe, 0) \
+ || __builtin_expect (ch == 0xc9, 0)) \
{ \
/* This is illegal. */ \
- if (! ignore_errors_p ()) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*irreversible; \
- continue; \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
else \
{ \
- /* Two-byte character. First test whether the next character \
+ /* Two-byte character. First test whether the next byte \
is also available. */ \
ch = ksc5601_to_ucs4 (&inptr, inend - inptr, 0x80); \
- if (__builtin_expect (ch, 1) == 0) \
+ if (__glibc_unlikely (ch == 0)) \
{ \
- /* The second character is not available. */ \
+ /* The second byte is not available. */ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
- if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR) \
- { \
- /* This is an illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- inptr += 2; \
- ++*irreversible; \
- continue; \
- } \
+ if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \
+ /* This is an illegal character. */ \
+ STANDARD_FROM_LOOP_ERR_HANDLER (2); \
} \
\
put32 (outptr, ch); \
outptr += 4; \
}
#define LOOP_NEED_FLAGS
+#define ONEBYTE_BODY \
+ { \
+ if (c <= 0x9f) \
+ return c; \
+ else \
+ return WEOF; \
+ }
#include <iconv/loop.c>
UNICODE_TAG_HANDLER (ch, 4); \
\
/* Illegal character. */ \
- STANDARD_ERR_HANDLER (4); \
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
\
*outptr++ = cp[0]; \
/* Now test for a possible second byte and write this if possible. */ \
if (cp[1] != '\0') \
{ \
- if (__builtin_expect (outptr >= outend, 0)) \
+ if (__glibc_unlikely (outptr >= outend)) \
{ \
/* The result does not fit into the buffer. */ \
--outptr; \