Don't return error for invald error if ignore flag is set.
authordrepper <drepper>
Tue, 6 Jun 2000 03:12:21 +0000 (03:12 +0000)
committerdrepper <drepper>
Tue, 6 Jun 2000 03:12:21 +0000 (03:12 +0000)
20 files changed:
iconvdata/8bit-gap.c
iconvdata/8bit-generic.c
iconvdata/ansi_x3.110.c
iconvdata/big5.c
iconvdata/big5hkscs.c
iconvdata/euc-cn.c
iconvdata/euc-jp.c
iconvdata/euc-kr.c
iconvdata/gbgbk.c
iconvdata/gbk.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

index b633c47..c805d5e 100644 (file)
@@ -51,12 +51,20 @@ struct gap
     if (HAS_HOLES && ch == L'\0' && *inptr != '\0')                          \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
+      {                                                                              \
+       put32 (outptr, ch);                                                   \
+       outptr += 4;                                                          \
       }                                                                              \
                                                                              \
-    put32 (outptr, ch);                                                              \
-    outptr += 4;                                                             \
     ++inptr;                                                                 \
   }
 #include <iconv/loop.c>
@@ -75,24 +83,45 @@ struct gap
     if (ch >= 0xffff)                                                        \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+       inptr += 4;                                                           \
+       continue;                                                             \
       }                                                                              \
     while (ch > rp->end)                                                     \
       ++rp;                                                                  \
     if (ch < rp->start)                                                              \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+       inptr += 4;                                                           \
+       continue;                                                             \
       }                                                                              \
                                                                              \
     res = from_ucs4[ch + rp->idx];                                           \
     if (ch != 0 && res == '\0')                                                      \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+       inptr += 4;                                                           \
+       continue;                                                             \
       }                                                                              \
                                                                              \
     *outptr++ = res;                                                         \
index 3543bdf..3b6b47a 100644 (file)
     if (HAS_HOLES && ch == L'\0' && *inptr != '\0')                          \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
       }                                                                              \
                                                                              \
     put32 (outptr, ch);                                                              \
        || (ch != 0 && from_ucs4[ch] == '\0'))                                \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
       }                                                                              \
+    else                                                                     \
+      *outptr++ = from_ucs4[ch];                                             \
                                                                              \
-    *outptr++ = from_ucs4[ch];                                               \
     inptr += 4;                                                                      \
   }
 #include <iconv/loop.c>
index 1dd214b..94bd2e6 100644 (file)
@@ -419,13 +419,20 @@ static const char from_ucs4[][2] =
        if (ch2 < 0x20 || ch2 >= 0x80)                                        \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
-         }                                                                   \
-                                                                             \
-       ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                             \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
                                                                              \
-       incr = 2;                                                             \
+           ++*converted;                                                     \
+           incr = 1;                                                         \
+         }                                                                   \
+       else                                                                  \
+         {                                                                   \
+           ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                         \
+           incr = 2;                                                         \
+         }                                                                   \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -436,13 +443,19 @@ static const char from_ucs4[][2] =
     if (ch == 0 && *inptr != '\0')                                           \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+      }                                                                              \
+    else                                                                     \
+      {                                                                              \
+       put32 (outptr, ch);                                                   \
+       outptr += 4;                                                          \
       }                                                                              \
                                                                              \
     inptr += incr;                                                           \
-    put32 (outptr, ch);                                                              \
-    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -480,8 +493,15 @@ static const char from_ucs4[][2] =
            if (tmp[0] == '\0')                                               \
              {                                                               \
                /* Illegal characters.  */                                    \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++*converted;                                                 \
+               inptr += 4;                                                   \
+               continue;                                                     \
              }                                                               \
            tmp[1] = '\0';                                                    \
            cp = tmp;                                                         \
@@ -504,13 +524,13 @@ static const char from_ucs4[][2] =
          cp = "\xd7";                                                        \
        else if (ch == 0x253c)                                                \
          cp = "\xe5";                                                        \
-       else if (ch >= 0x2571 && ch <= 0x2572)                                \
+       else if (ch >= 0x2571 && ch <= 0x2572)                                \
          {                                                                   \
            tmp[0] = 0xd8 + ch - 0x2571;                                      \
            tmp[1] = '\0';                                                    \
            cp = tmp;                                                         \
          }                                                                   \
