From 12da2147d1b399e6771196980b4ff83f5c6c7ddc Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 21 Aug 1998 05:22:57 +0000 Subject: [PATCH] * ew-dec.el (ew-decode-us-ascii): New function. (ew-decode-none): Use the function `ew-decode-us-ascii' instead of the variable `ew-decode-us-ascii'. (ew-decode-generic): Ditto. (ew-decode-generic-others): Ditto. * ew-unit.el (ew-charset-aliases): Abolished. (ew-char-decoder): Use `decode-mime-charset-string' with 'LF as lbt. * ew-var.el (ew-decode-us-ascii): Abolished. (ew-default-mime-charset): New variable. (ew-dynamic-options): Add `ew-default-mime-charset'. --- ChangeLog | 15 +++++++++++++++ ew-dec.el | 25 ++++++++++++++----------- ew-unit.el | 18 ++++-------------- ew-var.el | 25 ++++++++++++------------- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index c61e101..6fd654d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 1998-08-21 Tanaka Akira + * ew-dec.el (ew-decode-us-ascii): New function. + (ew-decode-none): Use the function `ew-decode-us-ascii' instead of + the variable `ew-decode-us-ascii'. + (ew-decode-generic): Ditto. + (ew-decode-generic-others): Ditto. + + * ew-unit.el (ew-charset-aliases): Abolished. + (ew-char-decoder): Use `decode-mime-charset-string' with 'LF as lbt. + + * ew-var.el (ew-decode-us-ascii): Abolished. + (ew-default-mime-charset): New variable. + (ew-dynamic-options): Add `ew-default-mime-charset'. + +1998-08-21 Tanaka Akira + * ew-unit.el (ew-eword-p): Use aref instead of substring. (ew-char-decoder): Refined. diff --git a/ew-dec.el b/ew-dec.el index eebda02..d3dea64 100644 --- a/ew-dec.el +++ b/ew-dec.el @@ -92,9 +92,12 @@ instead of its argument." (when (< 0 ew-parse-error-sit-for-seconds) (sit-for ew-parse-error-sit-for-seconds)))))) +(defun ew-decode-us-ascii (str) + (decode-mime-charset-string str ew-default-mime-charset 'LF)) + (defun ew-decode-none (anchor frag end eword-filter) (while (not (eq frag end)) - (put frag 'decoded (funcall ew-decode-us-ascii (symbol-name frag))) + (put frag 'decoded (ew-decode-us-ascii (symbol-name frag))) (setq frag (get frag 'next-frag)))) (defun ew-decode-generic (anchor start end @@ -153,14 +156,14 @@ instead of its argument." ((memq type puncts) (when buff (setq buff (nreverse buff) - tmp (funcall ew-decode-us-ascii - (mapconcat 'car buff ""))) + tmp (ew-decode-us-ascii + (mapconcat 'car buff ""))) (if (ew-contain-non-ascii-p tmp) (setq result (ew-rcons* result tmp)) (setq result (ew-rcons* result - (funcall ew-decode-us-ascii - (mapconcat 'cdr buff ""))))) + (ew-decode-us-ascii + (mapconcat 'cdr buff ""))))) (setq buff ())) (setq result (ew-rcons* result @@ -179,14 +182,14 @@ instead of its argument." (error "something wrong: unexpected token: %s (%s)" frag type)))) (when buff (setq buff (nreverse buff) - tmp (funcall ew-decode-us-ascii - (mapconcat 'car buff ""))) + tmp (ew-decode-us-ascii + (mapconcat 'car buff ""))) (if (ew-contain-non-ascii-p tmp) (setq result (ew-rcons* result tmp)) (setq result (ew-rcons* result - (funcall ew-decode-us-ascii - (mapconcat 'cdr buff ""))))) + (ew-decode-us-ascii + (mapconcat 'cdr buff ""))))) (setq buff ())) (nreverse result))) @@ -208,8 +211,8 @@ instead of its argument." result (symbol-name (car frags))) frags (cdr frags))) - (list (funcall ew-decode-us-ascii - (apply 'concat (nreverse result)))))) + (list (ew-decode-us-ascii + (apply 'concat (nreverse result)))))) (defun ew-decode-unstructured (anchor start end eword-filter) (ew-decode-generic diff --git a/ew-unit.el b/ew-unit.el index b658dca..f706daf 100644 --- a/ew-unit.el +++ b/ew-unit.el @@ -75,19 +75,9 @@ (defalias 'ew-b-decode 'base64-decode-string) (defalias 'ew-q-decode 'q-encoding-decode-string) -(defconst ew-charset-aliases - '((us-ascii . iso-8859-1) - (iso-2022-jp-2 . iso-2022-7bit-ss2) - (x-ctext . ctext) - )) - (defun ew-char-decoder (charset) - (let ((sym (intern (downcase charset))) - tmp cs) - (when (setq tmp (assq sym ew-charset-aliases)) - (setq sym (cdr tmp))) - (setq cs (intern (concat (symbol-name sym) "-unix"))) - (when (coding-system-p cs) + (let ((sym (intern (downcase charset)))) + (when (mime-charset-to-coding-system sym 'LF) (closure-make - (lambda (str) (decode-coding-string str cs)) - cs)))) + (lambda (str) (decode-mime-charset-string str sym 'LF)) + sym)))) diff --git a/ew-var.el b/ew-var.el index 1284d94..936a680 100644 --- a/ew-var.el +++ b/ew-var.el @@ -8,12 +8,7 @@ (defvar ew-ignore-76bytes-limit nil) (defvar ew-permit-sticked-comment nil) (defvar ew-permit-sticked-special nil) - -(defvar ew-parse-error-sit-for-seconds 0) - -;;; anonymous function to decode ground string. -;; NOTE: STR is CRLF-form and it should return as CRLF-form. -(defvar ew-decode-us-ascii (lambda (str) (decode-coding-string str 'iso-latin-1-unix))) +(defvar ew-default-mime-charset 'x-ctext) ;;; (defvar ew-decode-field-syntax-alist @@ -52,6 +47,8 @@ (defvar ew-decode-field-default-syntax '(ew-scan-unibyte-unstructured)) +(defvar ew-parse-error-sit-for-seconds 0) + ;;; constants. (defconst ew-token-regexp "[-!#-'*+0-9A-Z^-~]+") @@ -68,10 +65,12 @@ ;;; utilities for variables. (defun ew-dynamic-options () - (logior - (if ew-decode-sticked-encoded-word 1 0) - (if ew-decode-quoted-encoded-word 2 0) - (if ew-ignore-75bytes-limit 4 0) - (if ew-ignore-76bytes-limit 8 0) - (if ew-permit-sticked-comment 16 0) - (if ew-permit-sticked-special 32 0))) + (cons + ew-default-mime-charset + (logior + (if ew-decode-sticked-encoded-word 1 0) + (if ew-decode-quoted-encoded-word 2 0) + (if ew-ignore-75bytes-limit 4 0) + (if ew-ignore-76bytes-limit 8 0) + (if ew-permit-sticked-comment 16 0) + (if ew-permit-sticked-special 32 0)))) -- 1.7.10.4