From: morioka Date: Mon, 31 May 1999 10:25:30 +0000 (+0000) Subject: Sync up with flim-1_12_7. X-Git-Tag: chao-1_13_0~5 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=88006a55b33c0bb9f537158612a9880f50176792;p=elisp%2Fflim.git Sync up with flim-1_12_7. --- diff --git a/ChangeLog b/ChangeLog index 17213f7..27059be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,10 +52,6 @@ 1999-05-25 MORIOKA Tomohiko - * README.ja (install): Fixed - -1999-05-25 MORIOKA Tomohiko - * mmbuffer.el (mime-entity-body-end-point): New method. (mime-goto-header-start-point): New method. (mime-goto-body-start-point): New method. @@ -65,11 +61,6 @@ * mel.el (Q-encoded-text-length): Fixed. -1999-05-25 Yoshiki Hayashi - - * README.ja: Sync up with the latest README.en of flim-1_12 - branch. - 1999-05-24 MORIOKA Tomohiko * mmbuffer.el (mime-parse-multipart): Refer body-start instead of @@ -270,6 +261,181 @@ * luna.el: New module. +1999-05-31 MORIOKA Tomohiko + + * FLIM: Version 1.12.7 (Y-Dþzaki)-A released. + +1999-05-31 MORIOKA Tomohiko + + * mime-en.sgml (Network representation of header): Translate. + +1999-05-27 Shuhei KOBAYASHI + + * mel-b-el.el (pack-sequence): Eliminate local variable `i'. + (base64-encode-1): Avoid concat. + (base64-encode-string): Fixed last change; extra padding. + +1999-05-26 MORIOKA Tomohiko + + * smtpmail.el (smtpmail-default-smtp-server): Define obsolete + variable alias for XEmacs. + (smtpmail-smtp-server): Likewise. + (smtpmail-smtp-service): Likewise. + (smtpmail-local-domain): Likewise. + (smtpmail-debug-info): Likewise. + (smtpmail-send-it): Check function `expand-mail-aliases' is + defined. + +1999-05-26 MORIOKA Tomohiko + + * smtp.el (smtp-debug-info): Now a user option. + +1999-05-25 Yoshiki Hayashi + + * README.ja: Modify URL and required version of APEL. + +1999-05-24 Tanaka Akira + + * mel-b-ccl.el (base64-encode-string): New alias. + (base64-encode-region): Ditto. + (base64-decode-string): Ditto. + (base64-decode-region): Ditto. + +1999-05-24 Tanaka Akira + + * mel-b-ccl.el, mel-q-ccl.el: Sync up with doodle-1.12.5. + +1999-05-24 MORIOKA Tomohiko + + * eword-encode.el (ew-space-process): Renamed from + `tm-eword::space-process'. + +1999-05-24 MORIOKA Tomohiko + + * eword-encode.el (tm-eword::space-process): Don't concatenate + `special's. + (ew-encode-rword-1): Renamed from `tm-eword::encode-string-1'; add + new optional argument `must-output'; return nil if it can't encode + literally. + (eword-encode-rword-list): Fold SPACE or TAB in the encoded string + if `ew-encode-rword-1' can't encode literally and it is possible + to encode the rest literally with the folding. + (eword-encode-phrase-to-rword-list): Add `special' flag to + brackets of comments. + +1999-05-22 Shuhei KOBAYASHI + + * smtpmail.el: Require 'poe and 'pcustom. + +1999-05-22 Shuhei KOBAYASHI + + * mel.el: Update header. + Require 'path-util and don't require 'poem. + (mel-use-module): Eliminate local variable `encoding'. + (mime-insert-encoded-file for mel-b-builtin): + Use built-in `interactive' spec. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + (mime-encode-region): Capitalize prompt string. + (mime-decode-region): Ditto. + (mime-insert-encoded-file): Ditto. + (mime-write-decoded-region): Ditto. + + * mel-b-ccl.el: Update header. + (base64-ccl-encode-region): Use read-only `interactive' spec. + (base64-ccl-decode-region): Ditto. + (base64-ccl-insert-encoded-file): Use built-in `interactive' spec. + (base64-ccl-write-decoded-region): Ditto. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + + * mel-b-dl.el: Update header. + Don't require 'poe; it is required implicitly via 'mime-def. + (base64-dl-handle): Chech whether `base64-dl-module' is string. + Defalias `base64-encode-string' and `base64-decode-string' just + after `dynamic-call'ing "emacs_base64_init". + (base64-encode-region): Use read-only `interactive' spec. + Use `base64-encode-string'. + Changed order of evaluation to "encode, delete, then insert". + (base64-decode-region): Renamed from `decode-base64-region'. + Use read-only `interactive' spec. + Use `base64-decode-string'. + Changed order of evaluation to "decode, delete, then insert". + (mime-encode-string): Use `base64-encode-string'. + (mime-decode-string): Use `base64-decode-string'. + (mime-decode-region): Use `base64-decode-region'. + (encoded-text-encode-string): Use `base64-encode-string'. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + (mime-insert-encoded-file): Use built-in `interactive' spec. + (mime-write-decoded-region in comment): Ditto. + + * mel-b-el.el: Update header. + Don't require 'poe; it is required implicitly via 'mime-def. + (pack-sequence): Moved to top of the function definitions. + (base64-encode-string): Calculate padding first. + (base64-internal-encode-region): Changed order of evaluation to + "encode, delete, then insert". + (base64-internal-decode-string): Changed order of evaluation to + "decode, delete, then insert". + (base64-encode-region): Use read-only `interactive' spec. + (base64-decode-region): Ditto. + (base64-decode-string): Not interactive. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + (base64-insert-encoded-file): Use built-in `interactive' spec. + (base64-write-decoded-region): Ditto. + + * mel-g.el: Update header. + Require 'mime-def instead of 'poem and 'mel. + (mime-insert-encoded-file): Use built-in `interactive' spec. + (mime-write-decoded-region): Ditto. + + * mel-q-ccl.el: Update header. + (quoted-printable-ccl-encode-region): + Use read-only `interactive' spec. + (quoted-printable-ccl-decode-region): Ditto. + (quoted-printable-ccl-insert-encoded-file): + Use built-in `interactive' spec. + (quoted-printable-ccl-write-decoded-region): Ditto. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + + * mel-q.el: Update header. + Require 'path-util instead of 'emu. + (quoted-printable-internal-encode-region): Rewrite without regexp. + (quoted-printable-internal-decode-region): Ditto. + (quoted-printable-encode-region): Use read-only `interactive' spec. + (quoted-printable-decode-region): Ditto. + (mime-insert-encoded-file): Use built-in `interactive' spec. + (mime-write-decoded-region): Ditto. + (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". + + * mel-u.el: Update header. + Require 'path-util instead of 'emu. + (mime-insert-encoded-file): Use built-in `interactive' spec. + (mime-write-decoded-region): Ditto. + +1999-05-22 Shuhei KOBAYASHI + + * mime-def.el: Require 'poe, 'poem, and 'pcustom. + (mime): Declare `default-mime-charset' as an initial member. + + * mime-parse.el: Don't require 'cl at compile-time. + + * mailcap.el (mailcap-look-at-qchar): Use `char-after'. + + * std11.el: Require 'poe, 'poem, and 'pcustom. + + * smtp.el: Update header. + Require 'poe, 'poem, and 'pcustom. + Require 'cl at compile-time. + +1999-05-21 MORIOKA Tomohiko + + * README.en (Installation): Modify URL and required version of + APEL. + + * eword-encode.el (ew-find-charset-rule): Renamed from + `tm-eword::find-charset-rule'; use + `find-mime-charset-by-charsets'. + + 1999-05-11 MORIOKA Tomohiko * FLIM: Version 1.12.6 (Family-K-Dòenmae)-A released. diff --git a/Makefile b/Makefile index 67cc56d..275b57e 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,9 @@ # Makefile for FLIM. # -PACKAGE = flim -API = 1.12 -RELEASE = 6 +PACKAGE = chao +API = 1.13 +RELEASE = 0 TAR = tar RM = /bin/rm -f diff --git a/README.en b/README.en index 358e4e3..c8ed0b2 100644 --- a/README.en +++ b/README.en @@ -39,10 +39,10 @@ What's FLIM Installation ============ -(0) before installing it, please install APEL (9.12 or later) package. +(0) before installing it, please install APEL (9.19 or later) package. APEL package is available at: - ftp://ftp.jaist.ac.jp/pub/GNU/elisp/apel/ + ftp://ftp.etl.go.jp/pub/mule/apel/ (1-a) run in expanded place diff --git a/README.ja b/README.ja index c6fa67c..c3742e1 100644 --- a/README.ja +++ b/README.ja @@ -37,7 +37,7 @@ FLIM $B$H$O!)(B $BF3F~(B (install) ============== -(0) $BF3F~(B (install) $B$9$kA0$K!"(BAPEL (9.12 $B0J9_(B) $B$rF3F~$7$F$/$@$5$$!#(BAPEL +(0) $BF3F~(B (install) $B$9$kA0$K!"(BAPEL (9.19 $B0J9_(B) $B$rF3F~$7$F$/$@$5$$!#(BAPEL $B$O0J2<$N$H$3$m$G $(B6aE4(B $(B@>ED86K\(B ------ Kasanui $(B3^K%(B diff --git a/eword-decode.el b/eword-decode.el index 528a927..dd46d32 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -32,11 +32,11 @@ ;;; Code: -(require 'std11) -(require 'mel) (require 'mime-def) +(require 'mel) +(require 'std11) -(eval-when-compile (require 'cl)) +(eval-when-compile (require 'cl)) ; list*, pop (defgroup eword-decode nil "Encoded-word decoding" diff --git a/eword-encode.el b/eword-encode.el index 1bca5cf..4f45c6f 100644 --- a/eword-encode.el +++ b/eword-encode.el @@ -24,10 +24,9 @@ ;;; Code: -(require 'poem) +(require 'mime-def) (require 'mel) (require 'std11) -(require 'mime-def) (require 'eword-decode) @@ -184,30 +183,31 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is (defmacro ew-rword-type (rword) (` (car (cdr (cdr (cdr (, rword))))))) -(defun tm-eword::find-charset-rule (charsets) +(defun ew-find-charset-rule (charsets) (if charsets - (let* ((charset (charsets-to-mime-charset charsets)) - (encoding (cdr (assq charset eword-charset-encoding-alist))) - ) + (let* ((charset (find-mime-charset-by-charsets charsets)) + (encoding (cdr (or (assq charset eword-charset-encoding-alist) + '(nil . "Q"))))) (list charset encoding) ))) (defun tm-eword::words-to-ruled-words (wl &optional mode) (mapcar (function (lambda (word) - (let ((ret (tm-eword::find-charset-rule (car word)))) + (let ((ret (ew-find-charset-rule (car word)))) (make-ew-rword (cdr word) (car ret)(nth 1 ret) mode) ))) wl)) -(defun tm-eword::space-process (seq) +(defun ew-space-process (seq) (let (prev a ac b c cc) (while seq (setq b (car seq)) (setq seq (cdr seq)) (setq c (car seq)) (setq cc (ew-rword-charset c)) - (if (null (ew-rword-charset b)) + (if (and (null (ew-rword-charset b)) + (not (eq (ew-rword-type b) 'special))) (progn (setq a (car prev)) (setq ac (ew-rword-charset a)) @@ -236,7 +236,7 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is )) (defun eword-encode-split-string (str &optional mode) - (tm-eword::space-process + (ew-space-process (tm-eword::words-to-ruled-words (eword-encode-charset-words-to-words (eword-encode-divide-into-charset-words str)) @@ -268,117 +268,117 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is ;;; @ encode-string ;;; -(defun tm-eword::encode-string-1 (column rwl) - (let* ((rword (car rwl)) - (ret (tm-eword::encoded-word-length rword)) - string len) - (if (null ret) - (cond ((and (setq string (car rword)) - (or (<= (setq len (+ (length string) column)) 76) - (<= column 1)) +(defun ew-encode-rword-1 (column rwl &optional must-output) + (catch 'can-not-output + (let* ((rword (car rwl)) + (ret (tm-eword::encoded-word-length rword)) + string len) + (if (null ret) + (cond ((and (setq string (car rword)) + (or (<= (setq len (+ (length string) column)) 76) + (<= column 1)) + ) + (setq rwl (cdr rwl)) + ) + ((memq (aref string 0) '(? ?\t)) + (setq string (concat "\n" string) + len (length string) + rwl (cdr rwl)) + ) + (must-output + (setq string "\n " + len 1) + ) + (t + (throw 'can-not-output nil) + )) + (cond ((and (setq len (car ret)) + (<= (+ column len) 76) ) + (setq string + (eword-encode-text + (ew-rword-charset rword) + (ew-rword-encoding rword) + (cdr ret) + (ew-rword-type rword) + )) + (setq len (+ (length string) column)) (setq rwl (cdr rwl)) ) (t - (setq string "\n ") - (setq len 1) - )) - (cond ((and (setq len (car ret)) - (<= (+ column len) 76) - ) - (setq string - (eword-encode-text - (ew-rword-charset rword) - (ew-rword-encoding rword) - (cdr ret) - (ew-rword-type rword) - )) - (setq len (+ (length string) column)) - (setq rwl (cdr rwl)) - ) - (t - (setq string (car rword)) - (let* ((p 0) np - (str "") nstr) - (while (and (< p len) - (progn - (setq np (char-next-index (sref string p) p)) - (setq nstr (substring string 0 np)) - (setq ret (tm-eword::encoded-word-length - (cons nstr (cdr rword)) - )) - (setq nstr (cdr ret)) - (setq len (+ (car ret) column)) - (<= len 76) - )) - (setq str nstr - p np)) - (if (string-equal str "") - (setq string "\n " - len 1) - (setq rwl (cons (cons (substring string p) (cdr rword)) - (cdr rwl))) - (setq string - (eword-encode-text - (ew-rword-charset rword) - (ew-rword-encoding rword) - str - (ew-rword-type rword))) - (setq len (+ (length string) column)) - ) - ))) - ) - (list string len rwl) - )) + (setq string (car rword)) + (let* ((p 0) np + (str "") nstr) + (while (and (< p len) + (progn + (setq np (char-next-index (sref string p) p)) + (setq nstr (substring string 0 np)) + (setq ret (tm-eword::encoded-word-length + (cons nstr (cdr rword)) + )) + (setq nstr (cdr ret)) + (setq len (+ (car ret) column)) + (<= len 76) + )) + (setq str nstr + p np)) + (if (string-equal str "") + (if must-output + (setq string "\n " + len 1) + (throw 'can-not-output nil)) + (setq rwl (cons (cons (substring string p) (cdr rword)) + (cdr rwl))) + (setq string + (eword-encode-text + (ew-rword-charset rword) + (ew-rword-encoding rword) + str + (ew-rword-type rword))) + (setq len (+ (length string) column)) + ) + ))) + ) + (list string len rwl) + ))) (defun eword-encode-rword-list (column rwl) - (let (ret dest ps special str ew-f pew-f bew) + (let (ret dest str ew-f pew-f folded-points) (while rwl (setq ew-f (nth 2 (car rwl))) (if (and pew-f ew-f) (setq rwl (cons '(" ") rwl) - bew t pew-f nil) - (setq pew-f ew-f - bew nil) + (setq pew-f ew-f) ) - (setq ret (tm-eword::encode-string-1 column rwl)) + (if (null (setq ret (ew-encode-rword-1 column rwl))) + (let ((i (1- (length dest))) + c s r-dest r-column) + (catch 'success + (while (catch 'found + (while (>= i 0) + (cond ((memq (setq c (aref dest i)) '(? ?\t)) + (if (memq i folded-points) + (throw 'found nil) + (setq folded-points (cons i folded-points)) + (throw 'found i)) + ) + ((eq c ?\n) + (throw 'found nil) + )) + (setq i (1- i)))) + (setq s (substring dest i) + r-column (length s) + r-dest (concat (substring dest 0 i) "\n" s)) + (when (setq ret (ew-encode-rword-1 r-column rwl)) + (setq dest r-dest + column r-column) + (throw 'success t) + )) + (setq ret (ew-encode-rword-1 column rwl 'must-output)) + ))) (setq str (car ret)) - (if (eq (elt str 0) ?\n) - (cond - ((eq special ?\() - (setq dest (concat dest "\n (")) - (setq ret (tm-eword::encode-string-1 2 rwl)) - (setq str (car ret))) - ((eq bew t) - (setq dest (concat dest "\n ")) - (setq ret (tm-eword::encode-string-1 1 (cdr rwl))) - (setq str (car ret)))) - (cond ((eq special ? ) - (if (string= str "(") - (setq ps t) - (setq dest (concat dest " ")) - (setq ps nil) - )) - ((eq special ?\() - (if ps - (progn - (setq dest (concat dest " (")) - (setq ps nil) - ) - (setq dest (concat dest "(")) - ) - ))) - (cond ((string= str " ") - (setq special ? ) - ) - ((string= str "(") - (setq special ?\() - ) - (t - (setq special nil) - (setq dest (concat dest str)) - )) + (setq dest (concat dest str)) (setq column (nth 1 ret) rwl (nth 2 ret)) ) @@ -399,7 +399,7 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is (setq dest (append dest (list - (let ((ret (tm-eword::find-charset-rule + (let ((ret (ew-find-charset-rule (find-non-ascii-charset-string str)))) (make-ew-rword str (car ret)(nth 1 ret) 'phrase) @@ -409,13 +409,13 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is ((eq type 'comment) (setq dest (append dest - '(("(" nil nil)) + '(("(" nil nil special)) (tm-eword::words-to-ruled-words (eword-encode-charset-words-to-words (eword-encode-divide-into-charset-words (cdr token))) 'comment) - '((")" nil nil)) + '((")" nil nil special)) )) ) (t @@ -429,7 +429,7 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is )) (setq phrase (cdr phrase)) ) - (tm-eword::space-process dest) + (ew-space-process dest) )) (defun eword-encode-addr-seq-to-rword-list (seq) diff --git a/mailcap.el b/mailcap.el index 12eee88..eb1c093 100644 --- a/mailcap.el +++ b/mailcap.el @@ -95,11 +95,11 @@ (forward-char))))) (defsubst mailcap-look-at-qchar () - (let ((chr (char-after (point)))) - (when (eq chr ?\\) - (forward-char 2) - (char-before (point)) - ))) + (when (eq (char-after (point)) ?\\) + (prog2 + (forward-char) + (char-after (point)) + (forward-char)))) (defsubst mailcap-look-at-mtext () (let ((beg (point))) diff --git a/mel-b-ccl.el b/mel-b-ccl.el index 02fd3e3..fa12483 100644 --- a/mel-b-ccl.el +++ b/mel-b-ccl.el @@ -1,6 +1,6 @@ -;;; mel-b-ccl.el: CCL based encoder/decoder of Base64 +;;; mel-b-ccl.el --- Base64 encoder/decoder using CCL. -;; Copyright (C) 1998 Tanaka Akira +;; Copyright (C) 1998,1999 Tanaka Akira ;; Author: Tanaka Akira ;; Created: 1998/9/17 @@ -19,7 +19,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -288,9 +288,10 @@ abcdefghijklmnopqrstuvwxyz\ (&optional quantums-per-line output-crlf terminate-with-newline) `(2 ((r3 = 0) + (r2 = 0) + (read r1) (loop - (r2 = 0) - (read-branch + (branch r1 ,@(mapcar (lambda (r1) @@ -331,6 +332,8 @@ abcdefghijklmnopqrstuvwxyz\ (nth r1 mel-ccl-64-to-256-table)) mel-ccl-64-table))) (r3 += 1) + (r2 = 0) + (read r1) ,@(when quantums-per-line `((if (r3 == ,quantums-per-line) ((write ,(if output-crlf "\r\n" "\n")) @@ -398,18 +401,24 @@ abcdefghijklmnopqrstuvwxyz\ (unless-broken ccl-execute-eof-block-on-decoding-some - (defun base64-ccl-encode-string (string) + (defun base64-ccl-encode-string (string &optional no-line-break) "Encode STRING with base64 encoding." - (decode-coding-string string 'mel-ccl-base64-lf-rev)) + (if no-line-break + (decode-coding-string string 'mel-ccl-b-rev) + (decode-coding-string string 'mel-ccl-base64-lf-rev))) + (defalias-maybe 'base64-encode-string 'base64-ccl-encode-string) - (defun base64-ccl-encode-region (start end) + (defun base64-ccl-encode-region (start end &optional no-line-break) "Encode region from START to END with base64 encoding." - (interactive "r") - (decode-coding-region start end 'mel-ccl-base64-lf-rev)) + (interactive "*r") + (if no-line-break + (decode-coding-region start end 'mel-ccl-b-rev) + (decode-coding-region start end 'mel-ccl-base64-lf-rev))) + (defalias-maybe 'base64-encode-region 'base64-ccl-encode-region) (defun base64-ccl-insert-encoded-file (filename) "Encode contents of file FILENAME to base64, and insert the result." - (interactive (list (read-file-name "Insert encoded file: "))) + (interactive "*fInsert encoded file: ") (insert-file-contents-as-coding-system 'mel-ccl-base64-lf-rev filename)) (mel-define-method-function (mime-encode-string string (nil "base64")) @@ -427,17 +436,17 @@ abcdefghijklmnopqrstuvwxyz\ (defun base64-ccl-decode-string (string) "Decode base64 encoded STRING" (encode-coding-string string 'mel-ccl-b-rev)) +(defalias-maybe 'base64-decode-string 'base64-ccl-decode-string) (defun base64-ccl-decode-region (start end) "Decode base64 encoded the region from START to END." - (interactive "r") + (interactive "*r") (encode-coding-region start end 'mel-ccl-b-rev)) +(defalias-maybe 'base64-decode-region 'base64-ccl-decode-region) (defun base64-ccl-write-decoded-region (start end filename) "Decode the region from START to END and write out to FILENAME." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (write-region-as-coding-system 'mel-ccl-b-rev start end filename)) (mel-define-method-function (mime-decode-string string (nil "base64")) @@ -449,8 +458,9 @@ abcdefghijklmnopqrstuvwxyz\ 'base64-ccl-write-decoded-region) (mel-define-method encoded-text-decode-string (string (nil "B")) - (if (and (string-match B-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" B-encoded-text-regexp "\\'")) + string) (base64-ccl-decode-string string) (error "Invalid encoded-text %s" string))) @@ -460,4 +470,4 @@ abcdefghijklmnopqrstuvwxyz\ (provide 'mel-b-ccl) -;;; mel-b-ccl.el ends here +;;; mel-b-ccl.el ends here. diff --git a/mel-b-dl.el b/mel-b-dl.el index 411fa74..47b1b81 100644 --- a/mel-b-dl.el +++ b/mel-b-dl.el @@ -1,11 +1,11 @@ -;;; mel-b-dl.el: Base64 encoder/decoder using DL module +;;; mel-b-dl.el --- Base64 encoder/decoder using DL module. -;; Copyright (C) 1998 Free Software Foundation, Inc. +;; Copyright (C) 1998,1999 Free Software Foundation, Inc. -;; Author: MORIOKA Tomohiko +;; Author: MORIOKA Tomohiko ;; Keywords: MIME, Base64 -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -18,66 +18,66 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'poe) (require 'mime-def) (eval-and-compile (defvar base64-dl-handle - (and (file-exists-p base64-dl-module) + (and (stringp base64-dl-module) + (file-exists-p base64-dl-module) (dynamic-link base64-dl-module))) (dynamic-call "emacs_base64_init" base64-dl-handle) ) +;; base64-dl-module provides `encode-base64-string' and `decode-base64-string'. +(defalias 'base64-encode-string 'encode-base64-string) +(defalias 'base64-decode-string 'decode-base64-string) + (defun base64-encode-region (start end) "Encode current region by base64. START and END are buffer positions." - (interactive "r") - (let ((str (buffer-substring start end))) - (delete-region start end) - (insert (encode-base64-string str)) - ) - (or (bolp) - (insert "\n")) - ) - -(defun decode-base64-region (start end) + (interactive "*r") + (insert + (prog1 + (base64-encode-string + (buffer-substring start end)) + (delete-region start end))) + (or (bolp) (insert ?\n))) + +(defun base64-decode-region (start end) "Decode current region by base64. START and END are buffer positions." - (interactive "r") - (let ((str (buffer-substring start end))) - (delete-region start end) - (condition-case err - (insert (decode-base64-string str)) - (error (message (nth 1 err))) - ))) - -(defalias 'base64-encode-string 'encode-base64-string) -(defalias 'base64-decode-string 'decode-base64-string) + (interactive "*r") + (insert + (prog1 + (base64-decode-string + (buffer-substring start end)) + (delete-region start end)))) (mel-define-method-function (mime-encode-string string (nil "base64")) - 'encode-base64-string) + 'base64-encode-string) (mel-define-method-function (mime-decode-string string (nil "base64")) - 'decode-base64-string) + 'base64-decode-string) (mel-define-method-function (mime-encode-region start end (nil "base64")) 'base64-encode-region) (mel-define-method-function (mime-decode-region start end (nil "base64")) - 'decode-base64-region) + 'base64-decode-region) (mel-define-method-function (encoded-text-encode-string string (nil "B")) - 'encode-base64-string) + 'base64-encode-string) (mel-define-method encoded-text-decode-string (string (nil "B")) - (if (and (string-match B-encoded-text-regexp string) - (string= string (match-string 0 string))) - (decode-base64-string string) + (if (string-match (eval-when-compile + (concat "\\`" B-encoded-text-regexp "\\'")) + string) + (base64-decode-string string) (error "Invalid encoded-text %s" string))) @@ -89,28 +89,23 @@ START and END are buffer positions." It calls external base64 encoder specified by `base64-external-encoder'. So you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive (list (read-file-name "Insert encoded file: "))) - (insert (encode-base64-string + (interactive "*fInsert encoded file: ") + (insert (base64-encode-string (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-as-binary filename) (buffer-string)))) - (or (bolp) - (insert "\n")) - ) + (or (bolp) (insert ?\n))) ;; (mel-define-method mime-write-decoded-region (start end filename ;; (nil "base64")) ;; "Decode and write current region encoded by base64 into FILENAME. ;; START and END are buffer positions." -;; (interactive -;; (list (region-beginning) (region-end) -;; (read-file-name "Write decoded region to file: "))) +;; (interactive "*r\nFWrite decoded region to file: ") ;; (let ((str (buffer-substring start end))) ;; (with-temp-buffer -;; (insert (decode-base64-string str)) -;; (write-region-as-binary (point-min) (point-max) filename) -;; ))) +;; (insert (base64-decode-string str)) +;; (write-region-as-binary (point-min)(point-max) filename)))) ;;; @ end diff --git a/mel-b-el.el b/mel-b-el.el index 7426cc5..f661853 100644 --- a/mel-b-el.el +++ b/mel-b-el.el @@ -1,13 +1,13 @@ -;;; mel-b-el.el: Base64 encoder/decoder for GNU Emacs +;;; mel-b-el.el --- Base64 encoder/decoder. -;; Copyright (C) 1992,1995,1996,1997,1998 Free Software Foundation, Inc. +;; Copyright (C) 1992,1995,1996,1997,1998,1999 Free Software Foundation, Inc. ;; Author: ENAMI Tsugutomo -;; MORIOKA Tomohiko +;; MORIOKA Tomohiko ;; Created: 1995/6/24 ;; Keywords: MIME, Base64 -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -20,13 +20,12 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'poe) (require 'mime-def) @@ -72,6 +71,26 @@ external decoder is called." (integer :tag "Size"))) +;;; @ utility function +;;; + +(defun pack-sequence (seq size) + "Split sequence SEQ into SIZE elements packs, and return list of packs. +\[mel-b-el; tl-seq function]" + (let ((len (length seq)) + (p 0) + dest unit) + (while (< p len) + (setq unit (cons (elt seq p) unit)) + (setq p (1+ p)) + (when (zerop (mod p size)) + (setq dest (cons (nreverse unit) dest)) + (setq unit nil))) + (if unit + (nreverse (cons (nreverse unit) dest)) + (nreverse dest)))) + + ;;; @ internal base64 encoder ;;; based on base64 decoder by Enami Tsugutomo @@ -84,33 +103,31 @@ external decoder is called." `(aref base64-characters ,n)) (defun base64-encode-1 (pack) - (let ((a (car pack)) - (b (nth 1 pack)) - (c (nth 2 pack))) - (concat - (char-to-string (base64-num-to-char (ash a -2))) - (if b - (concat - (char-to-string - (base64-num-to-char (logior (ash (logand a 3) 4) (ash b -4)))) - (if c - (concat - (char-to-string - (base64-num-to-char (logior (ash (logand b 15) 2) (ash c -6)))) - (char-to-string (base64-num-to-char (logand c 63))) - ) - (concat (char-to-string - (base64-num-to-char (ash (logand b 15) 2))) "=") - )) - (concat (char-to-string - (base64-num-to-char (ash (logand a 3) 4))) "==") - )))) + (let ((buf (make-string 4 ?=))) + (aset buf 0 (base64-num-to-char (ash (car pack) -2))) + (if (nth 1 pack) + (progn + (aset buf 1 (base64-num-to-char + (logior (ash (logand (car pack) 3) 4) + (ash (nth 1 pack) -4)))) + (if (nth 2 pack) + (progn + (aset buf 2 (base64-num-to-char + (logior (ash (logand (nth 1 pack) 15) 2) + (ash (nth 2 pack) -6)))) + (aset buf 3 (base64-num-to-char + (logand (nth 2 pack) 63)))) + (aset buf 2 (base64-num-to-char + (ash (logand (nth 1 pack) 15) 2))))) + (aset buf 1 (base64-num-to-char + (ash (logand (car pack) 3) 4)))) + buf)) (defun-maybe base64-encode-string (string) "Encode STRING to base64, and return the result." - (let ((len (length string)) - (b 0)(e 57) - dest) + (let* ((len (length string)) + (b 0)(e 57) + (dest "")) (while (< e len) (setq dest (concat dest @@ -120,32 +137,23 @@ external decoder is called." "") "\n")) (setq b e - e (+ e 57) - ) - ) - (let* ((es (mapconcat - (function base64-encode-1) - (pack-sequence (substring string b) 3) - "")) - (m (mod (length es) 4)) - ) - (concat dest es (cond ((= m 3) "=") - ((= m 2) "==") - )) - ))) + e (+ e 57))) + (concat dest + (mapconcat + (function base64-encode-1) + (pack-sequence (substring string b) 3) + "")))) (defun base64-internal-encode-region (beg end) (save-excursion (save-restriction (narrow-to-region beg end) - (let ((str (buffer-substring beg end))) - (delete-region beg end) - (insert (base64-encode-string str)) - ) - (or (bolp) - (insert "\n") - ) - ))) + (insert + (prog1 + (base64-encode-string + (buffer-substring beg end)) + (delete-region beg end))) + (or (bolp) (insert ?\n))))) ;;; @ internal base64 decoder @@ -166,8 +174,7 @@ external decoder is called." (defsubst base64-internal-decode (string buffer) (let* ((len (length string)) - (i 0) - (j 0) + (i 0)(j 0) v1 v2 v3) (catch 'tag (while (< i len) @@ -187,12 +194,9 @@ external decoder is called." (if v4 (aset buffer (prog1 j (setq j (1+ j))) (logior (lsh (logand v3 3) 6) v4)) - (throw 'tag nil) - )) - (throw 'tag nil) - )))) - (substring buffer 0 j) - )) + (throw 'tag nil))) + (throw 'tag nil))))) + (substring buffer 0 j))) (defun base64-internal-decode-string (string) (base64-internal-decode string (make-string (length string) 0))) @@ -204,9 +208,10 @@ external decoder is called." (defun base64-internal-decode-region (beg end) (save-excursion (let ((str (string-as-unibyte (buffer-substring beg end)))) - (delete-region beg end) - (goto-char beg) - (insert (base64-internal-decode str str))))) + (insert + (prog1 + (base64-internal-decode str str) + (delete-region beg end)))))) ;; (defun base64-internal-decode-region2 (beg end) ;; (save-excursion @@ -233,30 +238,30 @@ external decoder is called." (as-binary-process (apply (function call-process-region) beg end (car base64-external-encoder) - t t nil (cdr base64-external-encoder))) + t t nil + (cdr base64-external-encoder))) ;; for OS/2 ;; regularize line break code (goto-char (point-min)) (while (re-search-forward "\r$" nil t) - (replace-match "")) - ))) + (replace-match ""))))) (defun base64-external-decode-region (beg end) (save-excursion (as-binary-process (apply (function call-process-region) beg end (car base64-external-decoder) - t t nil (cdr base64-external-decoder))) - )) + t t nil + (cdr base64-external-decoder))))) (defun base64-external-decode-string (string) (with-temp-buffer (insert string) (as-binary-process (apply (function call-process-region) - (point-min) (point-max) - (car base64-external-decoder) - t t nil (cdr base64-external-decoder))) + (point-min)(point-max) (car base64-external-decoder) + t t nil + (cdr base64-external-decoder))) (buffer-string))) @@ -271,7 +276,7 @@ smaller than `base64-internal-encoding-limit', otherwise it calls external base64 encoder specified by `base64-external-encoder'. In this case, you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive "r") + (interactive "*r") (if (and base64-internal-encoding-limit (> (- end start) base64-internal-encoding-limit)) (base64-external-encode-region start end) @@ -285,7 +290,7 @@ smaller than `base64-internal-decoding-limit', otherwise it calls external base64 decoder specified by `base64-external-decoder'. In this case, you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive "r") + (interactive "*r") (if (and base64-internal-decoding-limit (> (- end start) base64-internal-decoding-limit)) (base64-external-decode-region start end) @@ -298,7 +303,6 @@ smaller than `base64-internal-decoding-limit', otherwise it calls external base64 decoder specified by `base64-external-decoder'. In this case, you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive "r") (if (and base64-internal-decoding-limit (> (length string) base64-internal-decoding-limit)) (base64-external-decode-string string) @@ -318,8 +322,9 @@ metamail or XEmacs package)." 'base64-encode-string) (mel-define-method encoded-text-decode-string (string (nil "B")) - (if (and (string-match B-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" B-encoded-text-regexp "\\'")) + string) (base64-decode-string string) (error "Invalid encoded-text %s" string))) @@ -328,21 +333,21 @@ metamail or XEmacs package)." It calls external base64 encoder specified by `base64-external-encoder'. So you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive (list (read-file-name "Insert encoded file: "))) + (interactive "*fInsert encoded file: ") (if (and base64-internal-encoding-limit (> (nth 7 (file-attributes filename)) base64-internal-encoding-limit)) - (apply (function call-process) (car base64-external-encoder) - filename t nil (cdr base64-external-encoder)) + (apply (function call-process) + (car base64-external-encoder) + filename t nil + (cdr base64-external-encoder)) (insert (base64-encode-string (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-as-binary filename) (buffer-string)))) - (or (bolp) - (insert "\n")) - )) + (or (bolp) (insert ?\n)))) (mel-define-method-function (mime-insert-encoded-file filename (nil "base64")) 'base64-insert-encoded-file) @@ -350,9 +355,7 @@ mmencode included in metamail or XEmacs package)." (defun base64-write-decoded-region (start end filename) "Decode and write current region encoded by base64 into FILENAME. START and END are buffer positions." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (if (and base64-internal-decoding-limit (> (- end start) base64-internal-decoding-limit)) (as-binary-process @@ -365,42 +368,13 @@ START and END are buffer positions." (let ((str (buffer-substring start end))) (with-temp-buffer (insert (base64-internal-decode-string str)) - (write-region-as-binary (point-min) (point-max) filename) - )))) + (write-region-as-binary (point-min) (point-max) filename))))) (mel-define-method-function (mime-write-decoded-region start end filename (nil "base64")) 'base64-write-decoded-region) -;;; @ etc -;;; - -(defun pack-sequence (seq size) - "Split sequence SEQ into SIZE elements packs, -and return list of packs. [mel-b-el; tl-seq function]" - (let ((len (length seq)) (p 0) obj - unit (i 0) - dest) - (while (< p len) - (setq obj (elt seq p)) - (setq unit (cons obj unit)) - (setq i (1+ i)) - (if (= i size) - (progn - (setq dest (cons (reverse unit) dest)) - (setq unit nil) - (setq i 0) - )) - (setq p (1+ p)) - ) - (if unit - (setq dest (cons (reverse unit) dest)) - ) - (reverse dest) - )) - - ;;; @ end ;;; diff --git a/mel-g.el b/mel-g.el index 8be016c..16a37fd 100644 --- a/mel-g.el +++ b/mel-g.el @@ -1,15 +1,15 @@ -;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs +;;; mel-g.el --- Gzip64 encoder/decoder. ;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko -;; Copyright (C) 1996,1997 Shuhei KOBAYASHI +;; Copyright (C) 1996,1997,1999 Shuhei KOBAYASHI -;; Author: Shuhei KOBAYASHI -;; modified by MORIOKA Tomohiko -;; Maintainer: Shuhei KOBAYASHI +;; Author: Shuhei KOBAYASHI +;; MORIOKA Tomohiko +;; Maintainer: Shuhei KOBAYASHI ;; Created: 1995/10/25 ;; Keywords: Gzip64, base64, gzip, MIME -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -22,7 +22,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -33,9 +33,8 @@ ;;; Code: -(require 'poem) +(require 'mime-def) (require 'path-util) -(require 'mel) ;;; @ variables @@ -44,15 +43,13 @@ (defvar gzip64-external-encoder (let ((file (exec-installed-p "mmencode"))) (and file - (` ("sh" "-c" (, (concat "gzip -c | " file)))) - )) + (` ("sh" "-c" (, (concat "gzip -c | " file)))))) "*list of gzip64 encoder program name and its arguments.") (defvar gzip64-external-decoder (let ((file (exec-installed-p "mmencode"))) (and file - (` ("sh" "-c" (, (concat file " -u | gzip -dc")))) - )) + (` ("sh" "-c" (, (concat file " -u | gzip -dc")))))) "*list of gzip64 decoder program name and its arguments.") @@ -62,26 +59,25 @@ (defun gzip64-external-encode-region (beg end) (interactive "*r") (save-excursion - (as-binary-process (apply (function call-process-region) - beg end (car gzip64-external-encoder) - t t nil (cdr gzip64-external-encoder)) - ) + (as-binary-process + (apply (function call-process-region) + beg end (car gzip64-external-encoder) + t t nil + (cdr gzip64-external-encoder))) ;; for OS/2 ;; regularize line break code (goto-char (point-min)) (while (re-search-forward "\r$" nil t) - (replace-match "") - ) - )) + (replace-match "")))) (defun gzip64-external-decode-region (beg end) (interactive "*r") (save-excursion - (as-binary-process (apply (function call-process-region) - beg end (car gzip64-external-decoder) - t t nil (cdr gzip64-external-decoder)) - ) - )) + (as-binary-process + (apply (function call-process-region) + beg end (car gzip64-external-decoder) + t t nil + (cdr gzip64-external-decoder))))) (mel-define-method-function (mime-encode-region start end (nil "x-gzip64")) 'gzip64-external-encode-region) @@ -109,27 +105,24 @@ ;;; (mel-define-method mime-insert-encoded-file (filename (nil "x-gzip64")) - (interactive (list (read-file-name "Insert encoded file: "))) - (apply (function call-process) (car gzip64-external-encoder) + (interactive "*fInsert encoded file: ") + (apply (function call-process) + (car gzip64-external-encoder) filename t nil - (cdr gzip64-external-encoder)) - ) + (cdr gzip64-external-encoder))) (mel-define-method mime-write-decoded-region (start end filename (nil "x-gzip64")) "Decode and write current region encoded by gzip64 into FILENAME. START and END are buffer positions." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (as-binary-process (apply (function call-process-region) start end (car gzip64-external-decoder) nil nil nil (let ((args (cdr gzip64-external-decoder))) (append (butlast args) - (list (concat (car (last args)) ">" filename)))) - ))) + (list (concat (car (last args)) ">" filename))))))) ;;; @ end diff --git a/mel-q-ccl.el b/mel-q-ccl.el index dc84735..c71fab6 100644 --- a/mel-q-ccl.el +++ b/mel-q-ccl.el @@ -1,7 +1,6 @@ -;;; mel-ccl.el: CCL based encoder/decoder of Quoted-Printable -;;; and Q-encoding +;;; mel-q-ccl.el --- Quoted-Printable encoder/decoder using CCL. -;; Copyright (C) 1998 Tanaka Akira +;; Copyright (C) 1998,1999 Tanaka Akira ;; Author: Tanaka Akira ;; Created: 1998/9/17 @@ -20,7 +19,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -237,16 +236,36 @@ abcdefghijklmnopqrstuvwxyz\ (eval-when-compile -(defun mel-ccl-try-to-read-crlf (input-crlf reg eof-reg cr-eof lf-eof crlf-eof succ fail-cr fail-lf fail-crlf) +(defvar eof-block-branches) +(defvar eof-block-reg) +(defun mel-ccl-set-eof-block (branch) + (let ((p (assoc branch eof-block-branches))) + (unless p + (setq p (cons branch (length eof-block-branches)) + eof-block-branches (cons p eof-block-branches))) + `(,eof-block-reg = ,(cdr p)))) + +) + +(eval-when-compile + +(defun mel-ccl-try-to-read-crlf (input-crlf reg + succ + cr-eof cr-fail + lf-eof lf-fail + crlf-eof crlf-fail) (if input-crlf - `((,eof-reg = ,cr-eof) (read-if (,reg == ?\r) - ((,eof-reg = ,lf-eof) (read-if (,reg == ?\n) - ,succ - ,fail-lf)) - ,fail-cr)) - `((,eof-reg = ,crlf-eof) (read-if (,reg == ?\n) - ,succ - ,fail-crlf)))) + `(,(mel-ccl-set-eof-block cr-eof) + (read-if (,reg == ?\r) + (,(mel-ccl-set-eof-block lf-eof) + (read-if (,reg == ?\n) + ,succ + ,lf-fail)) + ,cr-fail)) + `(,(mel-ccl-set-eof-block crlf-eof) + (read-if (,reg == ?\n) + ,succ + ,crlf-fail)))) ) @@ -255,360 +274,317 @@ abcdefghijklmnopqrstuvwxyz\ ;; Generated CCL program works not properly on 20.2 because CCL_EOF_BLOCK ;; is not executed. (defun mel-ccl-encode-quoted-printable-generic (input-crlf output-crlf) - `(4 - ((r6 = 0) ; column - (r5 = 0) ; previous character is white space - (r4 = 0) - (read r0) - (loop ; r6 <= 75 - (loop - (loop - (branch - r0 - ,@(mapcar - (lambda (r0) - (let ((tmp (aref mel-ccl-qp-table r0))) - (cond - ((eq r0 (char-int ?F)) - `(if (r6 == 0) - ((r4 = 15) (read-if (r0 == ?r) - ((r4 = 16) (read-if (r0 == ?o) - ((r4 = 17) (read-if (r0 == ?m) - ((r4 = 18) (read-if (r0 == ? ) - ((r6 = 7) - (r5 = 1) - (write "=46rom ") - (r4 = 19) - (read r0) - (repeat)) - ((r6 = 4) - (write-repeat "From")))) - ((r6 = 3) - (write-repeat "Fro")))) - ((r6 = 2) - (write-repeat "Fr")))) - ((r6 = 1) - (write-repeat "F")))) - ((r3 = 0) (break)) ; RAW - )) - ((eq r0 (char-int ?.)) - `(if (r6 == 0) - ,(mel-ccl-try-to-read-crlf - input-crlf - 'r0 'r4 20 21 22 - `((write ,(if output-crlf "=2E\r\n" "=2E\n")) - (r4 = 23) - (read r0) - (repeat)) - '((r6 = 1) - (write-repeat ".")) - '((r6 = 4) - (write-repeat ".=0D")) - '((r6 = 1) - (write-repeat "."))) - ((r3 = 0) (break)) ; RAW - )) - ((eq tmp 'raw) '((r3 = 0) (break))) ; RAW - ((eq tmp 'enc) '((r3 = 1) (break))) ; ENC - ((eq tmp 'wsp) '((r3 = 2) (break))) ; WSP - ((eq tmp 'cr) (if input-crlf - '((r3 = 3) (break)) ; CR - '((r3 = 1) (break)))) ; ENC - ((eq tmp 'lf) (if input-crlf - '((r3 = 1) (break)) ; ENC - '((r3 = 3) (break)))) ; CRLF - ))) - mel-ccl-256-table))) - (branch - r3 - ;; r0:r3=RAW - (if (r6 < 75) - ((r6 += 1) - (r5 = 0) - (r4 = 1) - (write-read-repeat r0)) - (break)) - ;; r0:r3=ENC - ((r5 = 0) - (if (r6 < 73) - ((r6 += 3) - (write "=") - (write r0 ,mel-ccl-high-table) - (r4 = 2) - (write-read-repeat r0 ,mel-ccl-low-table)) - (if (r6 > 73) - ((r6 = 3) - (write ,(if output-crlf "=\r\n=" "=\n=")) - (write r0 ,mel-ccl-high-table) - (r4 = 3) - (write-read-repeat r0 ,mel-ccl-low-table)) - (break)))) - ;; r0:r3=WSP - ((r5 = 1) - (if (r6 < 75) - ((r6 += 1) - (r4 = 4) - (write-read-repeat r0)) - ((r6 = 1) - (write ,(if output-crlf "=\r\n" "=\n")) - (r4 = 5) - (write-read-repeat r0)))) - ;; r0:r3=CR/CRLF - ,(if input-crlf - ;; r0:r3=CR - `((if ((r6 > 73) & r5) - ((r6 = 0) - (r5 = 0) - (write ,(if output-crlf "=\r\n" "=\n")))) - (break)) - ;; r0:r3=CRLF - `(if r5 - ;; WSP ; r0:r3=CRLF - ((r5 = 0) - (r6 = 0) - (write ,(if output-crlf "=\r\n" "=\n")) - ,@(if output-crlf '((write ?\r)) '()) - (r4 = 0) - (write-read-repeat r0)) - ;; noWSP ; r0:r3=CRLF - ((r5 = 0) - (r6 = 0) - ,@(if output-crlf '((write ?\r)) '()) - (r4 = 0) - (write-read-repeat r0))) - ))) - ;; r0:r3={RAW,ENC,CR} - (loop - ,(funcall - (lambda (after-cr after-raw-enc) - (if input-crlf - `(if (r0 == ?\r) - ,after-cr - ,after-raw-enc) - after-raw-enc)) - ;; r0=\r:r3=CR - `((r4 = 6) - (read r0) - ;; CR:r3=CR r0 - (if (r0 == ?\n) - ;; CR:r3=CR r0=LF - (if r5 - ;; r5=WSP ; CR:r3=CR r0=LF - ((r6 = 0) - (r5 = 0) - (write ,(if output-crlf "=\r\n\r\n" "=\n\n")) - (r4 = 7) - (read r0) - (break)) - ;; r5=noWSP ; CR:r3=CR r0=LF - ((r6 = 0) - (r5 = 0) - (write ,(if output-crlf "\r\n" "\n")) - (r4 = 8) - (read r0) - (break))) - ;; CR:r3=CR r0=noLF - (if (r6 < 73) - ((r6 += 3) - (r5 = 0) - (write "=0D") - (break)) - (if (r6 == 73) - (if (r0 == ?\r) - ;; CR:r3=CR r0=CR - ((r4 = 9) - (read r0) - ;; CR:r3=CR CR r0 - (if (r0 == ?\n) - ;; CR:r3=CR CR LF - ((r6 = 0) - (r5 = 0) - (write ,(if output-crlf "=0D\r\n" "=0D\n")) - (r4 = 10) - (read r0) - (break)) - ;; CR:r3=CR CR noLF - ((r6 = 6) - (r5 = 0) - (write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D")) - (break)))) - ;; CR:r3=CR r0=noLFnorCR - ((r6 = 3) - (r5 = 0) - (write ,(if output-crlf "=\r\n=0D" "=\n=0D")) - (break))) - ((r6 = 3) - (r5 = 0) - (write ,(if output-crlf "=\r\n=0D" "=\n=0D")) - (break)))))) - (funcall - (lambda (after-newline after-cr-nolf after-nonewline) - (if input-crlf - ;; r0:r3={RAW,ENC} - `((r4 = 11) - (read r1) - ;; r0:r3={RAW,ENC} r1 - (if (r1 == ?\r) - ;; r0:r3={RAW,ENC} r1=CR - ((r4 = 12) - (read r1) - ;; r0:r3={RAW,ENC} CR r1 - (if (r1 == ?\n) - ;; r0:r3=RAW CR r1=LF - ,after-newline - ;; r0:r3=RAW CR r1=noLF - ,after-cr-nolf)) - ;; r0:r3={RAW,ENC} r1:noCR - ,after-nonewline)) - ;; r0:r3={RAW,ENC} - `((r4 = 11) - (read r1) - ;; r0:r3={RAW,ENC} r1 - (if (r1 == ?\n) - ;; r0:r3={RAW,ENC} r1=CRLF - ,after-newline - ;; r0:r3={RAW,ENC} r1:noCRLF - ,after-nonewline)))) - ;; r0:r3={RAW,ENC} CR r1=LF - ;; r0:r3={RAW,ENC} r1=CRLF - `((r6 = 0) - (r5 = 0) - (branch - r3 - ;; r0:r3=RAW CR r1=LF - ;; r0:r3=RAW r1=CRLF - ((write r0) - (write ,(if output-crlf "\r\n" "\n")) - (r4 = 13) - (read r0) - (break)) - ;; r0:r3=ENC CR r1=LF - ;; r0:r3=ENC r1=CRLF - ((write ?=) - (write r0 ,mel-ccl-high-table) - (write r0 ,mel-ccl-low-table) - (write ,(if output-crlf "\r\n" "\n")) - (r4 = 14) - (read r0) - (break)))) - ;; r0:r3={RAW,ENC} CR r1=noLF - `((branch - r3 - ;; r0:r3=RAW CR r1:noLF - ((r6 = 4) - (r5 = 0) - (write ,(if output-crlf "=\r\n" "=\n")) - (write r0) - (write "=0D") - (r0 = (r1 + 0)) ; "+ 0" is workaround for mule 2.3@19.34. - (break)) - ;; r0:r3=ENC CR r1:noLF - ((r6 = 6) - (r5 = 0) - (write ,(if output-crlf "=\r\n=" "=\n=")) - (write r0 ,mel-ccl-high-table) - (write r0 ,mel-ccl-low-table) - (write "=0D") - (r0 = (r1 + 0)) - (break)))) - ;; r0:r3={RAW,ENC} r1:noCR - ;; r0:r3={RAW,ENC} r1:noCRLF - `((branch - r3 - ;; r0:r3=RAW r1:noCR - ;; r0:r3=RAW r1:noCRLF - ((r6 = 1) - (r5 = 0) - (write ,(if output-crlf "=\r\n" "=\n")) - (write r0) - (r0 = (r1 + 0)) - (break)) - ;; r0:r3=ENC r1:noCR - ;; r0:r3=ENC r1:noCRLF - ((r6 = 3) - (r5 = 0) - (write ,(if output-crlf "=\r\n=" "=\n=")) - (write r0 ,mel-ccl-high-table) - (write r0 ,mel-ccl-low-table) - (r0 = (r1 + 0)) - (break))))))) - (repeat))) - ;; EOF - ( ;(write "[EOF:") (write r4 ,mel-ccl-high-table) (write r4 ,mel-ccl-low-table) (write "]") - (branch - r4 - ;; 0: (start) ; - (end) - ;; 1: RAW ; - (end) - ;; 2: r0:r3=ENC ; - (end) - ;; 3: SOFTBREAK r0:r3=ENC ; - (end) - ;; 4: r0:r3=WSP ; - ((write ,(if output-crlf "=\r\n" "=\n")) (end)) - ;; 5: SOFTBREAK r0:r3=WSP ; - ((write ,(if output-crlf "=\r\n" "=\n")) (end)) - ;; 6: ; r0=\r:r3=CR - (if (r6 <= 73) - ((write "=0D") (end)) - ((write ,(if output-crlf "=\r\n=0D" "=\n=0D")) (end))) - ;; 7: r5=WSP SOFTBREAK CR:r3=CR r0=LF ; - (end) - ;; 8: r5=noWSP CR:r3=CR r0=LF ; - (end) - ;; 9: (r6=73) ; CR:r3=CR r0=CR - ((write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D")) (end)) - ;; 10: (r6=73) CR:r3=CR CR LF ; - (end) - ;; 11: ; r0:r3={RAW,ENC} - (branch - r3 - ((write r0) (end)) - ((write "=") - (write r0 ,mel-ccl-high-table) - (write r0 ,mel-ccl-low-table) - (end))) - ;; 12: ; r0:r3={RAW,ENC} r1=CR + (let ((hard (if output-crlf "\r\n" "\n")) + (soft (if output-crlf "=\r\n" "=\n")) + (eof-block-branches nil) + (eof-block-reg 'r4) + (after-wsp 'r5) + (column 'r6) + (type 'r3) + (current 'r0) + (type-raw 0) + (type-enc 1) + (type-wsp 2) + (type-brk 3) + ) + `(4 + ((,column = 0) + (,after-wsp = 0) + ,(mel-ccl-set-eof-block '(end)) + (read r0) + (loop ; invariant: column <= 75 + (loop + (loop + (branch + r0 + ,@(mapcar + (lambda (r0) + (let ((tmp (aref mel-ccl-qp-table r0))) + (cond + ((eq r0 (char-int ?F)) + `(if (,column == 0) + (,(mel-ccl-set-eof-block '((write "F") (end))) + (read-if (r0 == ?r) + (,(mel-ccl-set-eof-block '((write "Fr") (end))) + (read-if (r0 == ?o) + (,(mel-ccl-set-eof-block '((write "Fro") (end))) + (read-if (r0 == ?m) + (,(mel-ccl-set-eof-block '((write "From") (end))) + (read-if (r0 == ? ) + ((,column = 7) + (,after-wsp = 1) + ,(mel-ccl-set-eof-block '((write "From=20") (end))) + (read r0) + (write-repeat "=46rom ")) + ((,column = 4) + (write-repeat "From")))) + ((,column = 3) + (write-repeat "Fro")))) + ((,column = 2) + (write-repeat "Fr")))) + ((,column = 1) + (write-repeat "F")))) + ((,type = ,type-raw) (break)) ; RAW + )) + ((eq r0 (char-int ?.)) + `(if (,column == 0) + ,(mel-ccl-try-to-read-crlf + input-crlf 'r0 + ;; "." CR LF (input-crlf: t) + ;; "." LF (input-crlf: nil) + `((write ,(concat "=2E" hard)) + ,(mel-ccl-set-eof-block '(end)) + (read r0) + (repeat)) + ;; "." + '((write ".") (end)) + ;; "." noCR (input-crlf: t) + `((,column = 1) + (write-repeat ".")) + ;; "." CR (input-crlf: t) + '((write ".=0D") (end)) + ;; "." CR noLF (input-crlf: t) + `((,column = 4) + (write-repeat ".=0D")) + ;; "." (input-crlf: nil) + '((write ".") (end)) + ;; "." noLF (input-crlf: nil) + `((,column = 1) + (write-repeat "."))) + ((,type = ,type-raw) (break)) ; RAW + )) + ((eq tmp 'raw) `((,type = ,type-raw) (break))) + ((eq tmp 'enc) `((,type = ,type-enc) (break))) + ((eq tmp 'wsp) `((,type = ,type-wsp) (break))) + ((eq tmp 'cr) `((,type = ,(if input-crlf type-brk type-enc)) + (break))) + ((eq tmp 'lf) `((,type = ,(if input-crlf type-enc type-brk)) + (break))) + ))) + mel-ccl-256-table))) + ;; r0:type{raw,enc,wsp,brk} + (branch + ,type + ;; r0:type-raw + (if (,column < 75) + ((,column += 1) + (,after-wsp = 0) + ,(mel-ccl-set-eof-block '(end)) + (write-read-repeat r0)) + ((r1 = (r0 + 0)) + (,after-wsp = 0) + ,@(mel-ccl-try-to-read-crlf + input-crlf 'r0 + `((,column = 0) + (write r1) + ,(mel-ccl-set-eof-block `((write ,hard) (end))) + (read r0) + (write-repeat ,hard)) + '((write r1) (end)) + `((,column = 1) + (write ,soft) (write-repeat r1)) + `((write ,soft) (write r1) (write "=0D") (end)) + `((,column = 4) + (write ,soft) (write r1) (write-repeat "=0D")) + '((write r1) (end)) + `((,column = 1) + (write ,soft) (write-repeat r1))))) + ;; r0:type-enc + ((,after-wsp = 0) + (if (,column < 73) + ((,column += 3) + (write "=") + (write r0 ,mel-ccl-high-table) + ,(mel-ccl-set-eof-block '(end)) + (write-read-repeat r0 ,mel-ccl-low-table)) + (if (,column < 74) + ((r1 = (r0 + 0)) + (,after-wsp = 0) + ,@(mel-ccl-try-to-read-crlf + input-crlf 'r0 + `((,column = 0) + (write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (write ,hard) + ,(mel-ccl-set-eof-block '(end)) + (read r0) + (repeat)) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column = 3) + (write ,(concat soft "=")) + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (repeat)) + `((write ,(concat soft "=")) + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (write "=0D") + (end)) + `((,column = 6) + (write ,(concat soft "=")) + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (write-repeat "=0D")) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column = 3) + (write ,(concat soft "=")) + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (repeat)))) + ((,column = 3) + (write ,(concat soft "=")) + (write r0 ,mel-ccl-high-table) + ,(mel-ccl-set-eof-block '(end)) + (write-read-repeat r0 ,mel-ccl-low-table))))) + ;; r0:type-wsp + (if (,column < 73) + ((r1 = (r0 + 0)) + ,@(mel-ccl-try-to-read-crlf + input-crlf 'r0 + `((,column = 0) + (,after-wsp = 0) + (write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (write ,hard) + ,(mel-ccl-set-eof-block `(end)) + (read r0) + (repeat)) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column += 1) + (,after-wsp = 1) + (write-repeat r1)) + `((write r1) + (write "=0D") + (end)) + `((,column += 4) + (,after-wsp = 0) + (write r1) + (write-repeat "=0D")) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column += 1) + (,after-wsp = 1) + (write-repeat r1)))) + (if (,column < 74) + ((r1 = (r0 + 0)) + ,@(mel-ccl-try-to-read-crlf + input-crlf 'r0 + `((,column = 0) + (,after-wsp = 0) + (write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (write ,hard) + ,(mel-ccl-set-eof-block `(end)) + (read r0) + (repeat)) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column += 1) + (,after-wsp = 1) + (write-repeat r1)) + `((write r1) + (write ,(concat soft "=0D")) + (end)) + `((,column = 3) + (,after-wsp = 0) + (write r1) + (write-repeat ,(concat soft "=0D"))) + `((write "=") + (write r1 ,mel-ccl-high-table) + (write r1 ,mel-ccl-low-table) + (end)) + `((,column += 1) + (,after-wsp = 1) + (write-repeat r1)))) + (if (,column < 75) + ((,column += 1) + (,after-wsp = 1) + ,(mel-ccl-set-eof-block `((write ,soft) (end))) + (write-read-repeat r0)) + ((write ,soft) + (,column = 0) + (,after-wsp = 0) + (repeat))))) + ;; r0:type-brk + ,(if input-crlf + ;; r0{CR}:type-brk + `((if ((,column > 73) & ,after-wsp) + ((,column = 0) + (,after-wsp = 0) + (write ,soft))) + ,(mel-ccl-set-eof-block `((if (,column > 73) (write ,soft)) + (write "=0D") (end))) + (read-if (r0 == ?\n) + (if ,after-wsp + ((,after-wsp = 0) + (,column = 0) + (write ,(concat soft hard)) + ,(mel-ccl-set-eof-block '(end)) + (read r0) + (repeat)) + ((,after-wsp = 0) + (,column = 0) + (write ,hard) + ,(mel-ccl-set-eof-block '(end)) + (read r0) + (repeat))) + (if (,column < 73) + ((,after-wsp = 0) + (,column += 3) + (write-repeat "=0D")) + (if (,column < 74) + (if (r0 == ?\r) + ((,after-wsp = 0) + ,(mel-ccl-set-eof-block + `((write ,(concat soft "=0D=0D")) (end))) + (read-if (r0 == ?\n) + ((,column = 0) + ,(mel-ccl-set-eof-block + `((write ,(concat "=0D" hard)) (end))) + (read r0) + (write-repeat ,(concat "=0D" hard))) + ((,column = 6) + (write-repeat ,(concat soft "=0D=0D"))))) + ((,after-wsp = 0) + (,column = 3) + (write-repeat ,(concat soft "=0D")))) + ((,after-wsp = 0) + (,column = 3) + (write-repeat ,(concat soft "=0D"))))))) + ;; r0{LF}:type-brk + `(if ,after-wsp + ;; WSP ; r0{LF}:type-brk + ((,after-wsp = 0) + (,column = 0) + (write ,(concat soft (if output-crlf "\r" ""))) + ,(mel-ccl-set-eof-block `(end)) + (write-read-repeat r0)) + ;; noWSP ; r0{LF}:type-brk + ((,after-wsp = 0) + (,column = 0) + ,@(if output-crlf '((write ?\r)) '()) + ,(mel-ccl-set-eof-block `(end)) + (write-read-repeat r0))) + ))))) (branch - r3 - ;; ; r0:r3=RAW r1=CR - ((write ,(if output-crlf "=\r\n" "=\n")) - (write r0) - (write "=0D") - (end)) - ;; ; r0:r3=ENC r1=CR - ((write ,(if output-crlf "=\r\n=" "=\n=")) - (write r0 ,mel-ccl-high-table) - (write r0 ,mel-ccl-low-table) - (write "=0D") - (end))) - ;; 13: r0:r3=RAW CR LF ; - ;; 13: r0:r3=RAW CRLF ; - (end) - ;; 14: r0:r3=ENC CR LF ; - ;; 14: r0:r3=ENC CRLF ; - (end) - ;; 15: r6=0 ; "F" - ((write "F") (end)) - ;; 16: r6=0 ; "Fr" - ((write "Fr") (end)) - ;; 17: r6=0 ; "Fro" - ((write "Fro") (end)) - ;; 18: r6=0 ; "From" - ((write "From") (end)) - ;; 19: r6=0 "From " ; - (end) - ;; 20: r6=0 ; "." - ((write ".") (end)) - ;; 21: r6=0 ; ".\r" - ((write ".=0D") (end)) - ;; 22: r6=0 ; "." - ((write ".") (end)) - ;; 23: r6=0 ".\r\n" ; - (end) - )) - )) + ,eof-block-reg + ,@(reverse (mapcar 'car eof-block-branches)))))) (defun mel-ccl-decode-quoted-printable-generic (input-crlf output-crlf) `(1 @@ -916,12 +892,12 @@ abcdefghijklmnopqrstuvwxyz\ (defun quoted-printable-ccl-encode-region (start end) "Encode the region from START to END with quoted-printable encoding." - (interactive "r") + (interactive "*r") (decode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev)) (defun quoted-printable-ccl-insert-encoded-file (filename) "Encode contents of the file named as FILENAME, and insert it." - (interactive (list (read-file-name "Insert encoded file: "))) + (interactive "*fInsert encoded file: ") (insert-file-contents-as-coding-system 'mel-ccl-quoted-printable-lf-lf-rev filename)) @@ -945,15 +921,12 @@ abcdefghijklmnopqrstuvwxyz\ (defun quoted-printable-ccl-decode-region (start end) "Decode the region from START to END with quoted-printable encoding." - (interactive "r") + (interactive "*r") (encode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev)) -(defun quoted-printable-ccl-write-decoded-region - (start end filename) +(defun quoted-printable-ccl-write-decoded-region (start end filename) "Decode quoted-printable encoded current region and write out to FILENAME." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (write-region-as-coding-system 'mel-ccl-quoted-printable-lf-lf-rev start end filename)) @@ -991,7 +964,7 @@ MODE allows `text', `comment', `phrase' or nil. Default value is (unless (featurep 'xemacs) (defun q-encoding-ccl-encoded-length (string &optional mode) (let ((status [nil nil nil nil nil nil nil nil nil])) - (fillarray status nil) + (fillarray status nil) ; XXX: Is this necessary? (ccl-execute-on-string (cond ((eq mode 'text) 'mel-ccl-count-uq) @@ -1006,8 +979,9 @@ MODE allows `text', `comment', `phrase' or nil. Default value is 'q-encoding-ccl-encode-string) (mel-define-method encoded-text-decode-string (string (nil "Q")) - (if (and (string-match Q-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" Q-encoded-text-regexp "\\'")) + string) (q-encoding-ccl-decode-string string) (error "Invalid encoded-text %s" string))) @@ -1017,4 +991,4 @@ MODE allows `text', `comment', `phrase' or nil. Default value is (provide 'mel-q-ccl) -;;; mel-q-ccl.el ends here +;;; mel-q-ccl.el ends here. diff --git a/mel-q.el b/mel-q.el index 0e80c16..44b83c9 100644 --- a/mel-q.el +++ b/mel-q.el @@ -1,12 +1,12 @@ -;;; mel-q.el: Quoted-Printable and Q-encoding encoder/decoder for GNU Emacs +;;; mel-q.el --- Quoted-Printable encoder/decoder. -;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. +;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. -;; Author: MORIOKA Tomohiko +;; Author: MORIOKA Tomohiko ;; Created: 1995/6/25 ;; Keywords: MIME, Quoted-Printable, Q-encoding -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -19,14 +19,14 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'emu) (require 'mime-def) +(require 'path-util) ;;; @ Quoted-Printable encoder @@ -36,54 +36,56 @@ (concat "=" (char-to-string (aref quoted-printable-hex-chars (ash character -4))) - (char-to-string (aref quoted-printable-hex-chars (logand character 15))) - )) + (char-to-string (aref quoted-printable-hex-chars (logand character 15))))) (defun quoted-printable-internal-encode-region (start end) (save-excursion (save-restriction - (narrow-to-region start end) - (goto-char start) - (let ((col 0)) - (while (< (point)(point-max)) - (cond ((>= col 75) - (insert "=\n") - (setq col 0) - ) - ((looking-at-as-unibyte "^From ") - (replace-match "=46rom ") - (backward-char 1) - (setq col (+ col 6)) - ) - ((looking-at-as-unibyte "[ \t]\n") - (forward-char 1) - (insert "=\n") - (forward-char 1) - (setq col 0) - ) - (t - (let ((chr (char-after (point)))) - (cond ((= chr ?\n) - (forward-char 1) - (setq col 0) - ) - ((or (= chr ?\t) - (and (<= 32 chr)(/= chr ?=)(< chr 127)) - ) - (forward-char 1) - (setq col (1+ col)) - ) - ((>= col 73) - (insert "=\n") - (setq col 0) - ) - (t - (delete-char 1) - (insert (quoted-printable-quote-char chr)) - (setq col (+ col 3)) - )) - ))) - ))))) + (narrow-to-region (goto-char start) end) + (let ((col 0) + chr) + (while (not (eobp)) + (cond + ((>= col 75) ; soft line break. + (insert "=\n") + (setq col 0)) + ((eolp) ; end of line. + (forward-char) + (setq col 0)) + (t + (setq chr (char-after (point))) + (cond + ((and (memq chr '(? ?\t)) ; encode WSP char before CRLF. + (eq (char-after (1+ (point))) ?\n)) + (forward-char) + (insert "=\n") + (forward-char) + (setq col 0)) + ((and (bolp) ; "^From " is not safe. + (eq chr ?F) + (eq (char-after (1+ (point))) ?r) + (eq (char-after (+ 2 (point))) ?o) + (eq (char-after (+ 3 (point))) ?m) + (eq (char-after (+ 4 (point))) ? )) + (delete-region (point)(1+ (point))) + (insert "=46") ; moved to ?r. + (forward-char 4) ; skip "rom ". + (setq col 7)) + ((or (= chr ?\t) ; skip safe char. + (and (<= 32 chr)(/= chr ?=)(< chr 127))) + (forward-char) + (setq col (1+ col))) + ((>= col 73) ; soft line break. + (insert "=\n") + (setq col 0)) + (t ; encode unsafe char. + (delete-region (point)(1+ (point))) + ;; (insert (quoted-printable-quote-char chr)) + (insert + ?= + (aref quoted-printable-hex-chars (ash chr -4)) + (aref quoted-printable-hex-chars (logand chr 15))) + (setq col (+ col 3))))))))))) (defvar quoted-printable-external-encoder '("mmencode" "-q") @@ -96,15 +98,13 @@ (as-binary-process (apply (function call-process-region) start end (car quoted-printable-external-encoder) - t t nil (cdr quoted-printable-external-encoder)) - ) + t t nil + (cdr quoted-printable-external-encoder))) ;; for OS/2 ;; regularize line break code (goto-char (point-min)) (while (re-search-forward "\r$" nil t) - (replace-match "") - ) - ))) + (replace-match ""))))) (defvar quoted-printable-internal-encoding-limit @@ -113,7 +113,8 @@ (require 'path-util) (if (exec-installed-p "mmencode") 1000 - (message "Don't found external encoder for Quoted-Printable!") + ;; XXX: Fix this message, or simply remove it. + ;; (message "Don't found external encoder for Quoted-Printable!") nil)) "*limit size to use internal quoted-printable encoder. If size of input to encode is larger than this limit, @@ -127,21 +128,18 @@ region is smaller than `quoted-printable-internal-encoding-limit', otherwise it calls external quoted-printable encoder specified by `quoted-printable-external-encoder'. In this case, you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive "r") + (interactive "*r") (if (and quoted-printable-internal-encoding-limit (> (- end start) quoted-printable-internal-encoding-limit)) (quoted-printable-external-encode-region start end) - (quoted-printable-internal-encode-region start end) - )) - + (quoted-printable-internal-encode-region start end))) (defun quoted-printable-encode-string (string) "Encode STRING to quoted-printable, and return the result." (with-temp-buffer (insert string) (quoted-printable-encode-region (point-min)(point-max)) - (buffer-string) - )) + (buffer-string))) (mel-define-method-function @@ -152,16 +150,16 @@ the program (maybe mmencode included in metamail or XEmacs package)." (mime-encode-region start end (nil "quoted-printable")) 'quoted-printable-encode-region) -(mel-define-method mime-insert-encoded-file (filename - (nil "quoted-printable")) +(mel-define-method mime-insert-encoded-file (filename (nil "quoted-printable")) "Encode contents of file FILENAME to quoted-printable, and insert the result. It calls external quoted-printable encoder specified by `quoted-printable-external-encoder'. So you must install the program \(maybe mmencode included in metamail or XEmacs package)." - (interactive (list (read-file-name "Insert encoded file: "))) - (apply (function call-process) (car quoted-printable-external-encoder) - filename t nil (cdr quoted-printable-external-encoder)) - ) + (interactive "*fInsert encoded file: ") + (apply (function call-process) + (car quoted-printable-external-encoder) + filename t nil + (cdr quoted-printable-external-encoder))) ;;; @ Quoted-Printable decoder @@ -179,25 +177,28 @@ It calls external quoted-printable encoder specified by (narrow-to-region start end) (goto-char (point-min)) (while (search-forward "=" nil t) - (let ((beg (match-beginning 0))) - (cond ((looking-at "\n") - (delete-region beg (match-end 0)) - ) - ((looking-at - `,(concat "[" quoted-printable-hex-chars - "][" quoted-printable-hex-chars "]")) - (let* ((end (match-end 0)) - (hex (buffer-substring (match-beginning 0) end))) - (delete-region beg end) - (insert - (logior - (ash (quoted-printable-hex-char-to-num (aref hex 0)) 4) - (quoted-printable-hex-char-to-num (aref hex 1)))) - )) - (t - ;; invalid - )) - ))))) + (cond + ((eolp) + ;; unfold soft line break. + (delete-region (1- (point))(1+ (point)))) + ((and (memq (char-after (point)) + (eval-when-compile + ;; XXX: should provide char-list instead. + (string-to-char-list quoted-printable-hex-chars))) + (memq (char-after (1+ (point))) + (eval-when-compile + ;; XXX: should provide char-list instead. + (string-to-char-list quoted-printable-hex-chars)))) + ;; encoded char. + (insert + (prog1 + (logior + (ash (quoted-printable-hex-char-to-num (char-after (point))) 4) + (quoted-printable-hex-char-to-num (char-after (1+ (point))))) + (delete-region (1- (point))(+ 2 (point)))))) + (t + ;; invalid encoding. + )))))) (defvar quoted-printable-external-decoder '("mmencode" "-q" "-u") "*list of quoted-printable decoder program name and its arguments.") @@ -207,8 +208,8 @@ It calls external quoted-printable encoder specified by (as-binary-process (apply (function call-process-region) start end (car quoted-printable-external-decoder) - t t nil (cdr quoted-printable-external-decoder)) - ))) + t t nil + (cdr quoted-printable-external-decoder))))) (defvar quoted-printable-internal-decoding-limit nil @@ -224,12 +225,11 @@ region is smaller than `quoted-printable-internal-decoding-limit', otherwise it calls external quoted-printable decoder specified by `quoted-printable-external-decoder'. In this case, you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive "r") + (interactive "*r") (if (and quoted-printable-internal-decoding-limit (> (- end start) quoted-printable-internal-decoding-limit)) (quoted-printable-external-decode-region start end) - (quoted-printable-internal-decode-region start end) - )) + (quoted-printable-internal-decode-region start end))) (defun quoted-printable-decode-string (string) "Decode STRING which is encoded in quoted-printable, and return the result." @@ -255,17 +255,14 @@ the program (maybe mmencode included in metamail or XEmacs package)." (nil "quoted-printable")) "Decode and write current region encoded by quoted-printable into FILENAME. START and END are buffer positions." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (as-binary-process (apply (function call-process-region) start end (car quoted-printable-external-decoder) nil nil nil (append (cdr quoted-printable-external-decoder) quoted-printable-external-decoder-option-to-specify-file - (list filename)) - ))) + (list filename))))) ;;; @ Q-encoding encode/decode string @@ -283,22 +280,16 @@ START and END are buffer positions." MODE allows `text', `comment', `phrase' or nil. Default value is `phrase'." (let ((specials (cdr (or (assq mode q-encoding-special-chars-alist) - (assq 'phrase q-encoding-special-chars-alist) - )))) + (assq 'phrase q-encoding-special-chars-alist))))) (mapconcat (function (lambda (chr) (cond ((eq chr ? ) "_") ((or (< chr 32) (< 126 chr) - (memq chr specials) - ) - (quoted-printable-quote-char chr) - ) + (memq chr specials)) + (quoted-printable-quote-char chr)) (t - (char-to-string chr) - )) - )) - string "") - )) + (char-to-string chr))))) + string ""))) (defun q-encoding-decode-string (string) "Decode STRING which is encoded in Q-encoding and return the result." @@ -315,19 +306,17 @@ MODE allows `text', `comment', `phrase' or nil. Default value is (h (setq l (quoted-printable-hex-char-to-num chr)) (prog1 (char-to-string (logior (ash h 4) l)) - (setq h nil) - ) - ) - (t (char-to-string chr)) - ))) + (setq h nil))) + (t (char-to-string chr))))) string ""))) (mel-define-method-function (encoded-text-encode-string string (nil "Q")) 'q-encoding-encode-string) (mel-define-method encoded-text-decode-string (string (nil "Q")) - (if (and (string-match Q-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" Q-encoded-text-regexp "\\'")) + string) (q-encoding-decode-string string) (error "Invalid encoded-text %s" string))) @@ -337,4 +326,4 @@ MODE allows `text', `comment', `phrase' or nil. Default value is (provide 'mel-q) -;;; mel-q.el ends here +;;; mel-q.el ends here. diff --git a/mel-u.el b/mel-u.el index 3328e56..49d5733 100644 --- a/mel-u.el +++ b/mel-u.el @@ -1,8 +1,8 @@ -;;; mel-u.el: uuencode encoder/decoder for GNU Emacs +;;; mel-u.el --- uuencode encoder/decoder. -;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. +;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. -;; Author: MORIOKA Tomohiko +;; Author: MORIOKA Tomohiko ;; Created: 1995/10/25 ;; Keywords: uuencode @@ -19,14 +19,14 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'emu) (require 'mime-def) +(require 'path-util) (mel-define-backend "x-uue") @@ -51,17 +51,16 @@ This function uses external uuencode encoder which is specified by variable `uuencode-external-encoder'." (interactive "*r") (save-excursion - (as-binary-process (apply (function call-process-region) - start end (car uuencode-external-encoder) - t t nil (cdr uuencode-external-encoder)) - ) + (as-binary-process + (apply (function call-process-region) + start end (car uuencode-external-encoder) + t t nil + (cdr uuencode-external-encoder))) ;; for OS/2 ;; regularize line break code (goto-char (point-min)) (while (re-search-forward "\r$" nil t) - (replace-match "") - ) - )) + (replace-match "")))) (defun uuencode-external-decode-region (start end) "Decode current region by unofficial uuencode format. @@ -76,14 +75,14 @@ variable `uuencode-external-decoder'." (if (re-search-forward "^begin [0-9]+ " nil t) (if (looking-at ".+$") (buffer-substring (match-beginning 0) - (match-end 0)) - ))))) + (match-end 0))))))) (default-directory temporary-file-directory)) (if filename (as-binary-process (apply (function call-process-region) start end (car uuencode-external-decoder) - t nil nil (cdr uuencode-external-decoder)) + t nil nil + (cdr uuencode-external-decoder)) (as-binary-input-file (insert-file-contents filename)) ;; The previous line causes the buffer to be made read-only, I ;; do not pretend to understand the control flow leading to this @@ -91,10 +90,7 @@ variable `uuencode-external-decoder'." ;; Use `inhibit-read-only' to avoid to force ;; buffer-read-only nil. - tomo. (let ((inhibit-read-only t)) - (delete-file filename) - ) - )) - ))) + (delete-file filename))))))) (mel-define-method-function (mime-encode-region start end (nil "x-uue")) 'uuencode-external-encode-region) @@ -125,18 +121,16 @@ variable `uuencode-external-decoder'." "Insert file encoded by unofficial uuencode format. This function uses external uuencode encoder which is specified by variable `uuencode-external-encoder'." - (interactive (list (read-file-name "Insert encoded file: "))) - (call-process (car uuencode-external-encoder) filename t nil - (file-name-nondirectory filename)) - ) + (interactive "*fInsert encoded file: ") + (call-process (car uuencode-external-encoder) + filename t nil + (file-name-nondirectory filename))) (mel-define-method mime-write-decoded-region (start end filename (nil "x-uue")) "Decode and write current region encoded by uuencode into FILENAME. START and END are buffer positions." - (interactive - (list (region-beginning) (region-end) - (read-file-name "Write decoded region to file: "))) + (interactive "*r\nFWrite decoded region to file: ") (save-excursion (let ((file (save-excursion (save-restriction @@ -145,16 +139,15 @@ START and END are buffer positions." (if (re-search-forward "^begin [0-9]+ " nil t) (if (looking-at ".+$") (buffer-substring (match-beginning 0) - (match-end 0)) - ))))) + (match-end 0))))))) (default-directory temporary-file-directory)) (if file (as-binary-process (apply (function call-process-region) start end (car uuencode-external-decoder) - nil nil nil (cdr uuencode-external-decoder)) - (rename-file file filename 'overwrites) - ))))) + nil nil nil + (cdr uuencode-external-decoder)) + (rename-file file filename 'overwrites)))))) ;;; @ end @@ -164,4 +157,4 @@ START and END are buffer positions." (mel-define-backend "x-uuencode" ("x-uue")) -;;; mel-u.el ends here +;;; mel-u.el ends here. diff --git a/mel.el b/mel.el index 02782cf..12fff86 100644 --- a/mel.el +++ b/mel.el @@ -1,4 +1,4 @@ -;;; mel.el : a MIME encoding/decoding library +;;; mel.el --- A MIME encoding/decoding library. ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. @@ -19,7 +19,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -28,6 +28,7 @@ (require 'mime-def) (require 'poem) (require 'alist) +(require 'path-util) (defcustom mime-encoding-list '("7bit" "8bit" "binary" "base64" "quoted-printable") @@ -60,17 +61,15 @@ Content-Transfer-Encoding for it." (defun mime-encoding-alist (&optional service) "Return table of Content-Transfer-Encoding for completion." - (mapcar #'list (mime-encoding-list service)) - ) + (mapcar #'list (mime-encoding-list service))) (defsubst mel-use-module (name encodings) - (let (encoding) - (while (setq encoding (car encodings)) - (set-alist 'mel-encoding-module-alist - encoding - (cons name (cdr (assoc encoding mel-encoding-module-alist)))) - (setq encodings (cdr encodings)) - ))) + (while encodings + (set-alist 'mel-encoding-module-alist + (car encodings) + (cons name (cdr (assoc (car encodings) + mel-encoding-module-alist)))) + (setq encodings (cdr encodings)))) (defsubst mel-find-function (service encoding) (mel-find-function-from-obarray @@ -116,21 +115,20 @@ Content-Transfer-Encoding for it." It calls external base64 encoder specified by `base64-external-encoder'. So you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive (list (read-file-name "Insert encoded file: "))) + (interactive "*fInsert encoded file: ") (insert (base64-encode-string (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-as-binary filename) (buffer-string)))) - (or (bolp) - (insert "\n")) - ) + (or (bolp) (insert ?\n))) (mel-define-method-function (encoded-text-encode-string string (nil "B")) 'base64-encode-string) (mel-define-method encoded-text-decode-string (string (nil "B")) - (if (and (string-match B-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" B-encoded-text-regexp "\\'")) + string) (base64-decode-string string) (error "Invalid encoded-text %s" string))) ) @@ -144,27 +142,22 @@ mmencode included in metamail or XEmacs package)." (and (featurep 'mule) (progn (require 'path-util) - (module-installed-p 'mel-b-ccl) - ))) + (module-installed-p 'mel-b-ccl)))) (defvar mel-q-ccl-module (and (featurep 'mule) (progn (require 'path-util) - (module-installed-p 'mel-q-ccl) - ))) + (module-installed-p 'mel-q-ccl)))) -(if mel-b-ccl-module - (mel-use-module 'mel-b-ccl '("base64" "B")) - ) +(when mel-b-ccl-module + (mel-use-module 'mel-b-ccl '("base64" "B"))) -(if mel-q-ccl-module - (mel-use-module 'mel-q-ccl '("quoted-printable" "Q")) - ) +(when mel-q-ccl-module + (mel-use-module 'mel-q-ccl '("quoted-printable" "Q"))) -(if base64-dl-module - (mel-use-module 'mel-b-dl '("base64" "B")) - ) +(when base64-dl-module + (mel-use-module 'mel-b-dl '("base64" "B"))) ;;; @ region @@ -175,12 +168,11 @@ mmencode included in metamail or XEmacs package)." "Encode region START to END of current buffer using ENCODING. ENCODING must be string." (interactive - (list (region-beginning) (region-end) - (completing-read "encoding: " + (list (region-beginning)(region-end) + (completing-read "Encoding: " (mime-encoding-alist) nil t "base64"))) - (funcall (mel-find-function 'mime-encode-region encoding) start end) - ) + (funcall (mel-find-function 'mime-encode-region encoding) start end)) ;;;###autoload @@ -188,8 +180,8 @@ ENCODING must be string." "Decode region START to END of current buffer using ENCODING. ENCODING must be string." (interactive - (list (region-beginning) (region-end) - (completing-read "encoding: " + (list (region-beginning)(region-end) + (completing-read "Encoding: " (mime-encoding-alist 'mime-decode-region) nil t "base64"))) (funcall (mel-find-function 'mime-decode-region encoding) @@ -212,26 +204,22 @@ the STRING by its value." (mel-define-service encoded-text-encode-string (string encoding) - "Encode STRING as encoded-text using ENCODING. -ENCODING must be string.") + "Encode STRING as encoded-text using ENCODING. ENCODING must be string.") (mel-define-service encoded-text-decode-string (string encoding) - "Decode STRING as encoded-text using ENCODING. -ENCODING must be string.") + "Decode STRING as encoded-text using ENCODING. ENCODING must be string.") (defun base64-encoded-length (string) (* (/ (+ (length string) 2) 3) 4)) (defsubst Q-encoding-printable-char-p (chr mode) (and (not (memq chr '(?= ?? ?_))) - (<= ?\ chr)(<= chr ?~) + (<= ?\ chr)(<= chr ?~) (cond ((eq mode 'text) t) ((eq mode 'comment) - (not (memq chr '(?\( ?\) ?\\))) - ) + (not (memq chr '(?\( ?\) ?\\)))) (t - (string-match "[A-Za-z0-9!*+/=_---]" (char-to-string chr)) - )))) + (string-match "[A-Za-z0-9!*+/=_---]" (char-to-string chr)))))) (defun Q-encoded-text-length (string &optional mode) (let ((l 0)(i 0)(len (length string)) chr) @@ -240,9 +228,8 @@ ENCODING must be string.") (if (or (Q-encoding-printable-char-p chr mode) (eq chr ? )) (setq l (+ l 1)) - (setq l (+ l 3)) - ) - (setq i (+ i 1)) ) + (setq l (+ l 3))) + (setq i (+ i 1))) l)) @@ -254,7 +241,7 @@ ENCODING must be string.") "Insert file FILENAME encoded by ENCODING format." (interactive (list (read-file-name "Insert encoded file: ") - (completing-read "encoding: " + (completing-read "Encoding: " (mime-encoding-alist) nil t "base64"))) (funcall (mel-find-function 'mime-insert-encoded-file encoding) @@ -266,9 +253,9 @@ ENCODING must be string.") "Decode and write current region encoded by ENCODING into FILENAME. START and END are buffer positions." (interactive - (list (region-beginning) (region-end) + (list (region-beginning)(region-end) (read-file-name "Write decoded region to file: ") - (completing-read "encoding: " + (completing-read "Encoding: " (mime-encoding-alist 'mime-write-decoded-region) nil t "base64"))) (funcall (mel-find-function 'mime-write-decoded-region encoding) diff --git a/mime-def.el b/mime-def.el index e36dbc4..685318b 100644 --- a/mime-def.el +++ b/mime-def.el @@ -26,7 +26,13 @@ ;;; Code: +(require 'poe) +(require 'poem) +(require 'pcustom) (require 'mcharset) +(require 'alist) + +(eval-when-compile (require 'cl)) ; list* (eval-and-compile (defconst mime-library-product ["Chao" (1 13 0) "JR Fujinomori"] @@ -55,16 +61,11 @@ (require 'custom) -(eval-when-compile (require 'cl)) - -(defgroup mime nil +(defgroup mime '((default-mime-charset custom-variable)) "Emacs MIME Interfaces" :group 'news :group 'mail) -(custom-handle-keyword 'default-mime-charset :group 'mime - 'custom-variable) - (defcustom mime-uuencode-encoding-name-list '("x-uue" "x-uuencode") "*List of encoding names for uuencode format." :group 'mime @@ -289,6 +290,61 @@ message/rfc822, `mime-entity' structures of them are included in (make-variable-buffer-local 'mime-message-structure) + +;;; @ for mm-backend +;;; + +(defvar mime-entity-implementation-alist nil) + +(defmacro mm-define-backend (type &optional parents) + "Define TYPE as a mm-backend. +If PARENTS is specified, TYPE inherits PARENTS. +Each parent must be backend name (symbol)." + (if parents + `(let ((rest ',(reverse parents))) + (while rest + (set-alist 'mime-entity-implementation-alist + ',type + (copy-alist + (cdr (assq (car rest) + mime-entity-implementation-alist)))) + (setq rest (cdr rest)) + )))) + +(defmacro mm-define-method (name args &rest body) + "Define NAME as a method function of (nth 1 (car ARGS)) backend. + +ARGS is like an argument list of lambda, but (car ARGS) must be +specialized parameter. (car (car ARGS)) is name of variable and (nth +1 (car ARGS)) is name of backend." + (let* ((specializer (car args)) + (class (nth 1 specializer)) + (self (car specializer))) + `(let ((imps (cdr (assq ',class mime-entity-implementation-alist))) + (func (lambda ,(if self + (cons self (cdr args)) + (cdr args)) + ,@body))) + (if imps + (set-alist 'mime-entity-implementation-alist + ',class (put-alist ',name func imps)) + (set-alist 'mime-entity-implementation-alist + ',class + (list (cons ',name func))) + )))) + +(put 'mm-define-method 'lisp-indent-function 'defun) + +(eval-when-compile + (defmacro eval-module-depended-macro (module definition) + (condition-case nil + (progn + (require (eval module)) + definition) + (error `(eval-after-load ,(symbol-name (eval module)) ',definition)) + )) + ) + (make-obsolete-variable 'mime-message-structure "should not use it.") diff --git a/mime-en.sgml b/mime-en.sgml index dd428f8..3ef7f7f 100644 --- a/mime-en.sgml +++ b/mime-en.sgml @@ -870,18 +870,23 @@ ENCODING must be string.")

Network representation of header encoded-word

-encoded-word $B$O(B header $B$GHs(B ASCII $BJ8;z$rI=8=$9$k$?$a$N7A(B -$B<0$G!"(BRFC 2047 $B$GDj5A$5$l$F$$$^$9!#(B +RFC 2047 defines the +encoded-word which is a format to represent +non-ASCII characters in a header.

-$B$^$?!"9T57$N0-$$$3$H$@$H8@$($^$9$,!"(Bencoded-word $B$rMQ$$$:$KHs(B -ASCII $BJ8;z$r(B header $B$KF~$l$?5-;v$bB8:_$7$^$9!#(B +The encoded-word is the only valid format to represent +non-ASCII characters in a header, but there are also +invalid styles. Such kinds of evil messages represent +non-ASCII characters in headers without encoded-words (it +is called "raw" non-ASCII characters).

-FLIM $B$O$3$l$i$rId9f2=!&I|9f2=$9$k5!G=$rDs6!$7$^$9!#(B +FLIM provides encoding/decoding features of both encoded-word and +invalid "raw" non-ASCII characters.

Header encoding/decoding diff --git a/mime-en.texi b/mime-en.texi index aa65897..bf1be13 100644 --- a/mime-en.texi +++ b/mime-en.texi @@ -957,10 +957,11 @@ ENCODING must be string.") @chapter Network representation of header @cindex RFC 2047 @cindex Standards Track +@cindex encoded-word @cindex RFC 2047 -encoded-word $B$O(B header $B$GHs(B ASCII (@ref{ASCII}) $BJ8;z$rI=8=$9$k$?$a$N7A<0(B -$B$G!"(B@strong{RFC 2047} $B$GDj5A$5$l$F$$$^$9!#(B@refill +@strong{RFC 2047} defines the @strong{encoded-word} which is a format to +represent non-ASCII (@ref{ASCII}) characters in a header.@refill @noindent @@ -971,10 +972,14 @@ Message Header Extensions for Non-ASCII Text'', November 1996, Standards Track (obsolete RFC 1521,1522,1590). @end quotation -$B$^$?!"9T57$N0-$$$3$H$@$H8@$($^$9$,!"(Bencoded-word $B$rMQ$$$:$KHs(B ASCII -(@ref{ASCII}) $BJ8;z$r(B header $B$KF~$l$?5-;v$bB8:_$7$^$9!#(B@refill +The encoded-word is the only valid format to represent non-ASCII +(@ref{ASCII}) characters in a header, but there are also invalid styles. +Such kinds of evil messages represent non-ASCII (@ref{ASCII}) characters +in headers without encoded-words (it is called "raw" non-ASCII +(@ref{ASCII}) characters).@refill -FLIM $B$O$3$l$i$rId9f2=!&I|9f2=$9$k5!G=$rDs6!$7$^$9!#(B +FLIM provides encoding/decoding features of both encoded-word and +invalid "raw" non-ASCII (@ref{ASCII}) characters. @menu diff --git a/mime-parse.el b/mime-parse.el index a445822..4a49855 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -24,10 +24,8 @@ ;;; Code: -(require 'std11) (require 'mime-def) - -(eval-when-compile (require 'cl)) +(require 'std11) ;;; @ lexical analyzer diff --git a/smtp.el b/smtp.el index c2c9937..47d082a 100644 --- a/smtp.el +++ b/smtp.el @@ -1,10 +1,10 @@ ;;; smtp.el --- basic functions to send mail with SMTP server -;; Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. +;; Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc. ;; Author: Tomoji Kagatani ;; Simon Leinen (ESMTP support) -;; Shuhei KOBAYASHI +;; Shuhei KOBAYASHI ;; Keywords: SMTP, mail ;; This file is part of FLIM (Faithful Library about Internet Message). @@ -20,13 +20,18 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'mail-utils) ; pick up mail-strip-quoted-names +(require 'poe) +(require 'poem) +(require 'pcustom) +(require 'mail-utils) ; mail-strip-quoted-names + +(eval-when-compile (require 'cl)) ; push (defgroup smtp nil "SMTP protocol for sending mail." @@ -62,7 +67,11 @@ don't define this value." :type '(choice (const nil) string) :group 'smtp) -(defvar smtp-debug-info nil) +(defcustom smtp-debug-info nil + "*smtp debug info printout. messages and process buffer." + :type 'boolean + :group 'smtp) + (defvar smtp-read-point nil) (defun smtp-make-fqdn () diff --git a/smtpmail.el b/smtpmail.el index 807b4a7..3d330ec 100644 --- a/smtpmail.el +++ b/smtpmail.el @@ -1,6 +1,6 @@ ;;; smtpmail.el --- SMTP interface for mail-mode -;; Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. +;; Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc. ;; Author: Tomoji Kagatani ;; Keywords: mail @@ -18,8 +18,8 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: @@ -42,10 +42,23 @@ ;;; Code: +(require 'poe) +(require 'pcustom) (require 'smtp) (require 'sendmail) (require 'time-stamp) +(eval-when-compile (require 'static)) + +(static-when (featurep 'xemacs) + (define-obsolete-variable-alias 'smtpmail-default-smtp-server + 'smtp-default-server) + (define-obsolete-variable-alias 'smtpmail-smtp-server 'smtp-server) + (define-obsolete-variable-alias 'smtpmail-smtp-service 'smtp-service) + (define-obsolete-variable-alias 'smtpmail-local-domain 'smtp-local-domain) + (define-obsolete-variable-alias 'smtpmail-debug-info 'smtp-debug-info) + ) + ;;; (defcustom smtpmail-queue-mail nil @@ -102,7 +115,7 @@ This is relative to `smtpmail-queue-dir'.") (backward-char 1) (setq delimline (point-marker)) ;; (sendmail-synch-aliases) - (if mail-aliases + (if (and mail-aliases (fboundp 'expand-mail-aliases)) ; XEmacs (expand-mail-aliases (point-min) delimline)) (goto-char (point-min)) ;; ignore any blank lines in the header diff --git a/std11.el b/std11.el index a083236..982b895 100644 --- a/std11.el +++ b/std11.el @@ -24,10 +24,9 @@ ;;; Code: -(or (fboundp 'buffer-substring-no-properties) - (require 'poe)) - -(require 'custom) +(require 'poe) +(require 'poem) ; find-non-ascii-charset-string +(require 'pcustom) ; std11-lexical-analyzer ;;; @ fetch