-       else if (ch >= 0x25e2 && ch <= 0x25e3)                                \
+       else if (ch >= 0x25e2 && ch <= 0x25e3)                                \
          {                                                                   \
            tmp[0] = 0xda + ch - 0x25e2;                                      \
            tmp[1] = '\0';                                                    \
@@ -521,8 +541,15 @@ static const char from_ucs4[][2] =
        else                                                                  \
          {                                                                   \
            /* Illegal characters.  */                                        \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++*converted;                                                     \
+           inptr += 4;                                                       \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
     else                                                                     \
@@ -531,9 +558,16 @@ static const char from_ucs4[][2] =
                                                                              \
        if (cp[0] == '\0' && ch != 0)                                         \
          {                                                                   \
-           /* Illegal.  */                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           /* Illegal characters.  */                                        \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++*converted;                                                     \
+           inptr += 4;                                                       \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
                                                                              \
index de15ad6..0e4ca74 100644 (file)
@@ -8455,8 +8455,15 @@ static const char from_ucs4_tab13[][2] =
        else                                                                  \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        /* Get the value from the table.  */                                  \
@@ -8466,8 +8473,15 @@ static const char from_ucs4_tab13[][2] =
        if (ch == 0 && *inptr != '\0')                                        \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        inptr += 2;                                                           \
@@ -8567,21 +8581,29 @@ static const char from_ucs4_tab13[][2] =
     if (cp[0] == '\0' && ch != 0)                                            \
       {                                                                              \
        /* Illegal character.  */                                             \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
-      }                                                                              \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
                                                                              \
-    /* See whether there is enough room for the second byte we write.  */     \
-    if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)           \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
       {                                                                              \
-       /* We have not enough room.  */                                       \
-       result = __GCONV_FULL_OUTPUT;                                         \
-       break;                                                                \
+       /* See whether there is enough room for the second byte we write.  */ \
+       if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)        \
+         {                                                                   \
+           /* We have not enough room.  */                                   \
+           result = __GCONV_FULL_OUTPUT;                                     \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       *outptr++ = cp[0];                                                    \
+       if (cp[1] != '\0')                                                    \
+         *outptr++ = cp[1];                                                  \
       }                                                                              \
                                                                              \
-    *outptr++ = cp[0];                                                       \
-    if (cp[1] != '\0')                                                       \
-      *outptr++ = cp[1];                                                     \
     inptr += 4;                                                                      \
   }
 #include <iconv/loop.c>
index 7e1999e..09974d5 100644 (file)
@@ -12609,8 +12609,15 @@ static const char from_ucs4_tab14[][2] =
        else                                                                  \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        /* Get the value from the table.  */                                  \
@@ -12620,8 +12627,15 @@ static const char from_ucs4_tab14[][2] =
        if (ch == 0 && *inptr != '\0')                                        \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        inptr += 2;                                                           \
@@ -12724,21 +12738,29 @@ static const char from_ucs4_tab14[][2] =
     if (cp[0] == '\0' && ch != 0)                                            \
       {                                                                              \
        /* Illegal character.  */                                             \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
-      }                                                                              \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
                                                                              \
-    /* See whether there is enough room for the second byte we write.  */     \
-    if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)           \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
       {                                                                              \
-       /* We have not enough room.  */                                       \
-       result = __GCONV_FULL_OUTPUT;                                         \
-       break;                                                                \
+       /* See whether there is enough room for the second byte we write.  */ \
+       if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)        \
+         {                                                                   \
+           /* We have not enough room.  */                                   \
+           result = __GCONV_FULL_OUTPUT;                                     \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       *outptr++ = cp[0];                                                    \
+       if (cp[1] != '\0')                                                    \
+         *outptr++ = cp[1];                                                  \
       }                                                                              \
                                                                              \
-    *outptr++ = cp[0];                                                       \
-    if (cp[1] != '\0')                                                       \
-      *outptr++ = cp[1];                                                     \
     inptr += 4;                                                                      \
   }
 #include <iconv/loop.c>
index 61601e7..3211b57 100644 (file)
     if (ch <= 0x7f)                                                          \
       ++inptr;                                                               \
     else                                                                     \
