]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/iso-2022-jp.c
Update copyright notices with scripts/update-copyrights.
[thirdparty/glibc.git] / iconvdata / iso-2022-jp.c
index a9612e99ab40e85ceaeb1d0f23d3b43ccdbdf747..ce66121380559e1a513e3b2cb11b78a8e9c34255 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-JP and ISO-2022-JP-2.
-   Copyright (C) 1998, 1999, 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 1998-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -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 <assert.h>
 #include <dlfcn.h>
@@ -664,7 +663,7 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                        *outptr++ = ESC;                                      \
                        *outptr++ = 'N';                                      \
-                       *outptr++ = res;                                      \
+                       *outptr++ = res & 0x7f;                               \
                        written = 3;                                          \
                      }                                                       \
                  }                                                           \
@@ -706,7 +705,7 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
            /* At the beginning of a line, G2 designation is cleared.  */     \
            if (var == iso2022jp2 && ch == 0x0a)                              \
-             set2 = UNSPECIFIED_set;                                         \
+             set2 = UNSPECIFIED_set;                                         \
          }                                                                   \
        else                                                                  \
          {                                                                   \
@@ -715,8 +714,7 @@ static const cvlist_t conversion_lists[4] =
               list that depends on the current language tag.  */             \
            cvlist_t conversion_list;                                         \
            unsigned char buf[2];                                             \
-                                                                             \
-           result = __GCONV_ILLEGAL_INPUT;                                   \
+           int res = __GCONV_ILLEGAL_INPUT;                                  \
                                                                              \
            if (var == iso2022jp2)                                            \
              conversion_list = conversion_lists[tag >> 8];                   \
@@ -735,7 +733,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 3 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -746,13 +744,13 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 3 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = ESC;                                        \
                      *outptr++ = 'N';                                        \
                      *outptr++ = ch - 0x80;                                  \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -765,16 +763,16 @@ static const cvlist_t conversion_lists[4] =
                        ++rp;                                                 \
                      if (ch >= rp->start)                                    \
                        {                                                     \
-                         unsigned char res =                                 \
+                         unsigned char ch2 =                                 \
                            iso88597_from_ucs4[ch - 0xa0 + rp->idx];          \
-                         if (res != '\0')                                    \
+                         if (ch2 != '\0')                                    \
                            {                                                 \
                              if (set2 != ISO88597_set)                       \
                                {                                             \
                                  if (__builtin_expect (outptr + 3 > outend,  \
                                                        0))                   \
                                    {                                         \
-                                     result = __GCONV_FULL_OUTPUT;           \
+                                     res = __GCONV_FULL_OUTPUT;              \
                                      break;                                  \
                                    }                                         \
                                  *outptr++ = ESC;                            \
@@ -785,13 +783,13 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                              if (__builtin_expect (outptr + 3 > outend, 0))  \
                                {                                             \
-                                 result = __GCONV_FULL_OUTPUT;               \
+                                 res = __GCONV_FULL_OUTPUT;                  \
                                  break;                                      \
                                }                                             \
                              *outptr++ = ESC;                                \
                              *outptr++ = 'N';                                \
-                             *outptr++ = res;                                \
-                             result = __GCONV_OK;                            \
+                             *outptr++ = ch2 - 0x80;                         \
+                             res = __GCONV_OK;                               \
                              break;                                          \
                            }                                                 \
                        }                                                     \
@@ -810,7 +808,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 3 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -821,11 +819,11 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 1 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0];                                     \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -837,7 +835,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 3 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -848,12 +846,12 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 2 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0];                                     \
                      *outptr++ = buf[1];                                     \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -869,7 +867,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 4 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -881,12 +879,12 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 2 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0];                                     \
                      *outptr++ = buf[1];                                     \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -903,7 +901,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 3 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -914,12 +912,12 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 2 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0];                                     \
                      *outptr++ = buf[1];                                     \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -936,7 +934,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 4 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -948,12 +946,12 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 2 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0];                                     \
                      *outptr++ = buf[1];                                     \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -972,7 +970,7 @@ static const cvlist_t conversion_lists[4] =
                        {                                                     \
                          if (__builtin_expect (outptr + 3 > outend, 0))      \
                            {                                                 \
-                             result = __GCONV_FULL_OUTPUT;                   \
+                             res = __GCONV_FULL_OUTPUT;                      \
                              break;                                          \
                            }                                                 \
                          *outptr++ = ESC;                                    \
@@ -983,11 +981,11 @@ static const cvlist_t conversion_lists[4] =
                                                                              \
                      if (__builtin_expect (outptr + 1 > outend, 0))          \
                        {                                                     \
-                         result = __GCONV_FULL_OUTPUT;                       \
+                         res = __GCONV_FULL_OUTPUT;                          \
                          break;                                              \
                        }                                                     \
                      *outptr++ = buf[0] - 0x80;                              \
-                     result = __GCONV_OK;                                    \
+                     res = __GCONV_OK;                                       \
                      break;                                                  \
                    }                                                         \
                                                                              \
@@ -996,13 +994,16 @@ static const cvlist_t conversion_lists[4] =
                default:                                                      \
                  abort ();                                                   \
                }                                                             \
-           while (result == __GCONV_ILLEGAL_INPUT                            \
+           while (res == __GCONV_ILLEGAL_INPUT                               \
                   && (conversion_list = CVLIST_REST (conversion_list)) != 0);\
                                                                              \
-           if (result == __GCONV_FULL_OUTPUT)                                \
-             break;                                                          \
+           if (res == __GCONV_FULL_OUTPUT)                                   \
+             {                                                               \
+               result = res;                                                 \
+               break;                                                        \
+             }                                                               \
                                                                              \
-           if (result == __GCONV_ILLEGAL_INPUT)                              \
+           if (res == __GCONV_ILLEGAL_INPUT)                                 \
              {                                                               \
                STANDARD_TO_LOOP_ERR_HANDLER (4);                             \
              }                                                               \
@@ -1017,6 +1018,13 @@ static const cvlist_t conversion_lists[4] =
 #define INIT_PARAMS            int set = *setp & CURRENT_SEL_MASK;           \
                                int set2 = *setp & CURRENT_ASSIGN_MASK;       \
                                int tag = *setp & CURRENT_TAG_MASK;
+#define REINIT_PARAMS          do                                            \
+                                 {                                           \
+                                   set = *setp & CURRENT_SEL_MASK;           \
+                                   set2 = *setp & CURRENT_ASSIGN_MASK;       \
+                                   tag = *setp & CURRENT_TAG_MASK;           \
+                                 }                                           \
+                               while (0)
 #define UPDATE_PARAMS          *setp = set | set2 | tag
 #include <iconv/loop.c>