aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-03 22:09:42 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-03 22:09:42 +0000
commitdb2d05f93ce7a790a1f50ed5b082539b566801e2 (patch)
treef9798dd65c34397e50a7fff0a41fc160e645c2aa
parentb9583166c0acb0f792fd741edaf6b35b6851694a (diff)
downloadglibc-db2d05f93ce7a790a1f50ed5b082539b566801e2.tar
glibc-db2d05f93ce7a790a1f50ed5b082539b566801e2.tar.gz
glibc-db2d05f93ce7a790a1f50ed5b082539b566801e2.tar.bz2
glibc-db2d05f93ce7a790a1f50ed5b082539b566801e2.zip
Update.
* iconvdata/8bit-gap.c: Correctly use __builtin_expect. * iconvdata/ansi_x3.110.c: Likewise. * iconvdata/big5.c: Likewise. * iconvdata/euc-cn.c: Likewise. * iconvdata/euc-jp.c: Likewise. * iconvdata/euc-kr.c: Likewise. * iconvdata/gb18030.c: Likewise. * iconvdata/gbbig5.c: Likewise. * iconvdata/gbgbk.c: Likewise. * iconvdata/gbk.c: Likewise. * iconvdata/ibm930.c: Likewise. * iconvdata/ibm932.c: Likewise. * iconvdata/ibm933.c: Likewise. * iconvdata/ibm935.c: Likewise. * iconvdata/ibm939.c: Likewise. * iconvdata/ibm943.c: Likewise. * iconvdata/iso-2022-cn.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. * iconv/gconv_simple.c: Likewise. Convert assert() in real error handling.
-rw-r--r--ChangeLog31
-rw-r--r--iconv/gconv_simple.c62
-rw-r--r--iconvdata/8bit-gap.c2
-rw-r--r--iconvdata/ansi_x3.110.c10
-rw-r--r--iconvdata/big5.c8
-rw-r--r--iconvdata/euc-cn.c6
-rw-r--r--iconvdata/euc-jp.c2
-rw-r--r--iconvdata/euc-kr.c6
-rw-r--r--iconvdata/gb18030.c2
-rw-r--r--iconvdata/gbbig5.c10
-rw-r--r--iconvdata/gbgbk.c20
-rw-r--r--iconvdata/gbk.c6
-rw-r--r--iconvdata/ibm930.c4
-rw-r--r--iconvdata/ibm932.c6
-rw-r--r--iconvdata/ibm933.c4
-rw-r--r--iconvdata/ibm935.c4
-rw-r--r--iconvdata/ibm939.c4
-rw-r--r--iconvdata/ibm943.c6
-rw-r--r--iconvdata/iso-2022-cn.c2
-rw-r--r--iconvdata/iso-2022-kr.c2
-rw-r--r--iconvdata/iso646.c2
-rw-r--r--iconvdata/iso8859-1.c2
-rw-r--r--iconvdata/iso_6937-2.c10
-rw-r--r--iconvdata/iso_6937.c10
-rw-r--r--iconvdata/johab.c16
-rw-r--r--iconvdata/sjis.c16
-rw-r--r--iconvdata/t.61.c16
-rw-r--r--iconvdata/uhc.c18
-rw-r--r--iconvdata/unicode.c2
-rw-r--r--iconvdata/utf-16.c20
-rw-r--r--localedata/Makefile4
-rw-r--r--localedata/tst-mbswcs6.c74
32 files changed, 248 insertions, 139 deletions
diff --git a/ChangeLog b/ChangeLog
index cfb6924f7e..1c1377089f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,36 @@
2001-08-03 Ulrich Drepper <drepper@redhat.com>
+ * iconvdata/8bit-gap.c: Correctly use __builtin_expect.
+ * iconvdata/ansi_x3.110.c: Likewise.
+ * iconvdata/big5.c: Likewise.
+ * iconvdata/euc-cn.c: Likewise.
+ * iconvdata/euc-jp.c: Likewise.
+ * iconvdata/euc-kr.c: Likewise.
+ * iconvdata/gb18030.c: Likewise.
+ * iconvdata/gbbig5.c: Likewise.
+ * iconvdata/gbgbk.c: Likewise.
+ * iconvdata/gbk.c: Likewise.
+ * iconvdata/ibm930.c: Likewise.
+ * iconvdata/ibm932.c: Likewise.
+ * iconvdata/ibm933.c: Likewise.
+ * iconvdata/ibm935.c: Likewise.
+ * iconvdata/ibm939.c: Likewise.
+ * iconvdata/ibm943.c: Likewise.
+ * iconvdata/iso-2022-cn.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.
+ * iconv/gconv_simple.c: Likewise. Convert assert() in real error
+ handling.
+
* iconvdata/Makefile: Add rules to build KOI8-T module.
* iconvdata/koi8-t.c: New file.
* iconvdata/gconv-modules: Add entries for KOI8-T.
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index dbec90cb79..c2c1358827 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -161,7 +161,7 @@ internal_ucs4_loop_single (struct __gconv_step *step,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (__builtin_expect (cnt, 4) < 4)
+ if (__builtin_expect (cnt < 4, 0))
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -229,7 +229,7 @@ ucs4_internal_loop (struct __gconv_step *step,
inval = *(const uint32_t *) inptr;
#endif
- if (__builtin_expect (inval, 0) > 0x7fffffff)
+ if (__builtin_expect (inval > 0x7fffffff, 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -286,7 +286,7 @@ ucs4_internal_loop_unaligned (struct __gconv_step *step,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
{
- if (__builtin_expect (inptr[0], 0) > 0x80)
+ if (__builtin_expect (inptr[0] > 0x80, 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -353,7 +353,7 @@ ucs4_internal_loop_single (struct __gconv_step *step,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (__builtin_expect (cnt, 4) < 4)
+ if (__builtin_expect (cnt < 4, 0))
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -362,8 +362,8 @@ ucs4_internal_loop_single (struct __gconv_step *step,
return __GCONV_INCOMPLETE_INPUT;
}
- if (__builtin_expect (((unsigned char *) state->__value.__wchb)[0], 0)
- > 0x80)
+ if (__builtin_expect (((unsigned char *) state->__value.__wchb)[0] > 0x80,
+ 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -515,7 +515,7 @@ internal_ucs4le_loop_single (struct __gconv_step *step,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (__builtin_expect (cnt, 4) < 4)
+ if (__builtin_expect (cnt < 4, 0))
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -580,7 +580,7 @@ ucs4le_internal_loop (struct __gconv_step *step,
inval = *(const uint32_t *) inptr;
#endif
- if (__builtin_expect (inval, 0) > 0x7fffffff)
+ if (__builtin_expect (inval > 0x7fffffff, 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -635,7 +635,7 @@ ucs4le_internal_loop_unaligned (struct __gconv_step *step,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
{
- if (__builtin_expect (inptr[3], 0) > 0x80)
+ if (__builtin_expect (inptr[3] > 0x80, 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -703,7 +703,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (__builtin_expect (cnt, 4) < 4)
+ if (__builtin_expect (cnt < 4, 0))
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -712,8 +712,8 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
return __GCONV_INCOMPLETE_INPUT;
}
- if (__builtin_expect (((unsigned char *) state->__value.__wchb)[3], 0)
- > 0x80)
+ if (__builtin_expect (((unsigned char *) state->__value.__wchb)[3] > 0x80,
+ 0))
{
/* The value is too large. We don't try transliteration here since
this is not an error because of the lack of possibilities to
@@ -764,7 +764,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (__builtin_expect (*inptr, 0) > '\x7f') \
+ if (__builtin_expect (*inptr > '\x7f', 0)) \
{ \
/* The value is too large. We don't try transliteration here since \
this is not an error because of the lack of possibilities to \
@@ -805,7 +805,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (__builtin_expect (*((const uint32_t *) inptr), 0) > 0x7f) \
+ if (__builtin_expect (*((const uint32_t *) inptr) > 0x7f, 0)) \
{ \
UNICODE_TAG_HANDLER (*((const uint32_t *) inptr), 4); \
STANDARD_ERR_HANDLER (4); \
@@ -839,13 +839,10 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
{ \
uint32_t wc = *((const uint32_t *) inptr); \
\
- /* Since we control every character we read this cannot happen. */ \
- assert (wc <= 0x7fffffff); \
- \
if (wc < 0x80) \
/* It's an one byte sequence. */ \
*outptr++ = (unsigned char) wc; \
- else \
+ else if (__builtin_expect (wc <= 0x7fffffff, 1)) \
{ \
size_t step; \
char *start; \
@@ -873,9 +870,14 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
while (--step > 0); \
start[0] |= wc; \
} \
+ else \
+ { \
+ STANDARD_ERR_HANDLER (4); \
+ } \
\
inptr += 4; \
}
+#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
#include <iconv/skeleton.c>
@@ -921,25 +923,25 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
cnt = 2; \
ch &= 0x1f; \
} \
- else if (__builtin_expect (ch & 0xf0, 0xe0) == 0xe0) \
+ else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \
{ \
/* We expect three bytes. */ \
cnt = 3; \
ch &= 0x0f; \
} \
- else if (__builtin_expect (ch & 0xf8, 0xf0) == 0xf0) \
+ else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \
{ \
/* We expect four bytes. */ \
cnt = 4; \
ch &= 0x07; \
} \
- else if (__builtin_expect (ch & 0xfc, 0xf8) == 0xf8) \
+ else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \
{ \
/* We expect five bytes. */ \
cnt = 5; \
ch &= 0x03; \
} \
- else if (__builtin_expect (ch & 0xfe, 0xfc) == 0xfc) \
+ else if (__builtin_expect ((ch & 0xfe) == 0xfc, 1)) \
{ \
/* We expect six bytes. */ \
cnt = 6; \
@@ -1052,19 +1054,19 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
cnt = 2; \
ch &= 0x1f; \
} \
- else if (__builtin_expect (ch & 0xf0, 0xe0) == 0xe0) \
+ else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \
{ \
/* We expect three bytes. */ \
cnt = 3; \
ch &= 0x0f; \
} \
- else if (__builtin_expect (ch & 0xf8, 0xf0) == 0xf0) \
+ else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \
{ \
/* We expect four bytes. */ \
cnt = 4; \
ch &= 0x07; \
} \
- else if (__builtin_expect (ch & 0xfc, 0xf8) == 0xf8) \
+ else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \
{ \
/* We expect five bytes. */ \
cnt = 5; \
@@ -1104,17 +1106,17 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
bytebuf[0] = 0xc0; \
ntotal = 2; \
} \
- else if (__builtin_expect (state->__value.__wch, 0) <= 0xffff) \
+ else if (__builtin_expect (state->__value.__wch <= 0xffff, 1)) \
{ \
bytebuf[0] = 0xe0; \
ntotal = 3; \
} \
- else if (__builtin_expect (state->__value.__wch, 0) <= 0x1fffff) \
+ else if (__builtin_expect (state->__value.__wch < 0x1fffff, 1)) \
{ \
bytebuf[0] = 0xf0; \
ntotal = 4; \
} \
- else if (__builtin_expect (state->__value.__wch, 0) <= 0x3ffffff) \
+ else if (__builtin_expect (state->__value.__wch < 0x3ffffff, 1)) \
{ \
bytebuf[0] = 0xf8; \
ntotal = 5; \
@@ -1198,7 +1200,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
{ \
uint32_t val = *((const uint32_t *) inptr); \
\
- if (__builtin_expect (val, 0) >= 0x10000) \
+ if (__builtin_expect (val >= 0x10000, 0)) \
{ \
UNICODE_TAG_HANDLER (val, 4); \
STANDARD_ERR_HANDLER (4); \
@@ -1288,7 +1290,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define BODY \
{ \
uint32_t val = *((const uint32_t *) inptr); \
- if (__builtin_expect (val, 0) >= 0x10000) \
+ if (__builtin_expect (val >= 0x10000, 0)) \
{ \
UNICODE_TAG_HANDLER (val, 4); \
STANDARD_ERR_HANDLER (4); \
diff --git a/iconvdata/8bit-gap.c b/iconvdata/8bit-gap.c
index e5942be160..8959fcbd95 100644
--- a/iconvdata/8bit-gap.c
+++ b/iconvdata/8bit-gap.c
@@ -82,7 +82,7 @@ struct gap
uint32_t ch = get32 (inptr); \
unsigned char res; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
rp = NULL; \
diff --git a/iconvdata/ansi_x3.110.c b/iconvdata/ansi_x3.110.c
index c11e25addb..21de42dbcd 100644
--- a/iconvdata/ansi_x3.110.c
+++ b/iconvdata/ansi_x3.110.c
@@ -402,7 +402,7 @@ static const char from_ucs4[][2] =
uint32_t ch = *inptr; \
int incr; \
\
- if (__builtin_expect (ch, 0x00) >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
@@ -417,8 +417,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (__builtin_expect (ch2, 0x20) < 0x20 \
- || __builtin_expect (ch2, 0x7f) >= 0x80) \
+ if (__builtin_expect (ch2 < 0x20, 0) \
+ || __builtin_expect (ch2 >= 0x80, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -474,8 +474,8 @@ static const char from_ucs4[][2] =
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]), \
+ 0)) \
{ \
if (ch == 0x2c7) \
cp = "\xcf\x20"; \
diff --git a/iconvdata/big5.c b/iconvdata/big5.c
index fabde6fdc9..e43229c6b3 100644
--- a/iconvdata/big5.c
+++ b/iconvdata/big5.c
@@ -8414,8 +8414,8 @@ static const char from_ucs4_tab15[][2] =
/* See whether the second byte is in the correct range. */ \
if (ch2 >= 0x40 && ch2 <= 0x7e) \
idx += ch2 - 0x40; \
- else if (__builtin_expect (ch2, 0xa1) >= 0xa1 \
- && __builtin_expect (ch2, 0xa1) <= 0xfe) \
+ else if (__builtin_expect (ch2 >= 0xa1, 1) \
+ && __builtin_expect (ch2 <= 0xfe, 1)) \
idx += 0x3f + (ch2 - 0xa1); \
else \
{ \
@@ -8484,8 +8484,8 @@ static const char from_ucs4_tab15[][2] =
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4_tab1) / sizeof (from_ucs4_tab1[0])) \
+ if (__builtin_expect (ch >= (sizeof (from_ucs4_tab1) \
+ / sizeof (from_ucs4_tab1[0])), 0)) \
switch (ch) \
{ \
case 0x2c7 ... 0x2d9: \
diff --git a/iconvdata/euc-cn.c b/iconvdata/euc-cn.c
index 2b69b555a9..e3a0161cc3 100644
--- a/iconvdata/euc-cn.c
+++ b/iconvdata/euc-cn.c
@@ -45,8 +45,8 @@
if (ch <= 0x7f) \
++inptr; \
else \
- if ((__builtin_expect (ch, 0xa1) <= 0xa0 && ch != 0x8e && ch != 0x8f) \
- || __builtin_expect (ch, 0xfe) > 0xfe) \
+ if ((__builtin_expect (ch <= 0xa0, 0) && ch != 0x8e && ch != 0x8f) \
+ || __builtin_expect (ch > 0xfe, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -76,7 +76,7 @@
ch = inptr[1]; \
\
/* All second bytes of a multibyte character must be >= 0xa1. */ \
- if (__builtin_expect (ch, 0xa1) < 0xa1) \
+ if (__builtin_expect (ch < 0xa1, 0)) \
{ \
if (! ignore_errors_p ()) \
{ \
diff --git a/iconvdata/euc-jp.c b/iconvdata/euc-jp.c
index abb4bc6e7c..1a638994a3 100644
--- a/iconvdata/euc-jp.c
+++ b/iconvdata/euc-jp.c
@@ -77,7 +77,7 @@
ch2 = inptr[1]; \
\
/* All second bytes of a multibyte character must be >= 0xa1. */ \
- if (__builtin_expect (ch2, 0xa1) < 0xa1) \
+ if (__builtin_expect (ch2 < 0xa1, 0)) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
diff --git a/iconvdata/euc-kr.c b/iconvdata/euc-kr.c
index 5e8974bd4d..02c2f4b335 100644
--- a/iconvdata/euc-kr.c
+++ b/iconvdata/euc-kr.c
@@ -81,9 +81,9 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
++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 ()) \
diff --git a/iconvdata/gb18030.c b/iconvdata/gb18030.c
index 5400d64838..0ab68984c3 100644
--- a/iconvdata/gb18030.c
+++ b/iconvdata/gb18030.c
@@ -22068,7 +22068,7 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] =
\
inptr += 4; \
} \
- else if (__builtin_expect (ch2, 0x40) >= 0x40) \
+ else if (__builtin_expect (ch2 >= 0x40, 1)) \
{ \
/* A two-byte character */ \
idx = (ch - 0x81) * 192 + (ch2 - 0x40); \
diff --git a/iconvdata/gbbig5.c b/iconvdata/gbbig5.c
index 56d6379e97..a7d94053c9 100644
--- a/iconvdata/gbbig5.c
+++ b/iconvdata/gbbig5.c
@@ -1,5 +1,5 @@
/* Mapping tables from GB2312 to BIG5 and vice versa.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -26,7 +26,7 @@
* This module does convertions between gb2312 and big5 encodings.
* It is necessary because gb2312 encoding use simplified chinese,
* while big5 use traditional one. Often times both the simplified
- * version of a chinese character and its traditional counterpart
+ * version of a chinese character and its traditional counterpart
* are presented in unicode and have distinctive code values. So
* an indirect method through UCS4 (GB2312 <=> UCS4 <=> BIG5) will
* not do the work correctly.
@@ -4818,7 +4818,7 @@ const char __from_big5_to_gb2312 [13973][2] =
ch = inptr[1]; \
\
/* All second bytes of a multibyte character must be >= 0xa1. */ \
- if (__builtin_expect (ch, 0xa1) < 0xa1) \
+ if (__builtin_expect (ch < 0xa1, 0)) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
@@ -4926,8 +4926,8 @@ const char __from_big5_to_gb2312 [13973][2] =
/* See if the second byte is in the correct range. */ \
if (ch >= 0x40 && ch <= 0x7e) \
idx += ch - 0x40; \
- else if (__builtin_expect (ch, 0xa1) >= 0xa1 \
- && __builtin_expect (ch, 0xa1) <= 0xfe) \
+ else if (__builtin_expect (ch >= 0xa1, 1) \
+ && __builtin_expect (ch <= 0xfe, 1)) \
idx += 0x3f + (ch - 0xa1); \
else \
{ \
diff --git a/iconvdata/gbgbk.c b/iconvdata/gbgbk.c
index 6d789de771..04deac6c7e 100644
--- a/iconvdata/gbgbk.c
+++ b/iconvdata/gbgbk.c
@@ -1,5 +1,5 @@
/* Mapping tables from GBK to GB2312 and vice versa.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -96,16 +96,16 @@
ch = 0xa1aa; \
\
/* Now determine whether the character is valid. */ \
- if (__builtin_expect (ch, 0xa1a1) < 0xa1a1 \
- || __builtin_expect (ch, 0xa1a1) > 0xf7fe \
- || __builtin_expect (inptr[1], 0xa1) < 0xa1 \
+ if (__builtin_expect (ch < 0xa1a1, 0) \
+ || __builtin_expect (ch > 0xf7fe, 0) \
+ || __builtin_expect (inptr[1] < 0xa1, 0) \
/* Now test the exceptions. */ \
- || (__builtin_expect (ch, 0xa1a1) >= 0xa2a1 \
- && __builtin_expect (ch, 0xa1a1) <= 0xa2aa) \
- || (__builtin_expect (ch, 0xa1a1) >= 0xa6e0 \
- && __builtin_expect (ch, 0xa1a1) <= 0xa6f5) \
- || (__builtin_expect (ch, 0xa1a1) >= 0xa8bb \
- && __builtin_expect (ch, 0xa1a1) <= 0xa8c0)) \
+ || (__builtin_expect (ch >= 0xa2a1, 0) \
+ && __builtin_expect (ch <= 0xa2aa, 0)) \
+ || (__builtin_expect (ch >= 0xa6e0, 0) \
+ && __builtin_expect (ch <= 0xa6f5, 0)) \
+ || (__builtin_expect (ch >= 0xa8bb, 0) \
+ && __builtin_expect (ch <= 0xa8c0, 0))) \
{ \
/* One of the characters we cannot map. */ \
STANDARD_ERR_HANDLER (2); \
diff --git a/iconvdata/gbk.c b/iconvdata/gbk.c
index 8de6b35244..98f05371af 100644
--- a/iconvdata/gbk.c
+++ b/iconvdata/gbk.c
@@ -13145,8 +13145,8 @@ static const char __gbk_from_ucs4_tab12[][2] =
if (ch <= 0x7f) \
++inptr; \
else \
- if (__builtin_expect (ch, 0x81) <= 0x80 \
- || __builtin_expect (ch, 0x81) > 0xfe) \
+ if (__builtin_expect (ch <= 0x80, 0) \
+ || __builtin_expect (ch > 0xfe, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -13178,7 +13178,7 @@ static const char __gbk_from_ucs4_tab12[][2] =
\
/* All second bytes of a multibyte character must be >= 0x40, and \
the __gbk_to_ucs table only covers the range up to 0xfe 0xa0. */ \
- if (__builtin_expect (ch2, 0x41) < 0x40 \
+ if (__builtin_expect (ch2 < 0x40, 0) \
|| (__builtin_expect (ch, 0x81) == 0xfe && ch2 > 0xa0)) \
{ \
/* This is an illegal character. */ \
diff --git a/iconvdata/ibm930.c b/iconvdata/ibm930.c
index eb638b646a..faadfffcf1 100644
--- a/iconvdata/ibm930.c
+++ b/iconvdata/ibm930.c
@@ -201,7 +201,7 @@ enum
const struct gap *rp2 = __ucs4_to_ibm930db_idx; \
const char *cp; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
@@ -243,7 +243,7 @@ enum
{ \
if (curcs == sb) \
{ \
- if (__builtin_expect (outptr+1 > outend, 0)) \
+ if (__builtin_expect (outptr + 1 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
diff --git a/iconvdata/ibm932.c b/iconvdata/ibm932.c
index 05d50ad86f..b81c14d05d 100644
--- a/iconvdata/ibm932.c
+++ b/iconvdata/ibm932.c
@@ -26,7 +26,7 @@
#endif
#define FROM 0
-#define TO 1
+#define TO 1
/* Definitions used in the body of the `gconv' function. */
#define CHARSET_NAME "IBM932//"
@@ -53,7 +53,7 @@
uint32_t ch = *inptr; \
uint32_t res; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
rp1 = NULL; \
rp2 = NULL; \
@@ -155,7 +155,7 @@
uint32_t high; \
uint16_t pccode; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
rp = NULL; \
diff --git a/iconvdata/ibm933.c b/iconvdata/ibm933.c
index c3a73472e2..804c2bd3eb 100644
--- a/iconvdata/ibm933.c
+++ b/iconvdata/ibm933.c
@@ -203,7 +203,7 @@ enum
const struct gap *rp2 = __ucs4_to_ibm933db_idx; \
const char *cp; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
@@ -245,7 +245,7 @@ enum
{ \
if (curcs == sb) \
{ \
- if (__builtin_expect (outptr+1 > outend, 0)) \
+ if (__builtin_expect (outptr + 1 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
diff --git a/iconvdata/ibm935.c b/iconvdata/ibm935.c
index 91dff9420f..70d6149eef 100644
--- a/iconvdata/ibm935.c
+++ b/iconvdata/ibm935.c
@@ -201,7 +201,7 @@ enum
const struct gap *rp2 = __ucs4_to_ibm935db_idx; \
const char *cp; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
@@ -243,7 +243,7 @@ enum
{ \
if (curcs == sb) \
{ \
- if (__builtin_expect (outptr+1 > outend, 0)) \
+ if (__builtin_expect (outptr + 1 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
diff --git a/iconvdata/ibm939.c b/iconvdata/ibm939.c
index 445faeae79..1cf77744df 100644
--- a/iconvdata/ibm939.c
+++ b/iconvdata/ibm939.c
@@ -201,7 +201,7 @@ enum
const struct gap *rp2 = __ucs4_to_ibm939db_idx; \
const char *cp; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
rp1 = NULL; \
@@ -238,7 +238,7 @@ enum
{ \
if (curcs == sb) \
{ \
- if (__builtin_expect (outptr+1 > outend, 0)) \
+ if (__builtin_expect (outptr + 1 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
diff --git a/iconvdata/ibm943.c b/iconvdata/ibm943.c
index 2bb2884b4c..2819e25d74 100644
--- a/iconvdata/ibm943.c
+++ b/iconvdata/ibm943.c
@@ -26,7 +26,7 @@
#endif
#define FROM 0
-#define TO 1
+#define TO 1
/* Definitions used in the body of the `gconv' function. */
#define CHARSET_NAME "IBM943//"
@@ -53,7 +53,7 @@
uint32_t ch = *inptr; \
uint32_t res; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
rp1 = NULL; \
rp2 = NULL; \
@@ -155,7 +155,7 @@
uint32_t high; \
uint16_t pccode; \
\
- if (__builtin_expect (ch, 0) >= 0xffff) \
+ if (__builtin_expect (ch >= 0xffff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
rp = NULL; \
diff --git a/iconvdata/iso-2022-cn.c b/iconvdata/iso-2022-cn.c
index 43f2a46d66..038c4485b9 100644
--- a/iconvdata/iso-2022-cn.c
+++ b/iconvdata/iso-2022-cn.c
@@ -117,7 +117,7 @@ enum
uint32_t ch = *inptr; \
\
/* This is a 7bit character set, disallow all 8bit characters. */ \
- if (__builtin_expect (ch, 0) > 0x7f) \
+ if (__builtin_expect (ch >= 0x7f, 0)) \
{ \
if (! ignore_errors_p ()) \
{ \
diff --git a/iconvdata/iso-2022-kr.c b/iconvdata/iso-2022-kr.c
index 9bace3e61f..9846d920d9 100644
--- a/iconvdata/iso-2022-kr.c
+++ b/iconvdata/iso-2022-kr.c
@@ -119,7 +119,7 @@ enum
uint32_t ch = *inptr; \
\
/* This is a 7bit character set, disallow all 8bit characters. */ \
- if (__builtin_expect (ch, 0) > 0x7f) \
+ if (__builtin_expect (ch > 0x7f, 0)) \
{ \
if (! ignore_errors_p ()) \
{ \
diff --git a/iconvdata/iso646.c b/iconvdata/iso646.c
index f61fcd411e..894ad2bafd 100644
--- a/iconvdata/iso646.c
+++ b/iconvdata/iso646.c
@@ -878,7 +878,7 @@ gconv_end (struct __gconv_step *data)
ch = 0x5d; \
break; \
default: \
- if (__builtin_expect (ch, 0) > 0x7f) \
+ if (__builtin_expect (ch > 0x7f, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
failure = __GCONV_ILLEGAL_INPUT; \
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index 882d7f460f..67105a44f4 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -46,7 +46,7 @@
#define BODY \
{ \
uint32_t ch = *((const uint32_t *) inptr); \
- if (__builtin_expect (ch, 0) > 0xff) \
+ if (__builtin_expect (ch > 0xff, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
diff --git a/iconvdata/iso_6937-2.c b/iconvdata/iso_6937-2.c
index 25d4552de1..bd4cd6774a 100644
--- a/iconvdata/iso_6937-2.c
+++ b/iconvdata/iso_6937-2.c
@@ -400,7 +400,7 @@ static const char from_ucs4[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
@@ -416,8 +416,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (__builtin_expect (ch2, 0) < 0x20 \
- || __builtin_expect (ch2, 0) >= 0x80) \
+ if (__builtin_expect (ch2 < 0x20, 0) \
+ || __builtin_expect (ch2 >= 0x80, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -490,8 +490,8 @@ static const char from_ucs4[][2] =
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]), \
+ 0)) \
{ \
switch (ch) \
{ \
diff --git a/iconvdata/iso_6937.c b/iconvdata/iso_6937.c
index 27e9c2e4de..2340e53849 100644
--- a/iconvdata/iso_6937.c
+++ b/iconvdata/iso_6937.c
@@ -392,7 +392,7 @@ static const char from_ucs4[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
@@ -408,8 +408,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (__builtin_expect (ch2, 0) < 0x20 \
- || __builtin_expect (ch2, 0) >= 0x80) \
+ if (__builtin_expect (ch2 < 0x20, 0) \
+ || __builtin_expect (ch2 >= 0x80, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -482,8 +482,8 @@ static const char from_ucs4[][2] =
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]), \
+ 0)) \
{ \
int fail = 0; \
switch (ch) \
diff --git a/iconvdata/johab.c b/iconvdata/johab.c
index a0b200f36b..83a76d1ff0 100644
--- a/iconvdata/johab.c
+++ b/iconvdata/johab.c
@@ -178,10 +178,10 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
0xd831-0xd87e and 0xd891-0xd8fe are user-defined area */ \
else \
{ \
- 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)) \
+ if (__builtin_expect (ch > 0xf9, 0) \
+ || __builtin_expect (ch == 0xdf, 0) \
+ || (__builtin_expect (ch > 0x7e, 0) && ch < 0x84) \
+ || (__builtin_expect (ch > 0xd3, 0) && ch < 0xd9)) \
{ \
/* These are illegal. */ \
if (! ignore_errors_p ()) \
@@ -212,7 +212,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
\
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
- if (__builtin_expect (ch, 0) <= 0xd3) \
+ if (__builtin_expect (ch <= 0xd3, 1)) \
{ \
/* Hangul */ \
uint_fast32_t i, m, f; \
@@ -244,7 +244,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
else if (i == 0 && m > 0 && f == 0) \
ch = 0x314e + m; /* 0x314f + m - 1 */ \
else if (__builtin_expect (i | m, 0) == 0 \
- && __builtin_expect (f, 1) > 0) \
+ && __builtin_expect (f > 0, 1)) \
ch = final_to_ucs[f - 1]; /* round trip?? */ \
else \
{ \
@@ -263,8 +263,8 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \
else \
{ \
- if (__builtin_expect (ch2, 0x31) < 0x31 \
- || (__builtin_expect (ch2, 0x7e) > 0x7e && ch2 < 0x91) \
+ if (__builtin_expect (ch2 < 0x31, 0) \
+ || (__builtin_expect (ch2 > 0x7e, 0) && ch2 < 0x91) \
|| __builtin_expect (ch2, 0) == 0xff \
|| (__builtin_expect (ch, 0) == 0xd9 && ch2 > 0xe5) \
|| (__builtin_expect (ch, 0) == 0xda \
diff --git a/iconvdata/sjis.c b/iconvdata/sjis.c
index ba36fa9fad..3a19642c83 100644
--- a/iconvdata/sjis.c
+++ b/iconvdata/sjis.c
@@ -4360,9 +4360,9 @@ static const char from_ucs4_extra[0x100][2] =
ch = halfkana_to_ucs4[ch - 0xa1]; \
++inptr; \
} \
- else if (__builtin_expect (ch, 0) > 0xea \
+ else if (__builtin_expect (ch > 0xea, 0) \
|| __builtin_expect (ch, 0) == 0xa0 \
- || __builtin_expect (ch, 0x81) <= 0x80) \
+ || __builtin_expect (ch <= 0x80, 0)) \
{ \
/* These are illegal. */ \
if (! ignore_errors_p ()) \
@@ -4394,10 +4394,10 @@ static const char from_ucs4_extra[0x100][2] =
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
if (__builtin_expect (ch2 < 0x40, 0) \
- || (__builtin_expect (idx, 0x8140) > 0x84be && idx < 0x889f) \
- || (__builtin_expect (idx, 0x8140) > 0x88fc && idx < 0x8940) \
- || (__builtin_expect (idx, 0x8140) > 0x9ffc && idx < 0xe040) \
- || __builtin_expect (idx, 0x8140) > 0xeaa4) \
+ || (__builtin_expect (idx > 0x84be, 0) && idx < 0x889f) \
+ || (__builtin_expect (idx > 0x88fc, 0) && idx < 0x8940) \
+ || (__builtin_expect (idx > 0x9ffc, 0) && idx < 0xe040) \
+ || __builtin_expect (idx > 0xeaa4, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -4467,8 +4467,8 @@ static const char from_ucs4_extra[0x100][2] =
cp = from_ucs4_greek[ch - 0x391]; \
else if (ch >= 0x2010 && ch <= 0x9fa0) \
cp = from_ucs4_cjk[ch - 0x02010]; \
- else if (__builtin_expect (ch, 0xff01) >= 0xff01 \
- && __builtin_expect (ch, 0xff01) <= 0xffef) \
+ else if (__builtin_expect (ch >= 0xff01, 1) \
+ && __builtin_expect (ch <= 0xffef, 1)) \
cp = from_ucs4_extra[ch - 0xff00]; \
else \
{ \
diff --git a/iconvdata/t.61.c b/iconvdata/t.61.c
index 9fd7fed6f6..5ccd72bdad 100644
--- a/iconvdata/t.61.c
+++ b/iconvdata/t.61.c
@@ -385,7 +385,7 @@ static const char from_ucs4[][2] =
uint32_t ch = *inptr; \
int increment = 1; \
\
- if (__builtin_expect (ch, 0x20) >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
@@ -400,8 +400,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (__builtin_expect (ch2, 0x20) < 0x20 \
- || __builtin_expect (ch2, 0x20) >= 0x80) \
+ if (__builtin_expect (ch2 < 0x20, 0) \
+ || __builtin_expect (ch2 >= 0x80, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -457,16 +457,16 @@ static const char from_ucs4[][2] =
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]), \
+ 0)) \
{ \
if (__builtin_expect (ch, 0) == 0x2126) \
cp = "\xe0"; \
else if (__builtin_expect (ch, 0) == 0x2c7) \
cp = "\xcf\x20"; \
- else if (__builtin_expect (ch, 0x2d8) < 0x2d8 \
- || __builtin_expect (ch, 0x2d8) > 0x2dd \
- || __builtin_expect (ch, 0x2d8) == 0x02dc) \
+ else if (__builtin_expect (ch < 0x2d8, 0) \
+ || __builtin_expect (ch > 0x2dd, 0) \
+ || __builtin_expect (ch == 0x2dc, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
diff --git a/iconvdata/uhc.c b/iconvdata/uhc.c
index 3d7ab46f02..51e38dcac6 100644
--- a/iconvdata/uhc.c
+++ b/iconvdata/uhc.c
@@ -3064,9 +3064,9 @@ static const char uhc_hangul_from_ucs[11172][2] =
*/ \
if (ch <= 0x7f) \
++inptr; \
- else if (__builtin_expect (ch, 0x81) <= 0x80 \
- || __builtin_expect (ch, 0x81) >= 0xfe \
- || __builtin_expect (ch, 0x81) == 0xc9) \
+ else if (__builtin_expect (ch <= 0x80, 0) \
+ || __builtin_expect (ch >= 0xfe, 0) \
+ || __builtin_expect (ch == 0xc9, 0)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -3116,12 +3116,12 @@ static const char uhc_hangul_from_ucs[11172][2] =
\
if (ch < 0xa1 || ch2 < 0xa1) \
{ \
- if (__builtin_expect (ch, 0xc5) > 0xc6 \
- || __builtin_expect (ch2, 0x41) < 0x41 \
- || __builtin_expect (ch2, 0x41) > 0xfe \
- || (__builtin_expect (ch2, 0x41) > 0x5a && ch2 < 0x61) \
- || (__builtin_expect (ch2, 0x41) > 0x7a && ch2 < 0x81) \
- || (__builtin_expect (ch, 0xc5) == 0xc6 && ch2 > 0x52)) \
+ if (__builtin_expect (ch > 0xc6, 0) \
+ || __builtin_expect (ch2 < 0x41, 0) \
+ || __builtin_expect (ch2 > 0xfe, 0) \
+ || (__builtin_expect (ch2 > 0x5a, 0) && ch2 < 0x61) \
+ || (__builtin_expect (ch2 > 0x7a, 0) && ch2 < 0x81) \
+ || (__builtin_expect (ch == 0xc6, 0) && ch2 > 0x52)) \
{ \
/* This is not legal. */ \
if (! ignore_errors_p ()) \
diff --git a/iconvdata/unicode.c b/iconvdata/unicode.c
index c63eb68eb2..7798ae330b 100644
--- a/iconvdata/unicode.c
+++ b/iconvdata/unicode.c
@@ -152,7 +152,7 @@ gconv_end (struct __gconv_step *data)
{ \
uint32_t c = get32 (inptr); \
\
- if (__builtin_expect (c, 0) >= 0x10000) \
+ if (__builtin_expect (c >= 0x10000, 0)) \
{ \
UNICODE_TAG_HANDLER (c, 4); \
STANDARD_ERR_HANDLER (4); \
diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c
index d39399e4b6..d17f6c3563 100644
--- a/iconvdata/utf-16.c
+++ b/iconvdata/utf-16.c
@@ -217,9 +217,9 @@ gconv_end (struct __gconv_step *data)
\
if (swap) \
{ \
- if (__builtin_expect (c, 0) >= 0x10000) \
+ if (__builtin_expect (c >= 0x10000, 0)) \
{ \
- if (__builtin_expect (c, 0) >= 0x110000) \
+ if (__builtin_expect (c >= 0x110000, 0)) \
{ \
STANDARD_ERR_HANDLER (4); \
} \
@@ -241,9 +241,9 @@ gconv_end (struct __gconv_step *data)
} \
else \
{ \
- if (__builtin_expect (c, 0) >= 0x10000) \
+ if (__builtin_expect (c >= 0x10000, 0)) \
{ \
- if (__builtin_expect (c, 0) >= 0x110000) \
+ if (__builtin_expect (c >= 0x110000, 0)) \
{ \
STANDARD_ERR_HANDLER (4); \
} \
@@ -285,7 +285,7 @@ gconv_end (struct __gconv_step *data)
{ \
u1 = bswap_16 (u1); \
\
- if (__builtin_expect (u1, 0) < 0xd800 || u1 > 0xdfff) \
+ if (__builtin_expect (u1 < 0xd800, 1) || u1 > 0xdfff) \
{ \
/* No surrogate. */ \
put32 (outptr, u1); \
@@ -307,8 +307,8 @@ gconv_end (struct __gconv_step *data)
\
inptr += 2; \
u2 = bswap_16 (get16 (inptr)); \
- if (__builtin_expect (u2, 0xdc00) < 0xdc00 \
- || __builtin_expect (u2, 0xdc00) >= 0xdfff) \
+ if (__builtin_expect (u2 < 0xdc00, 0) \
+ || __builtin_expect (u2 == 0xdfff, 0)) \
{ \
/* This is no valid second word for a surrogate. */ \
if (! ignore_errors_p ()) \
@@ -328,7 +328,7 @@ gconv_end (struct __gconv_step *data)
} \
else \
{ \
- if (__builtin_expect (u1, 0) < 0xd800 || u1 > 0xdfff) \
+ if (__builtin_expect (u1 < 0xd800, 1) || u1 > 0xdfff) \
{ \
/* No surrogate. */ \
put32 (outptr, u1); \
@@ -350,8 +350,8 @@ gconv_end (struct __gconv_step *data)
\
inptr += 2; \
u2 = get16 (inptr); \
- if (__builtin_expect (u2, 0xdc00) < 0xdc00 \
- || __builtin_expect (u2, 0xdc00) >= 0xdfff) \
+ if (__builtin_expect (u2 < 0xdc00, 0) \
+ || __builtin_expect (u2 >= 0xdfff, 0)) \
{ \
/* This is no valid second word for a surrogate. */ \
if (! ignore_errors_p ()) \
diff --git a/localedata/Makefile b/localedata/Makefile
index d49a8280e0..8866b693e4 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -91,7 +91,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \
tst_wctype tst_wcwidth
tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
- tst-leaks
+ tst-leaks tst-mbswcs6
ifeq (yes,$(build-shared))
ifneq (no,$(PERL))
tests: $(objpfx)mtrace-tst-leaks
@@ -189,6 +189,7 @@ $(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \
$(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
$(objpfx)tst-digits.out: $(objpfx)tst-locale.out
+$(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
endif
include SUPPORTED
@@ -269,6 +270,7 @@ tst_wctrans-ENV = $(TEST_MBWC_ENV)
tst_wctype-ENV = $(TEST_MBWC_ENV)
tst_wcwidth-ENV = $(TEST_MBWC_ENV)
tst-digits-ENV = $(TEST_MBWC_ENV)
+tst-mbswcs6-ENV = $(TEST_MBWC_ENV)
tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
diff --git a/localedata/tst-mbswcs6.c b/localedata/tst-mbswcs6.c
new file mode 100644
index 0000000000..a4ba7fe45e
--- /dev/null
+++ b/localedata/tst-mbswcs6.c
@@ -0,0 +1,74 @@
+/* Test for invalid input to wcrtomb.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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
+ 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. */
+
+#include <errno.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int
+do_test (const char *loc)
+{
+ char buf[100];
+ size_t n;
+ mbstate_t state;
+ const char *nloc;
+ int res;
+
+ nloc = setlocale (LC_ALL, loc);
+ if (nloc == NULL)
+ {
+ printf ("could not set locale \"%s\"\n", loc);
+ return 1;
+ }
+ printf ("new locale: %s\n", nloc);
+
+ memset (&state, '\0', sizeof (state));
+ errno = 0;
+ n = wcrtomb (buf, (wchar_t) -15l, &state);
+
+ printf ("n = %zd, errno = %d (%s)\n", n, errno, strerror (errno));
+
+ res = n != (size_t) -1 || errno != EILSEQ;
+ if (res)
+ puts ("*** FAIL");
+ putchar ('\n');
+
+ return res;
+}
+
+
+int
+main (void)
+{
+ int res;
+
+ res = do_test ("C");
+ res |= do_test ("de_DE.ISO-8859-1");
+ res |= do_test ("de_DE.UTF-8");
+ res |= do_test ("en_US.ANSI_X3.4-1968");
+ res |= do_test ("ja_JP.EUC-JP");
+ res |= do_test ("hr_HR.ISO-8859-2");
+ //res |= do_test ("ru_RU.KOI8-R");
+
+ return res;
+}