From: keiichi Date: Wed, 24 Nov 1999 10:38:52 +0000 (+0000) Subject: (mime-parse-parameters): Use `mime-parse-parameters-from-list'. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=a91adebe284075cbe0a8d56d504881562b4eb06f;p=elisp%2Fflim.git (mime-parse-parameters): Use `mime-parse-parameters-from-list'. (mime-parse-parameters-from-list): New function. --- diff --git a/mime-parse.el b/mime-parse.el index 2a6a2ba..796d099 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -86,66 +86,73 @@ be the result." (let* ((lrl (std11-lexical-analyze str mime-lexical-analyzer)) (token (car lrl)) rest name val) - (catch 'parse-error - (while (and token - (eq (car token) 'tpecials) - (string= (cdr token) ";") - ) - (setq token nil) - (when (and (setq lrl (mime-parse-parameters-skip-to-next-token - (cdr lrl) - )) - (setq name (cdar lrl)) - (setq lrl (mime-parse-parameters-skip-to-next-token - (cdr lrl) - )) - (string= (cdar lrl) "=") - (setq lrl (mime-parse-parameters-skip-to-next-token - (cdr lrl) - )) - (setq val (cdar lrl))) - (when (string-match "^\\([^*]+\\)\\(\\*\\([0-9]+\\)\\)?\\(\\*\\)?" - name) - (let ((number (if (match-beginning 3) - (string-to-int (substring name - (match-beginning 3) - (match-end 3) - )) - 0)) - (encoded (if (match-beginning 4) t nil)) - parm) - (setq name (substring name (match-beginning 1) (match-end 1)) - parm (or (assoc name rest) - (car (setq rest - (cons (make-mime-parameter name) - rest))))) - (when (and (eq number 0) - encoded - (string-match "^\\([^']*\\)'\\([^']*\\)'\\(.*\\)" - val)) - (when (< (match-beginning 1) (match-end 1)) - (mime-parameter-set-charset - parm - (intern (downcase (substring val - (match-beginning 1) - (match-end 1) - ))))) - (when (< (match-beginning 2) (match-end 2)) - (mime-parameter-set-language - parm - (intern (downcase (substring val - (match-beginning 2) - (match-end 2) - ))))) - (setq val (substring val (match-beginning 3))) + (while (and token + (eq (car token) 'tpecials) + (string= (cdr token) ";") + ) + (if (and (setq lrl (mime-parse-parameters-skip-to-next-token + (cdr lrl) + )) + (setq name (cdar lrl)) + (setq lrl (mime-parse-parameters-skip-to-next-token + (cdr lrl) + )) + (string= (cdar lrl) "=") + (setq lrl (mime-parse-parameters-skip-to-next-token + (cdr lrl) + )) + (setq val (cdar lrl))) + (setq lrl (mime-parse-parameters-skip-to-next-token (cdr lrl)) + token (car lrl) + rest (cons val rest) + rest (cons name rest) ) - (mime-parameter-append-raw-value parm number encoded val) - (setq lrl (mime-parse-parameters-skip-to-next-token - (cdr lrl) - ) - token (car lrl) - )))))) - rest)) + (setq token nil))) + (mime-parse-parameters-from-list rest))) + +(defun mime-parse-parameters-from-list (list) + (let (rest name val) + (while list + (let ((name (car list)) + (val (cadr list))) + (setq list (cddr list)) + (when (string-match "^\\([^*]+\\)\\(\\*\\([0-9]+\\)\\)?\\(\\*\\)?" + name) + (let ((number (if (match-beginning 3) + (string-to-int (substring name + (match-beginning 3) + (match-end 3))) + 0)) + (encoded (if (match-beginning 4) t nil)) + (parm (progn + (setq name (substring name + (match-beginning 1) + (match-end 1))) + (or (assoc name rest) + (car (setq rest + (cons (make-mime-parameter name) + rest))))))) + (when (and (eq number 0) + encoded + (string-match "^\\([^']*\\)'\\([^']*\\)'\\(.*\\)" val)) + (when (< (match-beginning 1) (match-end 1)) + (mime-parameter-set-charset + parm + (intern (downcase (substring val + (match-beginning 1) + (match-end 1) + ))))) + (when (< (match-beginning 2) (match-end 2)) + (mime-parameter-set-language + parm + (intern (downcase (substring val + (match-beginning 2) + (match-end 2) + ))))) + (setq val (substring val (match-beginning 3))) + ) + (mime-parameter-append-raw-value parm number encoded val))))) + rest)) ;;; @ Content-Type ;;;