[Mew-dist 08709] Re: B-encoded header routine

Kazu Yamamoto ( 山本和彦 ) kazu at example.com
1999年 5月 6日 (木) 13:11:20 JST


From: 小関 吉則 ( KOSEKI Yoshinori) <kose at example.com>
Subject: [Mew-dist 08680] Re: B-encoded header routine
Date: Wed, 28 Apr 1999 10:29:30 +0900

> 現在の Mew では 
> 
> From: 小関 吉則 (KOSEKI Yoshinori) <kose at example.com>
> 
>> 
> From: =?iso-2022-jp?B?GyRCPi40WBsoQiAbJEI1SEInGyhCIA==?=(
>  KOSEKI Yoshinori) <kose at example.com>
> 
> としますので decode すると 

とりあえずパッチを作りました。勇気ある人は、これを b25 に当てて、いろ
いろ試して頂けると幸いです。

#はっきりいって泥沼。RFC 2047 きらい。

--かず

-------------- next part --------------
Index: mew-bq.el
===================================================================
RCS file: /usr/home/kazu/cvsroot/Mew/mew/mew-bq.el,v
retrieving revision 1.54
diff -c -r1.54 mew-bq.el
*** mew-bq.el	1999/02/28 14:57:14	1.54
--- mew-bq.el	1999/05/06 04:11:13
***************
*** 362,379 ****
  	((equal status 'non-ascii)
  	 (setq status 'non-ascii))
  	((equal status 'non-ascii-space)
! 	 (mew-header-encode-text (substring str bound (1- i)))
  	 ;; non-ascii
! 	 (insert (substring str (1- i) i)) ;; a space
  	 (setq bound i)
  	 (setq status 'ascii))))
        ;; end of ascii
        )))
  
  (defun mew-header-encode-addr (str)
    (let* ((len (length str))
  	 (i 0) (bound 0) (status 'space)
! 	 open c I)
      ;; status space, ascii, non-ascii, non-ascii-space
      ;; assumptions:
      ;;  <> doesn't contain non-ascii characters.
--- 362,391 ----
  	((equal status 'non-ascii)
  	 (setq status 'non-ascii))
  	((equal status 'non-ascii-space)
! 	 (mew-header-encode-text (substring str bound SBOUND))
  	 ;; non-ascii
! 	 (insert (substring str SBOUND i)) ;; spaces
  	 (setq bound i)
  	 (setq status 'ascii))))
        ;; end of ascii
        )))
  
+ (defmacro mew-header-encode-cond2 (opt)
+   (` (cond
+       ((equal status 'ascii)
+        (mew-header-insert-ascii-addr (substring str bound i)))
+       ((equal status 'space)
+        (mew-header-insert-ascii-addr (substring str bound i)))
+       ((equal status 'non-ascii)
+        (mew-header-encode-text (substring str bound i)) (, opt))
+       ((equal status 'non-ascii-space)
+        (mew-header-encode-text (substring str bound SBOUND) (, opt))
+        (insert (substring str SBOUND i))))))
+ 
  (defun mew-header-encode-addr (str)
    (let* ((len (length str))
  	 (i 0) (bound 0) (status 'space)
! 	 SBOUND open c I)
      ;; status space, ascii, non-ascii, non-ascii-space
      ;; assumptions:
      ;;  <> doesn't contain non-ascii characters.
***************
*** 406,415 ****
         ;; end of quote
         ;; comment
         ((char-equal c ?\()
! 	(if (or (equal status 'ascii) (equal status 'space))
! 	    (mew-header-insert-ascii-addr (substring str bound i))
! 	  (mew-header-encode-text (substring str bound i)))
! 	(insert "(")
  	(setq i (1+ i))
  	(setq bound i)
  	(setq status 'ascii)
--- 418,425 ----
         ;; end of quote
         ;; comment
         ((char-equal c ?\()
! 	(mew-header-encode-cond2 nil)
! 	(mew-header-insert-ascii-text "(")
  	(setq i (1+ i))
  	(setq bound i)
  	(setq status 'ascii)
***************
*** 428,439 ****
  	    (progn
  	      (mew-draft-undo)
  	      (error "Comment must be closed in the header. ")))
! 	(if (equal status 'ascii)
! 	    (mew-header-insert-ascii-addr (substring str bound i))
! 	  (mew-header-encode-text (substring str bound i) 'comment))
  	(if (equal i len)
  	    ()
! 	  (insert ")")
  	  (setq bound (1+ i)))
  	(setq status 'space))
         ;; end of ()
--- 438,447 ----
  	    (progn
  	      (mew-draft-undo)
  	      (error "Comment must be closed in the header. ")))
! 	(mew-header-encode-cond2 'comment)
  	(if (equal i len)
  	    ()
! 	  (mew-header-insert-ascii-text ")")
  	  (setq bound (1+ i)))
  	(setq status 'space))
         ;; end of ()
***************
*** 445,459 ****
  	  (setq bound i)
  	  (setq status 'space))
  	 ((equal status 'non-ascii)
! 	  (setq status 'non-ascii-space))
  	 ))
         ;; end of white space
         ;; comma
         ((char-equal c ?,)
! 	(cond
! 	 ((or (equal status 'ascii) (equal status 'space))
! 	  (mew-header-insert-ascii-addr (substring str bound i)))
! 	 (t (mew-header-encode-text (substring str bound i))))
  	(insert ",\n ")
  	(setq i (1+ i))
  	(catch 'comma
--- 453,465 ----
  	  (setq bound i)
  	  (setq status 'space))
  	 ((equal status 'non-ascii)
! 	  (setq status 'non-ascii-space)
! 	  (setq SBOUND i))
  	 ))
         ;; end of white space
         ;; comma
         ((char-equal c ?,)
! 	(mew-header-encode-cond2 nil)
  	(insert ",\n ")
  	(setq i (1+ i))
  	(catch 'comma
***************
*** 473,482 ****
        ;; end of outside cond
        (setq i (+ i (mew-charlen c))))
      ;; end of while
!     (cond
!      ((or (equal status 'ascii) (equal status 'space))
!       (mew-header-insert-ascii-addr (substring str bound i)))
!      (t (mew-header-encode-text (substring str bound i))))))
  
  (defun mew-header-encode-text (str &optional comment)
    ;; `comment' means that we are in RFC822 comment "(...)".
--- 479,485 ----
        ;; end of outside cond
        (setq i (+ i (mew-charlen c))))
      ;; end of while
!     (mew-header-encode-cond2 nil)))
  
  (defun mew-header-encode-text (str &optional comment)
    ;; `comment' means that we are in RFC822 comment "(...)".


Mew-dist メーリングリストの案内