tm 7.52.1.
[elisp/tm.git] / tm-parse.el
index 6f27844..d6fe8ca 100644 (file)
@@ -2,11 +2,11 @@
 ;;; tm-parse.el --- MIME message parser
 ;;;
 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
-;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
+;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
 ;;;
 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;;; Version:
-;;;    $Id: tm-parse.el,v 7.3 1996/04/14 15:42:14 morioka Exp $
+;;;    $Id: tm-parse.el,v 7.8 1996/04/20 12:17:27 morioka Exp $
 ;;; Keywords: mail, news, MIME, multimedia
 ;;;
 ;;; This file is part of tm (Tools for MIME).
@@ -125,18 +125,21 @@ and return parsed it. [tm-parse.el]"
 (defun mime/parse-multipart (boundary ctype params encoding rcnum)
   (goto-char (point-min))
   (let* ((dash-boundary   (concat "--" boundary))
-        (delimiter       (concat "\n" dash-boundary))
-        (close-delimiter (concat delimiter "--"))
+        (delimiter       (concat "\n" (regexp-quote dash-boundary)))
+        (close-delimiter (concat delimiter "--[ \t]*$"))
         (beg (point-min))
-        (end (if (search-forward close-delimiter nil t)
-                 (match-beginning 0)
-               (point-max)
-               ))
-        (rsep (concat (regexp-quote delimiter) "[ \t]*\n"))
+        (end (progn
+               (goto-char (point-max))
+               (if (re-search-backward close-delimiter nil t)
+                   (match-beginning 0)
+                 (point-max)
+                 )))
+        (rsep (concat delimiter "[ \t]*\n"))
         (dc-ctl
-         (cond ((string= ctype "multipart/digest") '("message/rfc822"))
-               (t '("text/plain"))
-               ))
+         (if (string-equal ctype "multipart/digest")
+             '("message/rfc822")
+           '("text/plain")
+           ))
         cb ce ct ret ncb children (i 0))
     (save-restriction
       (narrow-to-region beg end)
@@ -164,7 +167,7 @@ and return parsed it. [tm-parse.el]"
       )
     (mime::content-info/create rcnum beg (point-max)
                               ctype params encoding
-                              (reverse children))
+                              (nreverse children))
     ))
 
 (defun mime/parse-message (&optional ctl encoding rcnum)
@@ -179,7 +182,7 @@ and return parsed it. [tm-parse.el]"
             (setq boundary (rfc822/strip-quoted-string (cdr boundary)))
             (mime/parse-multipart boundary ctype params encoding rcnum)
             )
-           ((string= ctype "message/rfc822")
+           ((string-equal ctype "message/rfc822")
             (goto-char (point-min))
             (mime::content-info/create rcnum
                                        (point-min) (point-max)
@@ -187,7 +190,7 @@ and return parsed it. [tm-parse.el]"
                                        (save-restriction
                                          (narrow-to-region
                                           (if (re-search-forward "^$" nil t)
-                                              (+ (match-end 0) 1)
+                                              (1+ (match-end 0))
                                             (point-min)
                                             )
                                           (point-max))
@@ -207,3 +210,5 @@ and return parsed it. [tm-parse.el]"
 ;;;
 
 (provide 'tm-parse)
+
+;;; tm-parse.el ends here