;;; ietf-drums.el --- Functions for parsing RFC822bis headers
-;; Copyright (C) 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000
+;; Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; This file is part of GNU Emacs.
;;; Code:
+(eval-when-compile (require 'cl))
(require 'time-date)
(require 'mm-util)
((= i (length token))
(push (mm-make-char 'ascii c) out))
(t
+ (when b
+ (push (mm-make-char 'ascii b) out))
(setq b c))))
(nreverse out)))
(let (c)
(ietf-drums-init string)
(while (not (eobp))
- (setq c (following-char))
+ (setq c (char-after))
(cond
((eq c ?\")
(forward-sexp 1))
(buffer-string))))
(defun ietf-drums-remove-whitespace (string)
- "Remove comments from STRING."
+ "Remove whitespace from STRING."
(with-temp-buffer
(ietf-drums-init string)
(let (c)
(while (not (eobp))
- (setq c (following-char))
+ (setq c (char-after))
(cond
((eq c ?\")
(forward-sexp 1))
(ietf-drums-init string)
(let (result c)
(while (not (eobp))
- (setq c (following-char))
+ (setq c (char-after))
(cond
((eq c ?\")
(forward-sexp 1))
(forward-char 1))))
result)))
+(defun ietf-drums-strip (string)
+ "Remove comments and whitespace from STRING."
+ (ietf-drums-remove-whitespace (ietf-drums-remove-comments string)))
+
(defun ietf-drums-parse-address (string)
"Parse STRING and return a MAILBOX / DISPLAY-NAME pair."
(with-temp-buffer
(let (display-name mailbox c display-string)
(ietf-drums-init string)
(while (not (eobp))
- (setq c (following-char))
+ (setq c (char-after))
(cond
((or (eq c ? )
(eq c ?\t))
(let ((beg (point))
pairs c)
(while (not (eobp))
- (setq c (following-char))
+ (setq c (char-after))
(cond
((memq c '(?\" ?< ?\())
(forward-sexp 1))
"Narrow to the header section in the current buffer."
(narrow-to-region
(goto-char (point-min))
- (if (search-forward "\n\n" nil 1)
- (1- (point))
+ (if (re-search-forward "^\r?$" nil 1)
+ (match-beginning 0)
(point-max)))
(goto-char (point-min)))