]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/t.61.c
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / iconvdata / t.61.c
index 9fd7fed6f6010a1dbdfb1f4c0026a33d7bba69d3..db5952b074ded19c7793890793afa4276a048151 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from T.61.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997-1999, 2000-2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -14,9 +14,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <dlfcn.h>
 #include <gconv.h>
@@ -385,9 +384,9 @@ static const char from_ucs4[][2] =
     uint32_t ch = *inptr;                                                    \
     int increment = 1;                                                       \
                                                                              \
-    if (__builtin_expect (ch, 0x20) >= 0xc1 && ch <= 0xcf)                   \
+    if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf)                              \
       {                                                                              \
-       /* Composed character.  First test whether the next character         \
+       /* Composed character.  First test whether the next byte              \
           is also available.  */                                             \
        uint32_t ch2;                                                         \
                                                                              \
@@ -400,20 +399,11 @@ static const char from_ucs4[][2] =
                                                                              \
        ch2 = inptr[1];                                                       \
                                                                              \
-       if (__builtin_expect (ch2, 0x20) < 0x20                               \
-           || __builtin_expect (ch2, 0x20) >= 0x80)                          \
+       if (__builtin_expect (ch2 < 0x20, 0)                                  \
+           || __builtin_expect (ch2 >= 0x80, 0))                             \
          {                                                                   \
            /* This is illegal.  */                                           \
-           if (! ignore_errors_p ())                                         \
-             {                                                               \
-               /* This is an illegal character.  */                          \
-               result = __GCONV_ILLEGAL_INPUT;                               \
-               break;                                                        \
-             }                                                               \
-                                                                             \
-           ++inptr;                                                          \
-           ++*irreversible;                                                  \
-           continue;                                                         \
+           STANDARD_FROM_LOOP_ERR_HANDLER (1);                               \
          }                                                                   \
                                                                              \
        ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20];                             \
@@ -423,17 +413,10 @@ static const char from_ucs4[][2] =
     else                                                                     \
       ch = to_ucs4[ch];                                                              \
                                                                              \
-    if (__builtin_expect (ch, 1) == 0 && *inptr != '\0')                     \
+    if (__builtin_expect (ch == 0, 0) && *inptr != '\0')                     \
       {                                                                              \
        /* This is an illegal character.  */                                  \
-       if (! ignore_errors_p ())                                             \
-         {                                                                   \
-           /* This is an illegal character.  */                              \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
-         }                                                                   \
-                                                                             \
-       ++*irreversible;                                                      \
+       STANDARD_FROM_LOOP_ERR_HANDLER (increment);                           \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -443,6 +426,13 @@ static const char from_ucs4[][2] =
     inptr += increment;                                                              \
   }
 #define LOOP_NEED_FLAGS
+#define ONEBYTE_BODY \
+  {                                                                          \
+    uint32_t ch = to_ucs4[c];                                                \
+    if (ch == 0 && c != '\0')                                                \
+      return WEOF;                                                           \
+    return ch;                                                               \
+  }
 #include <iconv/loop.c>
 
 
@@ -457,21 +447,21 @@ static const char from_ucs4[][2] =
     uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
-    if ((size_t) __builtin_expect (ch, 0)                                    \
-       >= sizeof (from_ucs4) / sizeof (from_ucs4[0]))                        \
+    if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]),   \
+                         0))                                                 \
       {                                                                              \
        if (__builtin_expect (ch, 0) == 0x2126)                               \
          cp = "\xe0";                                                        \
        else if (__builtin_expect (ch, 0) == 0x2c7)                           \
          cp = "\xcf\x20";                                                    \
-       else if (__builtin_expect (ch, 0x2d8) < 0x2d8                         \
-                || __builtin_expect (ch, 0x2d8) > 0x2dd                      \
-                || __builtin_expect (ch, 0x2d8) == 0x02dc)                   \
+       else if (__builtin_expect (ch < 0x2d8, 0)                             \
+                || __builtin_expect (ch > 0x2dd, 0)                          \
+                || __builtin_expect (ch == 0x2dc, 0))                        \
          {                                                                   \
            UNICODE_TAG_HANDLER (ch, 4);                                      \
                                                                              \
            /* Illegal characters.  */                                        \
-           STANDARD_ERR_HANDLER (4);                                         \
+           STANDARD_TO_LOOP_ERR_HANDLER (4);                                 \
          }                                                                   \
        else                                                                  \
          {                                                                   \
@@ -486,10 +476,10 @@ static const char from_ucs4[][2] =
       {                                                                              \
        cp = from_ucs4[ch];                                                   \
                                                                              \
-       if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)                \
+       if (__builtin_expect (cp[0] == '\0', 0) && ch != 0)                   \
          {                                                                   \
            /* Illegal.  */                                                   \
-           STANDARD_ERR_HANDLER (4);                                         \
+           STANDARD_TO_LOOP_ERR_HANDLER (4);                                 \
          }                                                                   \
       }                                                                              \
                                                                              \