X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/49116ac071969bee7f129bf7ce725c7a5b0b0fc5..ff98122692e5f21e3dd91d2513c7b1897b6e7ac9:/lisp/mail/rfc822.el diff --git a/lisp/mail/rfc822.el b/lisp/mail/rfc822.el index ac63ce6368..989f43cd5a 100644 --- a/lisp/mail/rfc822.el +++ b/lisp/mail/rfc822.el @@ -1,12 +1,16 @@ -;; Hairy rfc822 parser for mail and news and suchlike -;; Copyright (C) 1986-1990 Free Software Foundation, Inc. -;; Author Richard Mlynarik. +;;; rfc822.el --- hairy rfc822 parser for mail and news and suchlike + +;; Copyright (C) 1986, 87, 1990 Free Software Foundation, Inc. + +;; Author: Richard Mlynarik +;; Maintainer: FSF +;; Keywords: mail ;; This file is part of GNU Emacs. ;; 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 1, or (at your option) +;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -15,8 +19,16 @@ ;; GNU General Public License for more details. ;; 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, 675 Mass Ave, Cambridge, MA 02139, USA. +;; 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. + +;;; Commentary: + +;; Support functions for parsing RFC-822 headers, used by mail and news +;; modes. + +;;; Code: ;; uses address-start free, throws to address (defun rfc822-bad-address (reason) @@ -37,7 +49,7 @@ (setq losers (cdr losers)))) (goto-char (point-min)) (insert "(Unparsable address -- " reason - ":\n\t \"") + ": \"") (goto-char (point-max)) (insert "\")")) (rfc822-nuke-whitespace) (throw 'address (buffer-substring address-start (point)))) @@ -63,7 +75,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) @@ -87,7 +99,7 @@ t)))) (let ((tem (match-data))) (rfc822-nuke-whitespace leave-space) - (store-match-data tem) + (set-match-data tem) t))) (defun rfc822-snarf-word () @@ -96,7 +108,7 @@ ;; quoted-string (or (rfc822-looking-at "\"\\([^\"\\\n]\\|\\\\.\\|\\\\\n\\)*\"") (rfc822-bad-address "Unterminated quoted string"))) - ((rfc822-looking-at "[^][\000-\037\177-\377 ()<>@,;:\\\".]+") + ((rfc822-looking-at "[^][\000-\037 ()<>@,;:\\\".]+") ;; atom ) (t @@ -113,7 +125,7 @@ ;; domain-ref (or (rfc822-looking-at "\\[\\([^][\\\n]\\|\\\\.\\|\\\\\n\\)*\\]") (rfc822-bad-address "Unterminated domain literal [...]"))) - ((rfc822-looking-at "[^][\000-\037\177-\377 ()<>@,;:\\\".]+") + ((rfc822-looking-at "[^][\000-\037 ()<>@,;:\\\".]+") ;; domain-literal = atom ) (t @@ -178,7 +190,7 @@ ;; foo bar ;; "foo bar" ;; those aren't hacked yet. - (if (and (rfc822-looking-at "[^][\000-\037\177-\377 ()<>@,;:\\\"]+\\(\\|@[^][\000-\037\177-\377 ()<>@,;:\\\"]+\\)" t) + (if (and (rfc822-looking-at "[^][\000-\037 ()<>@,;:\\\"]+\\(\\|@[^][\000-\037 ()<>@,;:\\\"]+\\)" t) (progn (or (eobp) (rfc822-looking-at ?,)))) (progn @@ -232,7 +244,7 @@ (buffer-substring (if strip start (1- start)) (if strip end (1+ end)))) (rfc822-bad-address "Unterminated <...> address"))))) - ((looking-at "[^][\000-\037\177-\377 ()<>@,;:\\.]") + ((looking-at "[^][\000-\037 ()<>@,;:\\.]") ;; this allows "." to be part of the words preceding ;; an addr-spec, since many broken mailers output ;; "Hern K. Herklemeyer III @@ -244,7 +256,7 @@ (rfc822-snarf-words) (setq n (1+ n)) (setq again (or (rfc822-looking-at ?.) - (looking-at "[^][\000-\037\177-\377 ()<>@,;:\\.]")))))) + (looking-at "[^][\000-\037 ()<>@,;:\\.]")))))) ((= n 0) (throw 'address nil)) ((= n 1) ; allow "foo" (losing unix seems to do this) @@ -257,9 +269,9 @@ (t (rfc822-bad-address "Strange character or missing comma"))))))) - + (defun rfc822-addresses (header-text) - (if (string-match "\\`[ \t]*\\([^][\000-\037\177-\377 ()<>@,;:\\\".]+\\)[ \t]*\\'" + (if (string-match "\\`[ \t]*\\([^][\000-\037 ()<>@,;:\\\".]+\\)[ \t]*\\'" header-text) ;; Make very simple case moderately fast. (list (substring header-text (match-beginning 1) (match-end 1))) @@ -287,7 +299,7 @@ (catch 'address ; this is for rfc822-bad-address (cond ((rfc822-looking-at ?\,) nil) - ((looking-at "[][\000-\037\177-\377@;:\\.>)]") + ((looking-at "[][\000-\037@;:\\.>)]") (forward-char) (rfc822-bad-address (format "Strange character \\%c found" @@ -304,3 +316,4 @@ (provide 'rfc822) +;;; rfc822.el ends here