From: morioka Date: Sun, 8 Nov 1998 17:36:45 +0000 (+0000) Subject: (eword-decode-structured-field-body): New implementation; abolish X-Git-Tag: chao-1_12_2~3 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dde6a6df5904f787917f58dde8e23114ddb15d0;p=elisp%2Fflim.git (eword-decode-structured-field-body): New implementation; abolish optional argument `must-unfold'; delete DOC-string. (eword-decode-and-unfold-structured-field-body): Renamed from `eword-decode-and-unfold-structured-field'; delete DOC-string. (eword-decode-and-fold-structured-field-body): Renamed from `eword-decode-and-fold-structured-field'; abolish optional argument `must-unfold'; delete DOC-string. (eword-decode-unstructured-field-body): Abolish optional argument `must-unfold'; delete DOC-string. (eword-decode-and-unfold-unstructured-field-body): Renamed from `eword-decode-and-unfold-unstructured-field'; delete DOC-string. (eword-decode-unfolded-unstructured-field-body): New function. --- diff --git a/eword-decode.el b/eword-decode.el index b898f95..a6e4220 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -109,28 +109,53 @@ such as a version of Net$cape)." (concat dest string) )) -(defun eword-decode-and-fold-structured-field - (string start-column &optional max-column must-unfold) - "Decode and fold (fill) STRING as structured field body. +(defun eword-decode-structured-field-body (string + &optional start-column max-column) + (let ((tokens (eword-lexical-analyze string 'must-unfold)) + (result "")) + (while tokens + (let* ((token (car tokens)) + (type (car token))) + (setq tokens (cdr tokens)) + (setq result + (concat result (eword-decode-token token))) + )) + result)) + +(defun eword-decode-and-unfold-structured-field-body (string + &optional + start-column + max-column) + "Decode and unfold STRING as structured field body. It decodes non us-ascii characters in FULL-NAME encoded as encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii characters are regarded as variable `default-mime-charset'. If an encoded-word is broken or your emacs implementation can not -decode the charset included in it, it is not decoded. - -If MAX-COLUMN is omitted, `fill-column' is used. +decode the charset included in it, it is not decoded." + (let ((tokens (eword-lexical-analyze string 'must-unfold)) + (result "")) + (while tokens + (let* ((token (car tokens)) + (type (car token))) + (setq tokens (cdr tokens)) + (setq result + (if (eq type 'spaces) + (concat result " ") + (concat result (eword-decode-token token)) + )))) + result)) -If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even -if there are in decoded encoded-words (generated by bad manner MUA -such as a version of Net$cape)." +(defun eword-decode-and-fold-structured-field-body (string + start-column + &optional max-column) (if (and eword-max-size-to-decode (> (length string) eword-max-size-to-decode)) string (or max-column (setq max-column fill-column)) (let ((c start-column) - (tokens (eword-lexical-analyze string must-unfold)) + (tokens (eword-lexical-analyze string 'must-unfold)) (result "") token) (while (and (setq token (car tokens)) @@ -156,88 +181,26 @@ such as a version of Net$cape)." (concat result (eword-decode-token token)) result)))) -(defun eword-decode-and-unfold-structured-field (string - &optional start-column - max-column) - "Decode and unfold STRING as structured field body. -It decodes non us-ascii characters in FULL-NAME encoded as -encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii -characters are regarded as variable `default-mime-charset'. - -If an encoded-word is broken or your emacs implementation can not -decode the charset included in it, it is not decoded." - (let ((tokens (eword-lexical-analyze string 'must-unfold)) - (result "")) - (while tokens - (let* ((token (car tokens)) - (type (car token))) - (setq tokens (cdr tokens)) - (setq result - (if (eq type 'spaces) - (concat result " ") - (concat result (eword-decode-token token)) - )))) - result)) - -(defun eword-decode-structured-field-body (string &optional start-column - max-column must-unfold) - "Decode non us-ascii characters in STRING as structured field body. -STRING is unfolded before decoding. - -It decodes non us-ascii characters in FULL-NAME encoded as -encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii -characters are regarded as variable `default-mime-charset'. - -If an encoded-word is broken or your emacs implementation can not -decode the charset included in it, it is not decoded. - -If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even -if there are in decoded encoded-words (generated by bad manner MUA -such as a version of Net$cape)." - (if start-column - ;; fold with max-column - (eword-decode-and-fold-structured-field - string start-column max-column must-unfold) - ;; Don't fold - (mapconcat (function eword-decode-token) - (eword-lexical-analyze string must-unfold) - "") - )) - (defun eword-decode-unstructured-field-body (string &optional start-column - max-column must-unfold) - "Decode non us-ascii characters in STRING as unstructured field body. -STRING is unfolded before decoding. - -It decodes non us-ascii characters in FULL-NAME encoded as -encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii -characters are regarded as variable `default-mime-charset'. - -If an encoded-word is broken or your emacs implementation can not -decode the charset included in it, it is not decoded. - -If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even -if there are in decoded encoded-words (generated by bad manner MUA -such as a version of Net$cape)." + max-column) (eword-decode-string - (decode-mime-charset-string string default-mime-charset) - must-unfold)) + (decode-mime-charset-string string default-mime-charset))) -(defun eword-decode-and-unfold-unstructured-field (string - &optional start-column - max-column) - "Decode and unfold STRING as unstructured field body. -It decodes non us-ascii characters in FULL-NAME encoded as -encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii -characters are regarded as variable `default-mime-charset'. - -If an encoded-word is broken or your emacs implementation can not -decode the charset included in it, it is not decoded." +(defun eword-decode-and-unfold-unstructured-field-body (string + &optional start-column + max-column) (eword-decode-string (decode-mime-charset-string (std11-unfold-string string) default-mime-charset) 'must-unfold)) +(defun eword-decode-unfolded-unstructured-field-body (string + &optional start-column + max-column) + (eword-decode-string + (decode-mime-charset-string string default-mime-charset) + 'must-unfold)) + ;;; @ for region ;;; @@ -437,18 +400,18 @@ Default value of MODE is `summary'." (mime-set-field-decoder field 'plain #'eword-decode-structured-field-body - 'wide #'eword-decode-and-fold-structured-field - 'summary #'eword-decode-and-unfold-structured-field - 'nov #'eword-decode-and-unfold-structured-field) + 'wide #'eword-decode-and-fold-structured-field-body + 'summary #'eword-decode-and-unfold-structured-field-body + 'nov #'eword-decode-and-unfold-structured-field-body) )) ;; unstructured fields (default) (mime-set-field-decoder t - 'plain #'eword-decode-unstructured-field-body - 'wide #'eword-decode-unstructured-field-body - 'summary #'eword-decode-and-unfold-unstructured-field - 'nov #'eword-decode-and-unfold-unstructured-field) + 'plain #'eword-decode-unstructured-field-body + 'wide #'eword-decode-unstructured-field-body + 'summary #'eword-decode-and-unfold-unstructured-field-body + 'nov #'eword-decode-unfolded-unstructured-field-body) ;;;###autoload (defun mime-decode-field-body (field-body field-name