]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/ibm935.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / iconvdata / ibm935.c
index 07f4bf255899e88a0abee1d012b160db5dab590c..451b7b971b2689a1cd3c8ca687a526b9c0829dec 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion from and to IBM935
-   Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Masahide Washizawa <washi@yamato.ibm.co.jp>, 2000.
 
@@ -15,7 +15,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 /* IBM935 is designed for the representation of Simplified Chinese
    using a stateful EBCDIC encoding scheme.  It is also known as
@@ -109,24 +109,14 @@ enum
                                                                              \
     if (__builtin_expect(ch, 0) == SO)                                       \
       {                                                                              \
-       /* Shift OUT, change to DBCS converter.  */                           \
-       if (curcs == db)                                                      \
-         {                                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
-         }                                                                   \
+       /* Shift OUT, change to DBCS converter (redundant escape okay).  */   \
        curcs = db;                                                           \
        ++inptr;                                                              \
        continue;                                                             \
       }                                                                              \
     else if (__builtin_expect (ch, 0) == SI)                                 \
       {                                                                              \
-       /* Shift IN, change to SBCS converter.  */                            \
-       if (curcs == sb)                                                      \
-         {                                                                   \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
-           break;                                                            \
-         }                                                                   \
+       /* Shift IN, change to SBCS converter (redundant escape okay).  */    \
        curcs = sb;                                                           \
        ++inptr;                                                              \
        continue;                                                             \
@@ -200,7 +190,6 @@ enum
     uint32_t ch = get32 (inptr);                                             \
     const struct gap *rp1 = __ucs4_to_ibm935sb_idx;                          \
     const struct gap *rp2 = __ucs4_to_ibm935db_idx;                          \
-    const char *cp;                                                          \
                                                                              \
     if (__glibc_unlikely (ch >= 0xffff))                                     \
       {                                                                              \
@@ -213,14 +202,16 @@ enum
       ++rp1;                                                                 \
                                                                              \
     /* Use the UCS4 table for single byte.  */                               \
+    unsigned char sbconv;                                                    \
     if (__builtin_expect (ch < rp1->start, 0)                                \
-       || (cp = __ucs4_to_ibm935sb[ch + rp1->idx],                           \
-           __builtin_expect (cp[0], L'\1') == L'\0' && ch != '\0'))          \
+       || (sbconv = __ucs4_to_ibm935sb[ch + rp1->idx],                       \
+           __builtin_expect (sbconv, L'\1') == L'\0' && ch != '\0'))         \
       {                                                                              \
        /* Use the UCS4 table for double byte. */                             \
        while (ch > rp2->end)                                                 \
          ++rp2;                                                              \
                                                                              \
+       const char *cp;                                                       \
        if (__builtin_expect (ch < rp2->start, 0)                             \
            || (cp = __ucs4_to_ibm935db[ch + rp2->idx],                       \
                __builtin_expect (cp[0], L'\1')==L'\0' && ch != '\0'))        \
@@ -268,7 +259,7 @@ enum
            result = __GCONV_FULL_OUTPUT;                                     \
            break;                                                            \
          }                                                                   \
-       *outptr++ = cp[0];                                                    \
+       *outptr++ = sbconv;                                                   \
       }                                                                              \
                                                                              \
     /* Now that we wrote the output increment the input pointer.  */         \