/* Conversion module for ISO-2022-JP-3.
- Copyright (C) 1998-1999, 2000-2002, 2004, 2008
- Free Software Foundation, Inc.
+ Copyright (C) 1998-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998,
and Bruno Haible <bruno@clisp.org>, 2002.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <dlfcn.h>
#define TO_LOOP to_iso2022jp3_loop
#define DEFINE_INIT 1
#define DEFINE_FINI 1
+#define ONE_DIRECTION 0
#define FROM_LOOP_MIN_NEEDED_FROM 1
#define FROM_LOOP_MAX_NEEDED_FROM 4
#define FROM_LOOP_MIN_NEEDED_TO 4
+ ((data->__statep->__count & CURRENT_SEL_MASK) != ASCII_set \
? 3 : 0); \
\
- if (__builtin_expect (outbuf + need > outend, 0)) \
+ if (__glibc_unlikely (outbuf + need > outend)) \
/* We don't have enough room in the output buffer. */ \
status = __GCONV_FULL_OUTPUT; \
else \
uint32_t ch = *inptr; \
\
/* Recognize escape sequences. */ \
- if (__builtin_expect (ch == ESC, 0)) \
+ if (__glibc_unlikely (ch == ESC)) \
{ \
/* We now must be prepared to read two to three more bytes. \
If we have a match in the first byte but then the input buffer \
{ \
/* Use the JIS X 0201 table. */ \
ch = jisx0201_to_ucs4 (ch); \
- if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \
+ if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \
{ \
STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
{ \
/* Use the JIS X 0201 table. */ \
ch = jisx0201_to_ucs4 (ch + 0x80); \
- if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \
+ if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \
{ \
STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
provide the appropriate tables. */ \
ch = jisx0208_to_ucs4 (&inptr, inend - inptr, 0); \
\
- if (__builtin_expect (ch == 0, 0)) \
+ if (__glibc_unlikely (ch == 0)) \
{ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
- else if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \
+ else if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \
{ \
STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
} \
else /* (set == JISX0213_1_2004_set || set == JISX0213_2_set) */ \
{ \
- if (__builtin_expect (inptr + 1 >= inend, 0)) \
+ if (__glibc_unlikely (inptr + 1 >= inend)) \
{ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
|| (set != JISX0213_1_2000_set && set != JISX0213_1_2004_set) \
? 4 : 0); \
\
- if (__builtin_expect (outptr + need + 2 > outend, 0)) \
+ if (__glibc_unlikely (outptr + need + 2 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
{ \
size_t need = (lasttwo >> 16 ? 3 : 0); \
\
- if (__builtin_expect (outptr + need + 2 > outend, 0)) \
+ if (__glibc_unlikely (outptr + need + 2 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
inptr += 4; \
continue; \
} \
- if (__builtin_expect (written == 0, 0)) \
+ if (__glibc_unlikely (written == 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
continue; \
} \
\
- if (__builtin_expect (outptr + 1 >= outend, 0)) \
+ if (__glibc_unlikely (outptr + 1 >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
{ \
/* We must encode using ASCII. First write out the escape \
sequence. */ \
- if (__builtin_expect (outptr + 3 > outend, 0)) \
+ if (__glibc_unlikely (outptr + 3 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
*outptr++ = 'B'; \
set = ASCII_set; \
\
- if (__builtin_expect (outptr >= outend, 0)) \
+ if (__glibc_unlikely (outptr >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
{ \
if (set != JISX0201_Roman_set) \
{ \
- if (__builtin_expect (outptr + 3 > outend, 0)) \
+ if (__glibc_unlikely (outptr + 3 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
set = JISX0201_Roman_set; \
} \
\
- if (__builtin_expect (outptr >= outend, 0)) \
+ if (__glibc_unlikely (outptr >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
\
if (set != JISX0208_1983_set) \
{ \
- if (__builtin_expect (outptr + 3 > outend, 0)) \
+ if (__glibc_unlikely (outptr + 3 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
set = JISX0208_1983_set; \
} \
\
- if (__builtin_expect (outptr + 2 > outend, 0)) \
+ if (__glibc_unlikely (outptr + 2 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
\
if (set != new_set) \
{ \
- if (__builtin_expect (outptr + 4 > outend, 0)) \
+ if (__glibc_unlikely (outptr + 4 > outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
continue; \
} \
\
- if (__builtin_expect (outptr + 1 >= outend, 0)) \
+ if (__glibc_unlikely (outptr + 1 >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
set = JISX0201_Kana_set; \
} \
\
- if (__builtin_expect (outptr >= outend, 0)) \
+ if (__glibc_unlikely (outptr >= outend)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \