* eword-decode.el (eword-decode-entire-string): Delete argument
authorakr <akr>
Sat, 25 Apr 1998 01:01:58 +0000 (01:01 +0000)
committerakr <akr>
Sat, 25 Apr 1998 01:01:58 +0000 (01:01 +0000)
`default-charset'. Add argument `code-conversion'.
(eword-decode-unstructured): Add argument `code-conversion'.
(eword-decode-comment): Add argument `code-conversion'.
(eword-decode-quoted-string): Add argument `code-conversion'.
(eword-decode-string): Propagate `code-conversion' to
`eword-decode-unstructured'.
(eword-decode-region): Propagate `code-conversion' to
`eword-decode-unstructured'.

ChangeLog
eword-decode.el

index c563477..a47aaf0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+1998-04-25  Tanaka Akira  <shuhei-k@jaist.ac.jp>
+
+       * eword-decode.el (eword-decode-entire-string): Delete argument
+       `default-charset'. Add argument `code-conversion'.
+       (eword-decode-unstructured): Add argument `code-conversion'.
+       (eword-decode-comment): Add argument `code-conversion'.
+       (eword-decode-quoted-string): Add argument `code-conversion'.
+       (eword-decode-string): Propagate `code-conversion' to
+       `eword-decode-unstructured'.
+       (eword-decode-region): Propagate `code-conversion' to
+       `eword-decode-unstructured'.
+
 1998-04-23  Shuhei KOBAYASHI  <shuhei-k@jaist.ac.jp>
 
        * eword-decode.el (eword-decode-ignored-field-list): Add
index 65ae6b5..b84861c 100644 (file)
@@ -178,14 +178,19 @@ If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
 if there are in decoded encoded-words (generated by bad manner MUA
 such as a version of Net$cape)."
   (if eword-decode-sticked-encoded-word (setq after-regexp ""))
-  (let ((between-ewords-regexp
-         (if eword-decode-sticked-encoded-word
-           "\\(\n?[ \t]\\)*"
-           "\\(\n?[ \t]\\)+"))
-       (src string)    ; sequence of octets.
-       (dst ""))       ; sequence of characters.
-    (if (string-match
-         (concat "\\`\\(" eword-regexp "\\)" after-regexp) src)
+  (let* ((between-ewords-regexp
+          (if eword-decode-sticked-encoded-word
+            "\\(\n?[ \t]\\)*"
+            "\\(\n?[ \t]\\)+"))
+        (between-ewords-eword-after-regexp
+          (concat "\\`\\(" between-ewords-regexp "\\)"
+                     "\\(" eword-regexp "\\)"
+                     after-regexp))
+        (eword-after-regexp
+          (concat "\\`\\(" eword-regexp "\\)" after-regexp))
+        (src string)   ; sequence of octets.
+        (dst ""))      ; sequence of characters.
+    (if (string-match eword-after-regexp src)
       (let* (p
             (q (match-end 1))
             (ew (substring src 0 q))
@@ -196,11 +201,7 @@ such as a version of Net$cape)."
          (progn
            (while
              (and
-               (string-match
-                 (concat "\\`\\(" between-ewords-regexp "\\)"
-                            "\\(" eword-regexp "\\)"
-                            after-regexp)
-                 src)
+               (string-match between-ewords-eword-after-regexp src)
                (progn
                  (setq p (match-end 1)
                        q (match-end 3)
@@ -223,9 +224,13 @@ such as a version of Net$cape)."
                                   safe-regexp
                                   escape ; ?\\ or nil.
                                   delimiters ; list of chars.
-                                  default-charset
-                                  must-unfold)
-  (let ((dst "")
+                                  must-unfold
+                                  code-conversion)
+  (if (and code-conversion
+          (not (mime-charset-to-coding-system code-conversion)))
+      (setq code-conversion default-mime-charset))
+  (let ((equal-safe-regexp (concat "\\`=?" safe-regexp))
+       (dst "")
        (buf "")
        (src string)
        (ew-enable t))
@@ -239,7 +244,7 @@ such as a version of Net$cape)."
                 (or decoded (memq ch delimiters)))
          (setq dst (concat dst
                      (std11-wrap-as-quoted-pairs
-                       (decode-mime-charset-string buf default-charset)
+                       (decode-mime-charset-string buf code-conversion)
                        delimiters))
                buf ""))
        (cond
@@ -261,7 +266,7 @@ such as a version of Net$cape)."
            (setq buf (concat buf (substring src 0 (match-end 0)))
                  src (substring src (match-end 0))
                  ew-enable t))
-         ((and (string-match (concat "\\`=?" safe-regexp) src)
+         ((and (string-match equal-safe-regexp src)
                (< 0 (match-end 0)))
            (setq buf (concat buf (substring src 0 (match-end 0)))
                  src (substring src (match-end 0))
@@ -270,7 +275,7 @@ such as a version of Net$cape)."
     (if (not (string= buf ""))
       (setq dst (concat dst
                  (std11-wrap-as-quoted-pairs
-                   (decode-mime-charset-string buf default-charset)
+                   (decode-mime-charset-string buf code-conversion)
                    delimiters))))
     dst))
 
@@ -278,7 +283,7 @@ such as a version of Net$cape)."
 ;;; @ for string
 ;;;
 
-(defun eword-decode-unstructured (string &optional must-unfold)
+(defun eword-decode-unstructured (string &optional must-unfold code-conversion)
   (eword-decode-entire-string
     string
     eword-encoded-word-in-unstructured-regexp
@@ -286,10 +291,10 @@ such as a version of Net$cape)."
     "[^ \t\n=]*"
     nil
     nil
-    default-mime-charset
-    must-unfold))
+    must-unfold
+    code-conversion))
 
-(defun eword-decode-comment (string &optional must-unfold)
+(defun eword-decode-comment (string &optional must-unfold code-conversion)
   (eword-decode-entire-string
     string
     eword-encoded-word-in-comment-regexp
@@ -297,10 +302,10 @@ such as a version of Net$cape)."
     "[^ \t\n()\\\\=]*"
     ?\\
     '(?\( ?\))
-    default-mime-charset
-    must-unfold))
+    must-unfold
+    code-conversion))
 
