Function: message-tokenize-header

message-tokenize-header is a byte-compiled function defined in message.el.gz.

Signature

(message-tokenize-header HEADER &optional SEPARATOR)

Documentation

Split HEADER into a list of header elements.

SEPARATOR is a string of characters to be used as separators. "," is used by default.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-tokenize-header (header &optional separator)
  "Split HEADER into a list of header elements.
SEPARATOR is a string of characters to be used as separators.  \",\"
is used by default."
  (if (not header)
      nil
    (let ((regexp (format "[%s]+" (or separator ",")))
	  (first t)
	  beg quoted elems paren)
      (with-temp-buffer
	(mm-enable-multibyte)
	(setq beg (point-min))
	(insert header)
	(goto-char (point-min))
	(while (not (eobp))
	  (if first
	      (setq first nil)
	    (forward-char 1))
	  (cond ((and (> (point) beg)
		      (or (eobp)
			  (and (looking-at regexp)
			       (not quoted)
			       (not paren))))
		 (push (buffer-substring beg (point)) elems)
		 (setq beg (match-end 0)))
		((eq (char-after) ?\")
		 (setq quoted (not quoted)))
		((and (eq (char-after) ?\()
		      (not quoted))
		 (setq paren t))
		((and (eq (char-after) ?\))
		      (not quoted))
		 (setq paren nil))))
	(nreverse elems)))))