Fix up comment convention on the arch-tag lines.
[bpt/emacs.git] / lisp / mail / rfc822.el
index 39f02b9..a06e8dc 100644 (file)
@@ -1,6 +1,7 @@
 ;;; rfc822.el --- hairy rfc822 parser for mail and news and suchlike
 
-;; Copyright (C) 1986, 87, 1990 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1987, 1990, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Richard Mlynarik <mly@eddie.mit.edu>
 ;; Maintainer: FSF
@@ -10,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 ;; Support functions for parsing RFC-822 headers, used by mail and news
-;; modes.  
+;; modes.
 
 ;;; Code:
 
-;; uses address-start free, throws to address
+(defvar rfc822-address-start)
+
+;; uses rfc822-address-start free, throws to address
 (defun rfc822-bad-address (reason)
   (save-restriction
     (insert "_^_")
-    (narrow-to-region address-start
+    (narrow-to-region rfc822-address-start
                      (if (re-search-forward "[,;]" nil t)
                          (max (point-min) (1- (point)))
                        (point-max)))
@@ -52,7 +55,7 @@
                                    ": \"")
     (goto-char (point-max)) (insert "\")"))
   (rfc822-nuke-whitespace)
-  (throw 'address (buffer-substring address-start (point))))
+  (throw 'address (buffer-substring rfc822-address-start (point))))
 
 (defun rfc822-nuke-whitespace (&optional leave-space)
   (let (ch)
@@ -75,7 +78,7 @@
                  (forward-char -1)
                  (delete-char 2)
                  t)
-                ((memq ch '(?\ ?\t ?\n))
+                ((memq ch '(?\  ?\t ?\n))
                  (delete-region (point)
                                 (progn (skip-chars-forward " \t\n") (point)))
                  t)
                        t))))
       (let ((tem (match-data)))
        (rfc822-nuke-whitespace leave-space)
-       (store-match-data tem)
+       (set-match-data tem)
        t)))
 
 (defun rfc822-snarf-word ()
   ;;  domain-literal is  "[" *(dtext | quoted-pair) "]"
   ;;  dtext is "[^][\\n"
   ;;  domain-ref is atom
-  (let ((address-start (point))
+  (let ((rfc822-address-start (point))
        (n 0))
     (catch 'address
       ;; optimize common cases:
            (or (bobp) (/= (preceding-char) ?\ ) (delete-char -1))
            ;; relying on the fact that rfc822-looking-at <char>
            ;;  doesn't mung match-data
-           (throw 'address (buffer-substring address-start (match-end 0)))))
-      (goto-char address-start)
+           (throw 'address (buffer-substring rfc822-address-start (match-end 0)))))
+      (goto-char rfc822-address-start)
       (while t
        (cond ((and (= n 1) (rfc822-looking-at ?@))
               ;; local-part@domain
               (rfc822-snarf-domain)
               (throw 'address
-                (buffer-substring address-start (point))))
+                (buffer-substring rfc822-address-start (point))))
              ((rfc822-looking-at ?:)
               (cond ((not allow-groups)
                      (rfc822-bad-address "A group name may not appear here"))
               (throw 'address nil))
              ((= n 1) ; allow "foo" (losing unix seems to do this)
               (throw 'address
-                (buffer-substring address-start (point))))
+                (buffer-substring rfc822-address-start (point))))
               ((> n 1)
                (rfc822-bad-address "Missing comma between addresses or badly-formatted address"))
              ((or (eobp) (= (following-char) ?,))
              (t
               (rfc822-bad-address "Strange character or missing comma")))))))
 
-                          
+
 (defun rfc822-addresses (header-text)
   (if (string-match "\\`[ \t]*\\([^][\000-\037 ()<>@,;:\\\".]+\\)[ \t]*\\'"
                     header-text)
            (replace-match "\\1 " t))
 
          (goto-char (point-min))
-         (rfc822-nuke-whitespace)
          (let ((list ())
                tem
-               address-start); this is for rfc822-bad-address
+               rfc822-address-start); this is for rfc822-bad-address
+           (rfc822-nuke-whitespace)
            (while (not (eobp))
-             (setq address-start (point))
+             (setq rfc822-address-start (point))
              (setq tem
                    (catch 'address ; this is for rfc822-bad-address
                      (cond ((rfc822-looking-at ?\,)
 
 (provide 'rfc822)
 
+;; arch-tag: 5d388a24-e173-40fb-9b8e-85269de44b37
 ;;; rfc822.el ends here