-(defun eword-decode-quoted-string (string &optional must-unfold)
+(defun eword-decode-quoted-string (string &optional must-unfold code-conversion)
   (eword-decode-entire-string
     string
     eword-encoded-word-in-quoted-string-regexp
@@ -308,10 +313,10 @@ such as a version of Net$cape)."
     "[^ \t\n\"\\\\=]*"
     ?\\
     '(?\")
-    default-mime-charset
-    must-unfold))
+    must-unfold
+    code-conversion))
 
-(defun eword-decode-string (string &optional must-unfold default-mime-charset)
+(defun eword-decode-string (string &optional must-unfold code-conversion)
   "Decode MIME encoded-words in STRING.
 
 STRING is unfolded before decoding.
@@ -324,14 +329,15 @@ if there are in decoded encoded-words (generated by bad manner MUA
 such as a version of Net$cape)."
   (eword-decode-unstructured
     (std11-unfold-string string)
-    must-unfold))
+    must-unfold
+    code-conversion))
 
 
 ;;; @ for region
 ;;;
 
 (defun eword-decode-region (start end &optional unfolding must-unfold
-                                               default-mime-charset)
+                                               code-conversion)
   "Decode MIME encoded-words in region between START and END.
 
 If UNFOLDING is not nil, it unfolds before decoding.
@@ -348,7 +354,8 @@ such as a version of Net$cape)."
        )
       (let ((str (eword-decode-unstructured
                   (buffer-substring (point-min) (point-max))
-                  must-unfold)))
+                  must-unfold
+                  code-conversion)))
        (delete-region (point-min) (point-max))
        (insert str)))))
 
@@ -416,7 +423,7 @@ If SEPARATOR is not nil, it is used as header separator."
                         code-conversion)
                       (goto-char (point-max))
                       )))))
-       (eword-decode-region (point-min) (point-max) t nil code-conversion)
+       (eword-decode-region (point-min) (point-max) t nil nil)
        ))))
 
 (defun eword-decode-unfold ()