-      if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f)             \
+      if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe)             \
        {                                                                     \
          /* This is illegal.  */                                             \
-         result = __GCONV_ILLEGAL_INPUT;                                     \
-         break;                                                              \
+         if (! ignore_errors_p ())                                           \
+           {                                                                 \
+             result = __GCONV_ILLEGAL_INPUT;                                 \
+             break;                                                          \
+           }                                                                 \
+                                                                             \
+         ++inptr;                                                            \
+         ++*converted;                                                       \
+         continue;                                                           \
        }                                                                     \
       else                                                                   \
        {                                                                     \
          /* All second bytes of a multibyte character must be >= 0xa1. */    \
          if (ch < 0xa1)                                                      \
            {                                                                 \
-             /* This is an illegal character.  */                            \
-             result = __GCONV_ILLEGAL_INPUT;                                 \
-             break;                                                          \
+             if (! ignore_errors_p ())                                       \
+               {                                                             \
+                 /* This is an illegal character.  */                        \
+                 result = __GCONV_ILLEGAL_INPUT;                             \
+                 break;                                                      \
+               }                                                             \
+                                                                             \
+             ++inptr;                                                        \
+             ++*converted;                                                   \
+             continue;                                                       \
            }                                                                 \
                                                                              \
          /* This is code set 1: GB 2312-80.  */                              \
          if (ch == __UNKNOWN_10646_CHAR)                                     \
            {                                                                 \
              /* This is an illegal character.  */                            \
-             result = __GCONV_ILLEGAL_INPUT;                                 \
-             break;                                                          \
+             if (! ignore_errors_p ())                                       \
+               {                                                             \
+                 /* This is an illegal character.  */                        \
+                 result = __GCONV_ILLEGAL_INPUT;                             \
+                 break;                                                      \
+               }                                                             \
+                                                                             \
+             inptr += 2;                                                     \
+             ++*converted;                                                   \
+             continue;                                                       \
            }                                                                 \
                                                                              \
          inptr += 2;                                                         \
            if (found == __UNKNOWN_10646_CHAR)                                \
              {                                                               \
                /* Illegal character.  */                                     \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 4;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            /* It's a GB 2312 character, adjust it for EUC-CN.  */            \
index 2c25d7a..240d760 100644 (file)
                                                                              \
     if (ch <= 0x7f)                                                          \
       ++inptr;                                                               \
-    else if ((ch <= 0xa0 || ch > 0xfe) && ch != 0x8e && ch != 0x8f)          \
+    else if ((ch <= 0xa0 && ch != 0x8e && ch != 0x8f) || ch > 0xfe)          \
       {                                                                              \
        /* This is illegal.  */                                               \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++inptr;                                                              \
+       ++*converted;                                                         \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       {                                                                              \
        if (ch2 < 0xa1)                                                       \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        if (ch == 0x8e)                                                       \
            if (ch == __UNKNOWN_10646_CHAR)                                   \
              {                                                               \
                /* Illegal character.  */                                     \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 2;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
            inptr = endp;                                                     \
          }                                                                   \
                else                                                          \
                  {                                                           \
                    /* Illegal character.  */                                 \
-                   result = __GCONV_ILLEGAL_INPUT;                           \
-                   break;                                                    \
+                   if (! ignore_errors_p ())                                 \
+                     {                                                       \
+                       result = __GCONV_ILLEGAL_INPUT;                       \
+                       break;                                                \
+                     }                                                       \
+                                                                             \
+                   inptr += 4;                                               \
+                   ++*converted;                                             \
+                   continue;                                                 \
                  }                                                           \
              }                                                               \
          }                                                                   \
index 19516b6..d84e72c 100644 (file)
@@ -81,8 +81,15 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
     else if (ch <= 0xa0 || ch > 0xfe || ch == 0xc9)                          \
       {                                                                              \
        /* This is illegal.  */                                               \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++inptr;                                                              \
+       ++*converted;                                                         \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -99,8 +106,16 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
        if (ch == __UNKNOWN_10646_CHAR)                                       \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
                                                                              \
@@ -127,8 +142,15 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
     if (cp[0] == '\0' && ch != 0)                                            \
       {                                                                              \
        /* Illegal character.  */                                             \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       inptr += 4;                                                           \
+       ++*converted;                                                         \
+       continue;                                                             \
       }                                                                              \
                                                                              \
     *outptr++ = cp[0];                                                       \
index 64da7a4..88617ae 100644 (file)
        ch = (ch << 8) | inptr[1];                                            \
                                                                              \
        /* Now determine whether the character is valid.  */                  \
-       if (ch >= 0xa1a1 && ch <= 0xf7fe && inptr[1] >= 0xa1)                 \
+       if (ch < 0xa1a1 || ch > 0xf7fe || inptr[1] < 0xa1                     \
+           /* Now test the exceptions.  */                                   \
+           || (ch >= 0xa2a1 && ch <= 0xa2aa)                                 \
+           || (ch >= 0xa6e0 && ch <= 0xa6f5)                                 \
+           || (ch >= 0xa8bb && ch <= 0xa8c0))                                \
          {                                                                   \
-           /* So far so good.  Now test the exceptions.  */                  \
-           if ((ch >= 0xa2a1 && ch <= 0xa2aa)                                \
-               || (ch >= 0xa6e0 && ch <= 0xa6f5)                             \
-               || (ch >= 0xa8bb && ch <= 0xa8c0))                            \
+           /* One of the characters we cannot map.  */                       \
+           if (! ignore_errors_p ())                                         \
              {                                                               \
-               /* One of the exceptions.  */                                 \
                result = __GCONV_ILLEGAL_INPUT;                               \
                break;                                                        \
              }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
          }                                                                   \
        else                                                                  \
          {                                                                   \
-           /* One of the characters we cannot map.  */                       \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           /* Copy the two bytes.  */                                        \
+           *outptr++ = *inptr++;                                             \
+           *outptr++ = *inptr++;                                             \
          }                                                                   \
-                                                                             \
-       /* Copy the two bytes.  */                                            \
-       *outptr++ = *inptr++;                                                 \
-       *outptr++ = *inptr++;                                                 \
       }                                                                              \
   }
 #include <iconv/loop.c>
index 9956ea3..c120df0 100644 (file)
@@ -13124,8 +13124,15 @@ static const char __gbk_from_ucs4_tab12[][2] =
       if (ch <= 0x80 || ch > 0xfe)                                           \
        {                                                                     \
          /* This is illegal.  */                                             \
-         result = __GCONV_ILLEGAL_INPUT;                                     \
-         break;                                                              \
+         if (! ignore_errors_p ())                                           \
+           {                                                                 \
+             result = __GCONV_ILLEGAL_INPUT;                                 \
+             break;                                                          \
+           }                                                                 \
+                                                                             \
+         ++inptr;                                                            \
+         ++*converted;                                                       \
+         continue;                                                           \
        }                                                                     \
       else                                                                   \
        {                                                                     \
@@ -13148,8 +13155,16 @@ static const char __gbk_from_ucs4_tab12[][2] =
          if (ch2 < 0x40)                                                     \
            {                                                                 \
              /* This is an illegal character.  */                            \
-             result = __GCONV_ILLEGAL_INPUT;                                 \
-             break;                                                          \
+             if (! ignore_errors_p ())                                       \
+               {                                                             \
+                 /* This is an illegal character.  */                        \
+                 result = __GCONV_ILLEGAL_INPUT;                             \
+                 break;                                                      \
+               }                                                             \
+                                                                             \
+             ++inptr;                                                        \
+             ++*converted;                                                   \
+             continue;                                                       \
            }                                                                 \
                                                                              \
          /* This is code set 1: GBK.  */                                     \
@@ -13160,8 +13175,16 @@ static const char __gbk_from_ucs4_tab12[][2] =
          if (ch == 0 && *inptr != '\0')                                      \
            {                                                                 \
              /* This is an illegal character.  */                            \
-             result = __GCONV_ILLEGAL_INPUT;                                 \
-             break;                                                          \
+             if (! ignore_errors_p ())                                       \
+               {                                                             \
+                 /* This is an illegal character.  */                        \
+                 result = __GCONV_ILLEGAL_INPUT;                             \
+                 break;                                                      \
+               }                                                             \
+                                                                             \
+             inptr += 2;                                                     \
+             ++*converted;                                                   \
+             continue;                                                       \
            }                                                                 \
                                                                              \
          inptr += 2;                                                         \
@@ -13426,21 +13449,27 @@ static const char __gbk_from_ucs4_tab12[][2] =
       if (cp == NULL || (cp[0] == '\0' && ch != 0))                          \
        {                                                                     \
          /* Illegal character.  */                                           \
-         result = __GCONV_ILLEGAL_INPUT;                                     \
-         break;                                                              \
-       }                                                                     \
+         if (! ignore_errors_p ())                                           \
+           {                                                                 \
+             result = __GCONV_ILLEGAL_INPUT;                                 \
+             break;                                                          \
+           }                                                                 \
                                                                              \
+         ++*converted;                                                       \
+       }                                                                     \
       /* See whether there is enough room for the second byte we write.  */   \
-      if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)         \
+      else if (NEED_LENGTH_TEST && cp[1] != '\0' && outptr + 1 >= outend)     \
        {                                                                     \
          /* We have not enough room.  */                                     \
          result = __GCONV_FULL_OUTPUT;                                       \
          break;                                                              \
        }                                                                     \
