}
result = __GCONV_NOCONV;
- if (dir != illegal_dir)
+ if (__builtin_expect (dir, from_iso646) != illegal_dir)
{
new_data = (struct iso646_data *) malloc (sizeof (struct iso646_data));
\
/* Hopefully gcc can recognize that the following `if' is only true \
when we reach the default case in the `switch' statement. */ \
- if (failure == __GCONV_ILLEGAL_INPUT) \
+ if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \
break; \
} \
\
- if (failure == __GCONV_ILLEGAL_INPUT) \
+ if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \
#define BODY \
{ \
uint32_t ch = *((uint32_t *) inptr); \
- if (ch > 0xff) \
+ if (__builtin_expect (ch, 0) > 0xff) \
{ \
/* We have an illegal character. */ \
if (! ignore_errors_p ()) \
#define TO_LOOP to_iso6937_2
#define DEFINE_INIT 1
#define DEFINE_FINI 1
-#define MIN_NEEDED_FROM 1
-#define MAX_NEEDED_FROM 2
+#define MIN_NEEDED_FROM 1
+#define MAX_NEEDED_FROM 2
#define MIN_NEEDED_TO 4
{ \
uint32_t ch = *inptr; \
\
- if (ch >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
int ch2; \
\
- if (inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store the \
intermediate result. */ \
\
ch2 = inptr[1]; \
\
- if (ch2 < 0x20 || ch2 >= 0x80) \
+ if (__builtin_expect (ch2, 0) < 0x20 \
+ || __builtin_expect (ch2, 0) >= 0x80) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
ch = to_ucs4[ch]; \
\
- if (ch == 0 && *inptr != '\0') \
+ if (__builtin_expect (ch, 1) == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch, 0) \
+ >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
{ \
int fail = 0; \
switch (ch) \
fail = 1; \
} \
\
- if (fail) \
+ if (__builtin_expect (fail, 0)) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
continue; \
} \
} \
- else if (from_ucs4[ch][0] == '\0' && ch != 0) \
+ else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
/* Now test for a possible second byte and write this if possible. */ \
if (cp[1] != '\0') \
{ \
- if (NEED_LENGTH_TEST && outptr >= outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr >= outend, 0)) \
{ \
/* The result does not fit into the buffer. */ \
--outptr; \
#define TO_LOOP to_iso6937
#define DEFINE_INIT 1
#define DEFINE_FINI 1
-#define MIN_NEEDED_FROM 1
-#define MAX_NEEDED_FROM 2
+#define MIN_NEEDED_FROM 1
+#define MAX_NEEDED_FROM 2
#define MIN_NEEDED_TO 4
{ \
uint32_t ch = *inptr; \
\
- if (ch >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
int ch2; \
\
- if (inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store the \
intermediate result. */ \
\
ch2 = inptr[1]; \
\
- if (ch2 < 0x20 || ch2 >= 0x80) \
+ if (__builtin_expect (ch2, 0) < 0x20 \
+ || __builtin_expect (ch2, 0) >= 0x80) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* Illegal character. */ \
if (! ignore_errors_p ()) \
{ \
ch = to_ucs4[ch]; \
\
- if (ch == 0 && *inptr != '\0') \
+ if (__builtin_expect (ch, 1) == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch, 0) \
+ >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
{ \
int fail = 0; \
switch (ch) \
fail = 1; \
} \
\
- if (fail) \
+ if (__builtin_expect (fail, 0)) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
continue; \
} \
} \
- else if (from_ucs4[ch][0] == '\0' && ch != 0) \
+ else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
/* Now test for a possible second byte and write this if possible. */ \
if (cp[1] != '\0') \
{ \
- if (NEED_LENGTH_TEST && outptr >= outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr >= outend, 0)) \
{ \
/* The result does not fit into the buffer. */ \
--outptr; \
0xd831-0xd87e and 0xd891-0xd8fe are user-defined area */ \
else \
{ \
- if (ch > 0xf9 || ch == 0xdf || (ch > 0x7e && ch < 0x84) \
- || (ch > 0xd3 && ch < 0xd9)) \
+ if (__builtin_expect (ch, 0) > 0xf9 \
+ || __builtin_expect (ch, 0) == 0xdf \
+ || (__builtin_expect (ch, 0) > 0x7e && ch < 0x84) \
+ || (__builtin_expect (ch, 0) > 0xd3 && ch < 0xd9)) \
{ \
/* These are illegal. */ \
if (! ignore_errors_p ()) \
uint32_t ch2; \
uint_fast32_t idx; \
\
- if (NEED_LENGTH_TEST && inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store the \
intermediate result. */ \
\
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
- if (ch <= 0xd3) \
+ if (__builtin_expect (ch, 0) <= 0xd3) \
{ \
/* Hangul */ \
uint_fast32_t i, m, f; \
m = mid[(idx & 0x03e0) >> 5]; \
f = final[idx & 0x001f]; \
\
- if (i == -1 || m == -1 || f == -1) \
+ if (__builtin_expect (i, 0) == -1 \
+ || __builtin_expect (m, 0) == -1 \
+ || __builtin_expect (f, 0) == -1) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
ch = init_to_ucs[i - 1]; \
else if (i == 0 && m > 0 && f == 0) \
ch = 0x314e + m; /* 0x314f + m - 1 */ \
- else if (i == 0 && m == 0 && f > 0) \
+ else if (__builtin_expect (i | m, 0) == 0 \
+ && __builtin_expect (f, 1) > 0) \
ch = final_to_ucs[f - 1]; /* round trip?? */ \
else \
{ \
} \
else \
{ \
- if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff) \
+ if (__builtin_expect (ch2, 0x31) < 0x31 \
+ || (__builtin_expect (ch2, 0x7e) > 0x7e && ch2 < 0x91) \
+ || __builtin_expect (ch2, 0) == 0xff \
+ || (__builtin_expect (ch, 0) == 0xda \
+ && ch2 > 0xa0 && ch2 < 0xd4)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
++*converted; \
continue; \
} \
- else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4) \
- { \
- /* This is illegal. Modern Hangul Jaso is defined \
- elsewhere in Johab */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*converted; \
- continue; \
- } \
else \
{ \
ch = johab_sym_hanja_to_ucs (idx, ch, ch2); \
} \
} \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
if (ch >= 0xac00 && ch <= 0xd7a3) \
{ \
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0))\
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
{ \
ch = jamo_from_ucs_table[ch - 0x3131]; \
\
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0))\
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
written = ucs4_to_ksc5601_hanja (ch, outptr, \
(NEED_LENGTH_TEST \
? outend - outptr : 2)); \
- if (NEED_LENGTH_TEST && written == 0) \
+ if (NEED_LENGTH_TEST && __builtin_expect (written, 1) == 0) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
- if (written == __UNKNOWN_10646_CHAR) \
+ if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \
written = ucs4_to_ksc5601_sym (ch, outptr, \
(NEED_LENGTH_TEST \
? outend - outptr : 2)); \
- if (NEED_LENGTH_TEST && written == 0) \
+ if (NEED_LENGTH_TEST && __builtin_expect (written, 1) == 0) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
- if (written == __UNKNOWN_10646_CHAR) \
+ if (__builtin_expect (written, 1) == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \