]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(BODY for TO_LOOP): Avoid running off the end of the ISO-8859-7 from idx table.
authorUlrich Drepper <drepper@redhat.com>
Tue, 28 May 2002 04:53:57 +0000 (04:53 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 28 May 2002 04:53:57 +0000 (04:53 +0000)
iconvdata/iso-2022-jp.c

index 80fd03349817e4abdffc048b9d9c58a00008a936..d714a3b5cf23521216bdcb91736ae9dbc9e037e6 100644 (file)
@@ -701,25 +701,29 @@ static const cvlist_t conversion_lists[4] =
          }                                                                   \
        else if (set2 == ISO88597_set)                                        \
          {                                                                   \
-           const struct gap *rp = from_idx;                                  \
-                                                                             \
-           while (ch > rp->end)                                              \
-             ++rp;                                                           \
-           if (ch >= rp->start)                                              \
+           if (__builtin_expect (ch < 0xffff, 1))                            \
              {                                                               \
-               unsigned char res = iso88597_from_ucs4[ch - 0xa0 + rp->idx];  \
-               if (res != '\0')                                              \
+               const struct gap *rp = from_idx;                              \
+                                                                             \
+               while (ch > rp->end)                                          \
+                 ++rp;                                                       \
+               if (ch >= rp->start)                                          \
                  {                                                           \
-                   if (__builtin_expect (outptr + 3 > outend, 0))            \
+                   unsigned char res =                                       \
+                     iso88597_from_ucs4[ch - 0xa0 + rp->idx];                \
+                   if (res != '\0')                                          \
                      {                                                       \
-                       result = __GCONV_FULL_OUTPUT;                         \
-                       break;                                                \
-                     }                                                       \
+                       if (__builtin_expect (outptr + 3 > outend, 0))        \
+                         {                                                   \
+                           result = __GCONV_FULL_OUTPUT;                     \
+                           break;                                            \
+                         }                                                   \
                                                                              \
-                   *outptr++ = ESC;                                          \
-                   *outptr++ = 'N';                                          \
-                   *outptr++ = res;                                          \
-                   written = 3;                                              \
+                       *outptr++ = ESC;                                      \
+                       *outptr++ = 'N';                                      \
+                       *outptr++ = res;                                      \
+                       written = 3;                                          \
+                     }                                                       \
                  }                                                           \
              }                                                               \
          }                                                                   \
@@ -810,43 +814,45 @@ static const cvlist_t conversion_lists[4] =
                    }                                                         \
                                                                              \
                  /* Try ISO 8859-7 upper half.  */                           \
-                 {                                                           \
-                   const struct gap *rp = from_idx;                          \
+                 if (__builtin_expect (ch < 0xffff, 1))                      \
+                   {                                                         \
+                     const struct gap *rp = from_idx;                        \
                                                                              \
-                   while (ch > rp->end)                                      \
-                     ++rp;                                                   \
-                   if (ch >= rp->start)                                      \
-                     {                                                       \
-                       unsigned char res =                                   \
-                         iso88597_from_ucs4[ch - 0xa0 + rp->idx];            \
-                       if (res != '\0')                                      \
-                         {                                                   \
-                           if (set2 != ISO88597_set)                         \
-                             {                                               \
-                               if (__builtin_expect (outptr + 3 > outend, 0))\
-                                 {                                           \
-                                   result = __GCONV_FULL_OUTPUT;             \
-                                   break;                                    \
-                                 }                                           \
-                               *outptr++ = ESC;                              \
-                               *outptr++ = '.';                              \
-                               *outptr++ = 'F';                              \
-                               set2 = ISO88597_set;                          \
-                             }                                               \
-                                                                             \
-                           if (__builtin_expect (outptr + 3 > outend, 0))    \
-                             {                                               \
-                               result = __GCONV_FULL_OUTPUT;                 \
-                               break;                                        \
-                             }                                               \
-                           *outptr++ = ESC;                                  \
-                           *outptr++ = 'N';                                  \
-                           *outptr++ = res;                                  \
-                           result = __GCONV_OK;                              \
-                           break;                                            \
-                         }                                                   \
-                     }                                                       \
-                 }                                                           \
+                     while (ch > rp->end)                                    \
+                       ++rp;                                                 \
+                     if (ch >= rp->start)                                    \
+                       {                                                     \
+                         unsigned char res =                                 \
+                           iso88597_from_ucs4[ch - 0xa0 + rp->idx];          \
+                         if (res != '\0')                                    \
+                           {                                                 \
+                             if (set2 != ISO88597_set)                       \
+                               {                                             \
+                                 if (__builtin_expect (outptr + 3 > outend,  \
+                                                       0))                   \
+                                   {                                         \
+                                     result = __GCONV_FULL_OUTPUT;           \
+                                     break;                                  \
+                                   }                                         \
+                                 *outptr++ = ESC;                            \
+                                 *outptr++ = '.';                            \
+                                 *outptr++ = 'F';                            \
+                                 set2 = ISO88597_set;                        \
+                               }                                             \
+                                                                             \
+                             if (__builtin_expect (outptr + 3 > outend, 0))  \
+                               {                                             \
+                                 result = __GCONV_FULL_OUTPUT;               \
+                                 break;                                      \
+                               }                                             \
+                             *outptr++ = ESC;                                \
+                             *outptr++ = 'N';                                \
+                             *outptr++ = res;                                \
+                             result = __GCONV_OK;                            \
+                             break;                                          \
+                           }                                                 \
+                       }                                                     \
+                   }                                                         \
                                                                              \
                  break;                                                      \
                                                                              \