-                                                                             \
-      *outptr++ = cp[0];                                                     \
-      if (cp[1] != '\0')                                                     \
-       *outptr++ = cp[1];                                                    \
+      else                                                                   \
+       {                                                                     \
+         *outptr++ = cp[0];                                                  \
+         if (cp[1] != '\0')                                                  \
+           *outptr++ = cp[1];                                                \
+       }                                                                     \
     }                                                                        \
                                                                              \
     inptr += 4;                                                               \
index c8d0a02..ba0addc 100644 (file)
@@ -406,12 +406,20 @@ gconv_end (struct __gconv_step *data)
        when we reach the default case in the `switch' statement.  */         \
     if (failure == __GCONV_ILLEGAL_INPUT)                                    \
       {                                                                              \
-       /* Exit the loop with an error.  */                                   \
-       result = failure;                                                     \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* Exit the loop with an error.  */                               \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
+      {                                                                              \
+       put32 (outptr, ch);                                                   \
+       outptr += 4;                                                          \
       }                                                                              \
-    put32 (outptr, ch);                                                              \
-    outptr += 4;                                                             \
     ++inptr;                                                                 \
   }
 #define EXTRA_LOOP_DECLS       , enum variant var
@@ -875,11 +883,17 @@ gconv_end (struct __gconv_step *data)
                                                                              \
     if (failure == __GCONV_ILLEGAL_INPUT)                                    \
       {                                                                              \
-       /* Exit the loop with an error.  */                                   \
-       result = failure;                                                     \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* Exit the loop with an error.  */                               \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
       }                                                                              \
-    *outptr++ = (unsigned char) ch;                                          \
+    else                                                                     \
+      *outptr++ = (unsigned char) ch;                                        \
     inptr += 4;                                                                      \
   }
 #define EXTRA_LOOP_DECLS       , enum variant var
index 06eeda5..4949991 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion to and from ISO 8859-1.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
     if (ch > 0xff)                                                           \
       {                                                                              \
        /* We have an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
       }                                                                              \
-    *outptr++ = (unsigned char) ch;                                          \
+    else                                                                     \
+      *outptr++ = (unsigned char) ch;                                        \
     inptr += 4;                                                                      \
   }
 #include <iconv/loop.c>
index a688b7c..f58ebe4 100644 (file)
@@ -418,8 +418,16 @@ static const char from_ucs4[][2] =
        if (ch2 < 0x20 || ch2 >= 0x80)                                        \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                             \
@@ -427,8 +435,16 @@ static const char from_ucs4[][2] =
        if (ch == 0)                                                          \
          {                                                                   \
            /* Illegal character.  */                                         \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        inptr += 2;                                                           \
@@ -440,8 +456,16 @@ static const char from_ucs4[][2] =
        if (ch == 0 && *inptr != '\0')                                        \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
        ++inptr;                                                              \
       }                                                                              \
@@ -543,15 +567,30 @@ static const char from_ucs4[][2] =
        if (fail)                                                             \
          {                                                                   \
            /* Illegal characters.  */                                        \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
     else if (from_ucs4[ch][0] == '\0' && ch != 0)                            \
       {                                                                              \
        /* Illegal characters.  */                                            \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+       inptr += 4;                                                           \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       cp = from_ucs4[ch];                                                    \
@@ -563,6 +602,7 @@ static const char from_ucs4[][2] =
        if (NEED_LENGTH_TEST && outptr >= outend)                             \
          {                                                                   \
            /* The result does not fit into the buffer.  */                   \
+           --outptr;                                                         \
            result = __GCONV_FULL_OUTPUT;                                     \
            break;                                                            \
          }                                                                   \
index 81e5d0c..f6581cf 100644 (file)
@@ -410,8 +410,16 @@ static const char from_ucs4[][2] =
        if (ch2 < 0x20 || ch2 >= 0x80)                                        \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                             \
@@ -419,8 +427,16 @@ static const char from_ucs4[][2] =
        if (ch == 0)                                                          \
          {                                                                   \
            /* Illegal character.  */                                         \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        inptr += 2;                                                           \
@@ -432,8 +448,16 @@ static const char from_ucs4[][2] =
        if (ch == 0 && *inptr != '\0')                                        \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
        ++inptr;                                                              \
       }                                                                              \
@@ -514,15 +538,30 @@ static const char from_ucs4[][2] =
        if (fail)                                                             \
          {                                                                   \
            /* Illegal characters.  */                                        \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
     else if (from_ucs4[ch][0] == '\0' && ch != 0)                            \
       {                                                                              \
        /* Illegal characters.  */                                            \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++*converted;                                                         \
+       inptr += 4;                                                           \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       cp = from_ucs4[ch];                                                    \
@@ -534,6 +573,7 @@ static const char from_ucs4[][2] =
        if (NEED_LENGTH_TEST && outptr >= outend)                             \
          {                                                                   \
            /* The result does not fit into the buffer.  */                   \
+           --outptr;                                                         \
            result = __GCONV_FULL_OUTPUT;                                     \
            break;                                                            \
          }                                                                   \
index 1822b0d..ca4d053 100644 (file)
@@ -183,8 +183,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
            || (ch > 0xd3 && ch < 0xd9))                                      \
          {                                                                   \
            /* These are illegal.  */                                         \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
        else                                                                  \
          {                                                                   \
@@ -215,8 +223,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
                if (i == -1 || m == -1 || f == -1)                            \
                  {                                                           \
                    /* This is illegal.  */                                   \
-                   result = __GCONV_ILLEGAL_INPUT;                           \
-                   break;                                                    \
+                   if (! ignore_errors_p ())                                 \
+                     {                                                       \
+                       /* This is an illegal character.  */                  \
+                       result = __GCONV_ILLEGAL_INPUT;                       \
+                       break;                                                \
+                     }                                                       \
+                                                                             \
+                   ++inptr;                                                  \
+                   ++*converted;                                             \
+                   continue;                                                 \
                  }                                                           \
                else if (i > 0 && m > 0)                                      \
                  ch = ((i - 1) * 21 + (m - 1)) * 28 + f + 0xac00;            \
@@ -229,8 +245,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
                else                                                          \
                  {                                                           \
                    /* This is illegal.  */                                   \
-                   result = __GCONV_ILLEGAL_INPUT;                           \
-                   break;                                                    \
+                   if (! ignore_errors_p ())                                 \
+                     {                                                       \
+                       /* This is an illegal character.  */                  \
+                       result = __GCONV_ILLEGAL_INPUT;                       \
+                       break;                                                \
+                     }                                                       \
+                                                                             \
+                   ++inptr;                                                  \
+                   ++*converted;                                             \
+                   continue;                                                 \
                  }                                                           \
              }                                                               \
            else                                                              \
@@ -238,15 +262,31 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
                if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff)  \
                  {                                                           \
                    /* This is illegal.  */                                   \
-                   result = __GCONV_ILLEGAL_INPUT;                           \
-                   break;                                                    \
+                   if (! ignore_errors_p ())                                 \
+                     {                                                       \
+                       /* This is an illegal character.  */                  \
+                       result = __GCONV_ILLEGAL_INPUT;                       \
+                       break;                                                \
+                     }                                                       \
+                                                                             \
+                   ++inptr;                                                  \
+                   ++*converted;                                             \
+                   continue;                                                 \
                  }                                                           \
                else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4)              \
                  {                                                           \
                    /* This is illegal.  Modern Hangul Jaso is defined        \
                       elsewhere in Johab */                                  \
-                   result = __GCONV_ILLEGAL_INPUT;                           \
-                   break;                                                    \
+                   if (! ignore_errors_p ())                                 \
+                     {                                                       \
+                       /* This is an illegal character.  */                  \
+                       result = __GCONV_ILLEGAL_INPUT;                       \
+                       break;                                                \
+                     }                                                       \
+                                                                             \
+                   ++inptr;                                                  \
+                   ++*converted;                                             \
+                   continue;                                                 \
                  }                                                           \
                else                                                          \
                  {                                                           \
@@ -267,8 +307,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
        if (ch == 0)                                                          \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        inptr += 2;                                                           \
@@ -354,8 +402,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
              }                                                               \
            if (written == __UNKNOWN_10646_CHAR)                              \
              {                                                               \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 4;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            outptr[0] -= 0x4a;                                                \
@@ -383,8 +439,16 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
              }                                                               \
            if (written == __UNKNOWN_10646_CHAR)                              \
              {                                                               \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 4;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            outptr[0] -= 0x4a;                                                \
index 4ca7ce9..07f03f7 100644 (file)
@@ -4354,11 +4354,19 @@ static const char from_ucs4_extra[0x100][2] =
        ch = halfkana_to_ucs4[ch - 0xa1];                                     \
        ++inptr;                                                              \
       }                                                                              \
-    else if (ch > 0xea || ch == 0xa0 || ch == 0x7f || ch == 0x80)            \
+    else if (ch > 0xea || ch == 0xa0 || ch <= 0x80)                          \
       {                                                                              \
        /* These are illegal.  */                                             \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* This is an illegal character.  */                              \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++inptr;                                                              \
+       ++*converted;                                                         \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -4382,8 +4390,16 @@ static const char from_ucs4_extra[0x100][2] =
            || (idx > 0x9ffc && idx < 0xe040) || idx > 0xeaa4)                \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
        else                                                                  \
          {                                                                   \
@@ -4405,8 +4421,16 @@ static const char from_ucs4_extra[0x100][2] =
        if (ch == 0)                                                          \
          {                                                                   \
            /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 2;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
                                                                              \
@@ -4437,8 +4461,16 @@ static const char from_ucs4_extra[0x100][2] =
        else                                                                  \
          {                                                                   \
            /* Illegal character.  */                                         \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
     else                                                                     \
@@ -4447,21 +4479,29 @@ static const char from_ucs4_extra[0x100][2] =
     if (cp[0] == '\0' && ch != 0)                                            \
       {                                                                              \
        /* Illegal character.  */                                             \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
-      }                                                                              \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* This is an illegal character.  */                              \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
                                                                              \
-    *outptr++ = cp[0];                                                       \
-    /* Now test for a possible second byte and write this if possible.  */    \
-    if (cp[1] != '\0')                                                       \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
       {                                                                              \
-       if (NEED_LENGTH_TEST && outptr >= outend)                             \
+       *outptr++ = cp[0];                                                    \
+       /* Now test for a possible second byte and write this if possible.  */\
+       if (cp[1] != '\0')                                                    \
          {                                                                   \
-           /* The result does not fit into the buffer.  */                   \
-           result = __GCONV_FULL_OUTPUT;                                     \
-           break;                                                            \
+           if (NEED_LENGTH_TEST && outptr >= outend)                         \
+             {                                                               \
+               /* The result does not fit into the buffer.  */               \
+               result = __GCONV_FULL_OUTPUT;                                 \
+               break;                                                        \
+             }                                                               \
+           *outptr++ = cp[1];                                                \
          }                                                                   \
-       *outptr++ = cp[1];                                                    \
       }                                                                              \
                                                                              \
     inptr += 4;                                                                      \
index 10a52a1..1623606 100644 (file)
@@ -401,8 +401,16 @@ static const char from_ucs4[][2] =
        if (ch2 < 0x20 || ch2 >= 0x80)                                        \
          {                                                                   \
            /* This is illegal.  */                                           \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           ++inptr;                                                          \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                             \
@@ -418,12 +426,21 @@ static const char from_ucs4[][2] =
     if (ch == 0 && *inptr != '\0')                                           \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
-      }                                                                              \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* This is an illegal character.  */                              \
+           --inptr;                                                          \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
                                                                              \
-    put32 (outptr, ch);                                                              \
-    outptr += 4;                                                             \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
+      {                                                                              \
+       put32 (outptr, ch);                                                   \
+       outptr += 4;                                                          \
+      }                                                                              \
   }
 #include <iconv/loop.c>
 
@@ -448,8 +465,16 @@ static const char from_ucs4[][2] =
        else if (ch < 0x2d8 || ch > 0x2dd || ch == 0x02dc)                    \
          {                                                                   \
            /* Illegal characters.  */                                        \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
        else                                                                  \
          {                                                                   \
@@ -467,8 +492,16 @@ static const char from_ucs4[][2] =
        if (cp[0] == '\0' && ch != 0)                                         \
          {                                                                   \
            /* Illegal.  */                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
       }                                                                              \
                                                                              \
index e42cb2e..15faf1e 100644 (file)
@@ -3066,8 +3066,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
     else if (ch <= 0x80 || ch >= 0xfe || ch == 0xc9)                         \
       {                                                                              \
        /* This is illegal.  */                                               \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* This is an illegal character.  */                              \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
+                                                                             \
+       ++inptr;                                                              \
+       ++*converted;                                                         \
+       continue;                                                             \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -3109,8 +3117,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
                || (ch2 > 0x7a && ch2 < 0x81) || (ch == 0xc6 && ch2 > 0x52))  \
              {                                                               \
                /* This is not legal.  */                                     \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++inptr;                                                      \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            ch = uhc_extra_to_ucs[ch2 - 0x41                                  \
@@ -3122,8 +3138,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
            if (ch == 0)                                                      \
              {                                                               \
                /* This is an illegal character.  */                          \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 2;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            inptr += 2;                                                       \
@@ -3134,8 +3158,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
            if (ch == __UNKNOWN_10646_CHAR)                                   \
              {                                                               \
                /* Illegal.  */                                               \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               inptr += 2;                                                   \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
          }                                                                   \
       }                                                                              \
@@ -3184,8 +3216,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
          }                                                                   \
        if (written == __UNKNOWN_10646_CHAR)                                  \
          {                                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        *outptr++ |= 0x80;                                                    \
@@ -3208,8 +3248,16 @@ static const char uhc_hangul_from_ucs[11172][2] =
          }                                                                   \
        if (written == __UNKNOWN_10646_CHAR)                                  \
          {                                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
+           if (! ignore_errors_p ())                                         \
+             {                                                               \
+               /* This is an illegal character.  */                          \
+               result = __GCONV_ILLEGAL_INPUT;                               \
+               break;                                                        \
+             }                                                               \
+                                                                             \
+           inptr += 4;                                                       \
+           ++*converted;                                                     \
+           continue;                                                         \
          }                                                                   \
                                                                              \
        *outptr++ |= 0x80;                                                    \
index 883e7b1..7f2aca5 100644 (file)
@@ -151,13 +151,21 @@ gconv_end (struct __gconv_step *data)
                                                                              \
     if (c >= 0x10000)                                                        \
       {                                                                              \
-       result = __GCONV_ILLEGAL_INPUT;                                       \
-       break;                                                                \
-      }                                                                              \
+       if (! ignore_errors_p ())                                             \
+         {                                                                   \
+           /* This is an illegal character.  */                              \
+           result = __GCONV_ILLEGAL_INPUT;                                   \
+           break;                                                            \
+         }                                                                   \
                                                                              \
-    put16 (outptr, c);                                                       \
+       ++*converted;                                                         \
+      }                                                                              \
+    else                                                                     \
+      {                                                                              \
+       put16 (outptr, c);                                                    \
+       outptr += 2;                                                          \
+      }                                                                              \
                                                                              \
-    outptr += 2;                                                             \
     inptr += 4;                                                                      \
   }
 #define EXTRA_LOOP_DECLS \
index a7a01a8..9ca2e0b 100644 (file)
@@ -201,8 +201,16 @@ gconv_end (struct __gconv_step *data)
          {                                                                   \
            if (c >= 0x110000)                                                \
              {                                                               \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++*converted;                                                 \
+               inptr += 4;                                                   \
+               continue;                                                     \
              }                                                               \
                                                                              \
            /* Generate a surrogate character.  */                            \
@@ -226,8 +234,16 @@ gconv_end (struct __gconv_step *data)
          {                                                                   \
            if (c >= 0x110000)                                                \
              {                                                               \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   /* This is an illegal character.  */                      \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++*converted;                                                 \
+               inptr += 4;                                                   \
+               continue;                                                     \
              }                                                               \
                                                                              \
            /* Generate a surrogate character.  */                            \
@@ -291,9 +307,15 @@ gconv_end (struct __gconv_step *data)
            if (u2 < 0xdc00 || u2 >= 0xdfff)                                  \
              {                                                               \
                /* This is no valid second word for a surrogate.  */          \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               inptr -= 2;                                                   \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   inptr -= 2;                                               \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00));            \
@@ -327,9 +349,15 @@ gconv_end (struct __gconv_step *data)
            if (u2 < 0xdc00 || u2 >= 0xdfff)                                  \
              {                                                               \
                /* This is no valid second word for a surrogate.  */          \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               inptr -= 2;                                                   \
-               break;                                                        \
+               if (! ignore_errors_p ())                                     \
+                 {                                                           \
+                   inptr -= 2;                                               \
+                   result = __GCONV_ILLEGAL_INPUT;                           \
+                   break;                                                    \
+                 }                                                           \
+                                                                             \
+               ++*converted;                                                 \
+               continue;                                                     \
              }                                                               \
                                                                              \
            put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00));            \