Function: ietf-drums-parse-addresses

ietf-drums-parse-addresses is a byte-compiled function defined in ietf-drums.el.gz.

Signature

(ietf-drums-parse-addresses STRING &optional RAWP)

Documentation

Parse STRING and return a list of MAILBOX / DISPLAY-NAME pairs.

If RAWP, don't actually parse the addresses, but instead return a list of address strings.

Aliases

mail-header-parse-addresses

Source Code

;; Defined in /usr/src/emacs/lisp/mail/ietf-drums.el.gz
(defun ietf-drums-parse-addresses (string &optional rawp)
  "Parse STRING and return a list of MAILBOX / DISPLAY-NAME pairs.
If RAWP, don't actually parse the addresses, but instead return
a list of address strings."
  (if (null string)
      nil
    (with-temp-buffer
      (ietf-drums-init string)
      (let ((beg (point))
	    pairs c address)
	(while (not (eobp))
	  (setq c (char-after))
	  (cond
           ((eq c ?:)
            (setq beg (1+ (point)))
            (skip-chars-forward "^;")
            (when-let* ((address
                         (condition-case nil
                             (ietf-drums-parse-addresses
                              (buffer-substring beg (point)) rawp)
                           (error nil))))
              (if (listp address)
                  (setq pairs (append address pairs))
                (push address pairs)))
            (condition-case nil
                (forward-char 1)
              (error nil))
	    (setq beg (point)))
	   ((memq c '(?\" ?< ?\())
	    (condition-case nil
		(forward-sexp 1)
	      (error
	       (skip-chars-forward "^,"))))
	   ((eq c ?,)
	    (setq address
		  (if rawp
		      (buffer-substring beg (point))
		    (condition-case nil
			(ietf-drums-parse-address
			 (buffer-substring beg (point)))
		      (error nil))))
	    (when (or (consp address)
                      (and (stringp address) (< 0 (length address))))
              (push address pairs))
	    (forward-char 1)
	    (setq beg (point)))
	   ((not (eobp))
	    (forward-char 1))))
	(setq address
	      (if rawp
		  (buffer-substring beg (point))
		(condition-case nil
		    (ietf-drums-parse-address
		     (buffer-substring beg (point)))
		  (error nil))))
        (when (or (consp address)
                  (and (stringp address) (< 0 (length address))))
          (push address pairs))
	(nreverse pairs)))))