OSDN Git Service

Fix: MIME encode ISO-2022-JP after US-ASCII is broken. [ruby-dev:39722]
[nkf/nkf.git] / nkf.c
diff --git a/nkf.c b/nkf.c
index 162a173..9bda6e2 100644 (file)
--- a/nkf.c
+++ b/nkf.c
@@ -20,8 +20,8 @@
  *
  * 3. This notice may not be removed or altered from any source distribution.
  */
-#define NKF_VERSION "2.0.9"
-#define NKF_RELEASE_DATE "2009-06-23"
+#define NKF_VERSION "2.1.0"
+#define NKF_RELEASE_DATE "2009-11-17"
 #define COPY_RIGHT \
     "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
     "Copyright (C) 1996-2009, The nkf Project."
@@ -1206,6 +1206,7 @@ set_input_encoding(nkf_encoding *enc)
     case CP50220:
     case CP50221:
     case CP50222:
+       x0201_f = TRUE;
 #ifdef SHIFTJIS_CP932
        cp51932_f = TRUE;
 #endif
@@ -1227,6 +1228,7 @@ set_input_encoding(nkf_encoding *enc)
     case SHIFT_JIS:
        break;
     case WINDOWS_31J:
+       x0201_f = TRUE;
 #ifdef SHIFTJIS_CP932
        cp51932_f = TRUE;
 #endif
@@ -1248,6 +1250,7 @@ set_input_encoding(nkf_encoding *enc)
     case EUCJP_NKF:
        break;
     case CP51932:
+       x0201_f = TRUE;
 #ifdef SHIFTJIS_CP932
        cp51932_f = TRUE;
 #endif
@@ -1327,6 +1330,7 @@ set_output_encoding(nkf_encoding *enc)
 #endif
        break;
     case CP50221:
+       x0201_f = TRUE;
 #ifdef SHIFTJIS_CP932
        if (cp932inv_f == TRUE) cp932inv_f = FALSE;
 #endif
@@ -1355,6 +1359,7 @@ set_output_encoding(nkf_encoding *enc)
     case SHIFT_JIS:
        break;
     case WINDOWS_31J:
+       x0201_f = TRUE;
 #ifdef UTF8_OUTPUT_ENABLE
        ms_ucs_map_f = UCS_MAP_CP932;
 #endif
@@ -1383,6 +1388,7 @@ set_output_encoding(nkf_encoding *enc)
 #endif
        break;
     case CP51932:
+       x0201_f = TRUE;
 #ifdef SHIFTJIS_CP932
        if (cp932inv_f == TRUE) cp932inv_f = FALSE;
 #endif
@@ -4433,7 +4439,7 @@ mime_getc(FILE *f)
        }
        if (c1=='='&&c2<SP) { /* this is soft wrap */
            while((c1 =  (*i_mgetc)(f)) <=SP) {
-               if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
+               if (c1 == EOF) return (EOF);
            }
            mime_decode_mode = 'Q'; /* still in MIME */
            goto restart_mime_q;
@@ -4843,10 +4849,13 @@ mime_putc(nkf_char c)
                    return;
                }
            }
-           (*o_mputc)(c);
-           base64_count++;
+           if (c != 0x1B) {
+               (*o_mputc)(c);
+               base64_count++;
+               return;
+           }
        }
-       return;
+       else return;
     }
 
     if (mimeout_mode <= 0) {
@@ -5530,7 +5539,7 @@ kanji_convert(FILE *f)
                SKIP;
            } else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
                if ((c1 = (*i_getc)(f)) == EOF) {
-                   /*  (*oconv)(0, ESC); don't send bogus code */
+                   (*oconv)(0, ESC);
                    LAST;
                }
                else if (c1 == '&') {
@@ -5660,7 +5669,7 @@ kanji_convert(FILE *f)
            } else if (c1 == ESC && iconv == s_iconv) {
                /* ESC in Shift_JIS */
                if ((c1 = (*i_getc)(f)) == EOF) {
-                   /*  (*oconv)(0, ESC); don't send bogus code */
+                   (*oconv)(0, ESC);
                    LAST;
                } else if (c1 == '$') {
                    /* J-PHONE emoji */