Update.
authorUlrich Drepper <drepper@redhat.com>
Fri, 3 Aug 2001 22:09:42 +0000 (22:09 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 3 Aug 2001 22:09:42 +0000 (22:09 +0000)
* 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.

32 files changed:
ChangeLog
iconv/gconv_simple.c
iconvdata/8bit-gap.c
iconvdata/ansi_x3.110.c
iconvdata/big5.c
iconvdata/euc-cn.c
iconvdata/euc-jp.c
iconvdata/euc-kr.c
iconvdata/gb18030.c
iconvdata/gbbig5.c
iconvdata/gbgbk.c
iconvdata/gbk.c
iconvdata/ibm930.c
iconvdata/ibm932.c
iconvdata/ibm933.c
iconvdata/ibm935.c
iconvdata/ibm939.c
iconvdata/ibm943.c
iconvdata/iso-2022-cn.c
iconvdata/iso-2022-kr.c
iconvdata/iso646.c
iconvdata/iso8859-1.c
iconvdata/iso_6937-2.c
iconvdata/iso_6937.c
iconvdata/johab.c
iconvdata/sjis.c
iconvdata/t.61.c
iconvdata/uhc.c
iconvdata/unicode.c
iconvdata/utf-16.c
localedata/Makefile
localedata/tst-mbswcs6.c [new file with mode: 0644]

index cfb6924..1c13770 100644 (file)
--- 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.
index dbec90c..c2c1358 100644 (file)
@@ -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);                                             \
index e5942be..8959fcb 100644 (file)
@@ -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;                                                            \
index c11e25a..21de42d 100644 (file)
@@ -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";                                                    \
index fabde6f..e43229c 100644 (file)
@@ -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:                                                \
index 2b69b55..e3a0161 100644 (file)
@@ -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 ())                                       \
                {                                                             \
index abb4bc6..1a63899 100644 (file)
@@ -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 ())                                         \
index 5e8974b..02c2f4b 100644 (file)
@@ -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 ())                                             \
index 5400d64..0ab6898 100644 (file)
@@ -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);                         \
index 56d6379..a7d9405 100644 (file)
@@ -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                                                                  \
          {                                                                   \
index 6d789de..04deac6 100644 (file)
@@ -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.
 
          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);                                         \
index 8de6b35..98f0537 100644 (file)
@@ -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.  */                            \
index eb638b6..faadfff 100644 (file)
@@ -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;                                                    \
index 05d50ad..b81c14d 100644 (file)
@@ -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;                                                           \
     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;                                                            \
index c3a7347..804c2bd 100644 (file)
@@ -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;                                                    \
index 91dff94..70d6149 100644 (file)
@@ -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;                                                    \
index 445faea..1cf7774 100644 (file)
@@ -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;                                                    \
index 2bb2884..2819e25 100644 (file)
@@ -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;                                                           \
     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;                                                            \
index 43f2a46..038c448 100644 (file)
@@ -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 ())                                             \
          {                                                                   \
index 9bace3e..9846d92 100644 (file)
@@ -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 ())                                             \
          {                                                                   \
index f61fcd4..894ad2b 100644 (file)
@@ -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;                                  \
index 882d7f4..67105a4 100644 (file)
@@ -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);                                          \
                                                                              \
index 25d4552..bd4cd67 100644 (file)
@@ -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)                                                           \
          {                                                                   \
index 27e9c2e..2340e53 100644 (file)
@@ -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)                                                           \
index a0b200f..83a76d1 100644 (file)
@@ -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                      \
index ba36fa9..3a19642 100644 (file)
@@ -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                                                                  \
          {                                                                   \
index 9fd7fed..5ccd72b 100644 (file)
@@ -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);                                      \
                                                                              \
index 3d7ab46..51e38dc 100644 (file)
@@ -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 ())                                     \
index c63eb68..7798ae3 100644 (file)
@@ -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);                                             \
index d39399e..d17f6c3 100644 (file)
@@ -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 ())                                     \
index d49a828..8866b69 100644 (file)
@@ -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 (file)
index 0000000..a4ba7fe
--- /dev/null
@@ -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;
+}