From: yamaoka Date: Wed, 10 Feb 2010 04:17:43 +0000 (+0000) Subject: 2010-02-09 Kazuhiro Ito X-Git-Tag: flim-1_14-wl-root~5 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08abbffcf723b558e7df0dbcdbcda1a74751fad6;p=elisp%2Fflim.git 2010-02-09 Kazuhiro Ito * mel-q-ccl.el (quoted-printable-ccl-encode-string) (quoted-printable-ccl-insert-encoded-file) (q-encoding-ccl-encode-string): Use ccl-execute-on-string() on Emacs 23.1. (quoted-printable-ccl-encode-region): Use quoted-printable-ccl-encode-string() on Emacs 23.1. 2010-01-25 Kazuhiro Ito * mel-q-ccl.el (mel-ccl-encode-quoted-printable-generic): Output invalid character as is. 2010-01-24 Kazuhiro Ito * mel-q.el (quoted-printable-quote-char) (quoted-printable-internal-encode-region): Support Emacs 23 raw-byte characters in multibyte string. * mel-q-ccl.el (mel-ccl-decode-q) (mel-ccl-encode-q-generic) (mel-ccl-encode-quoted-printable-generic): Ditto. (quoted-printable-ccl-write-decoded-region): Use LF eol coding system explicitly. --- diff --git a/ChangeLog b/ChangeLog index 759ceb4..cdfab51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2010-02-09 Kazuhiro Ito + + * mel-q-ccl.el (quoted-printable-ccl-encode-string) + (quoted-printable-ccl-insert-encoded-file) + (q-encoding-ccl-encode-string): Use ccl-execute-on-string() on + Emacs 23.1. + (quoted-printable-ccl-encode-region): Use + quoted-printable-ccl-encode-string() on Emacs 23.1. + +2010-01-25 Kazuhiro Ito + + * mel-q-ccl.el (mel-ccl-encode-quoted-printable-generic): Output + invalid character as is. + +2010-01-24 Kazuhiro Ito + + * mel-q.el (quoted-printable-quote-char) + (quoted-printable-internal-encode-region): Support Emacs 23 + raw-byte characters in multibyte string. + + * mel-q-ccl.el (mel-ccl-decode-q) + (mel-ccl-encode-q-generic) + (mel-ccl-encode-quoted-printable-generic): Ditto. + (quoted-printable-ccl-write-decoded-region): Use LF eol coding + system explicitly. + 2008-11-25 Katsumi Yamaoka * eword-decode.el (eword-decode-string, eword-decode-region): diff --git a/mel-q-ccl.el b/mel-q-ccl.el index aa4c7d5..4627a37 100644 --- a/mel-q-ccl.el +++ b/mel-q-ccl.el @@ -146,8 +146,9 @@ abcdefghijklmnopqrstuvwxyz\ (define-ccl-program mel-ccl-decode-q `(1 ((loop - (read-branch - r0 + (read r0) + (branch + (r0 & 255) ,@(mapcar (lambda (r0) (cond @@ -188,7 +189,9 @@ abcdefghijklmnopqrstuvwxyz\ `(3 (loop (loop - (read-branch + (read r0) + (r0 &= 255) + (branch r0 ,@(mapcar (lambda (r0) @@ -295,6 +298,7 @@ abcdefghijklmnopqrstuvwxyz\ (loop ; invariant: column <= 75 (loop (loop + (r0 &= 255) (branch r0 ,@(mapcar @@ -591,7 +595,7 @@ abcdefghijklmnopqrstuvwxyz\ ((read r0) (loop (branch - r0 + (r0 & 255) ,@(mapcar (lambda (r0) (let ((tmp (aref mel-ccl-qp-table r0))) @@ -729,9 +733,8 @@ abcdefghijklmnopqrstuvwxyz\ (t ;; r0:[^\t\r -~] ;; invalid character found. - ;; -> ignore. - `((read r0) - (repeat)))))) + ;; -> output as is. + `((write-read-repeat r0)))))) mel-ccl-256-table)) ;; r1[0]:[\t ] (loop @@ -884,27 +887,56 @@ abcdefghijklmnopqrstuvwxyz\ (unless-broken ccl-execute-eof-block-on-decoding-some - (defun quoted-printable-ccl-encode-string (string) - "Encode STRING with quoted-printable encoding." - (decode-coding-string - string - 'mel-ccl-quoted-printable-lf-lf-rev)) - - (defun quoted-printable-ccl-encode-region (start end) - "Encode the region from START to END with quoted-printable encoding." - (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 "*fInsert encoded file: ") - (insert - (decode-coding-string - (with-temp-buffer - (set-buffer-multibyte nil) - (insert-file-contents-as-binary filename) - (buffer-string)) - 'mel-ccl-quoted-printable-lf-lf-rev))) + (cond + ((eval-when-compile + (and (eq emacs-major-version 23) + (eq emacs-minor-version 1))) + (defun quoted-printable-ccl-encode-string (string) + "Encode STRING with quoted-printable encoding." + (ccl-execute-on-string 'mel-ccl-encode-quoted-printable-lf-lf + [0 0 0 0 0 0 0 0 0] string nil t)) + (defun quoted-printable-ccl-encode-region (start end) + "Encode the region from START to END with quoted-printable encoding." + (interactive "*r") + (save-excursion + (goto-char start) + (insert (prog1 (quoted-printable-ccl-encode-string + (buffer-substring start end)) + (delete-region start end))))) + + (defun quoted-printable-ccl-insert-encoded-file (filename) + "Encode contents of the file named as FILENAME, and insert it." + (interactive "*fInsert encoded file: ") + (insert + (ccl-execute-on-string 'mel-ccl-encode-quoted-printable-lf-lf + [0 0 0 0 0 0 0 0 0] + (with-temp-buffer + (set-buffer-multibyte nil) + (insert-file-contents-as-binary filename) + (buffer-string)) + nil t)))) + (t + (defun quoted-printable-ccl-encode-string (string) + "Encode STRING with quoted-printable encoding." + (decode-coding-string + string + 'mel-ccl-quoted-printable-lf-lf-rev)) + + (defun quoted-printable-ccl-encode-region (start end) + "Encode the region from START to END with quoted-printable encoding." + (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 "*fInsert encoded file: ") + (insert + (decode-coding-string + (with-temp-buffer + (set-buffer-multibyte nil) + (insert-file-contents-as-binary filename) + (buffer-string)) + 'mel-ccl-quoted-printable-lf-lf-rev))))) (mel-define-method-function (mime-encode-string string (nil "quoted-printable")) @@ -932,7 +964,10 @@ encoding." (defun quoted-printable-ccl-write-decoded-region (start end filename) "Decode quoted-printable encoded current region and write out to FILENAME." (interactive "*r\nFWrite decoded region to file: ") - (let ((coding-system-for-write 'mel-ccl-quoted-printable-lf-lf-rev) + (let ((coding-system-for-write + (if (coding-system-p 'mel-ccl-quoted-printable-lf-lf-rev-unix) + 'mel-ccl-quoted-printable-lf-lf-rev-unix + 'mel-ccl-quoted-printable-lf-lf-rev)) jka-compr-compression-info-list jam-zcat-filename-list) (write-region start end filename))) @@ -950,16 +985,31 @@ encoding." ;;; @ Q ;;; -(defun q-encoding-ccl-encode-string (string &optional mode) - "Encode STRING to Q-encoding of encoded-word, and return the result. + (cond + ((eval-when-compile + (and (eq emacs-major-version 23) + (eq emacs-minor-version 1))) + (defun q-encoding-ccl-encode-string (string &optional mode) + "Encode STRING to Q-encoding of encoded-word, and return the result. MODE allows `text', `comment', `phrase' or nil. Default value is `phrase'." - (decode-coding-string - string - (cond - ((eq mode 'text) 'mel-ccl-uq-rev) - ((eq mode 'comment) 'mel-ccl-cq-rev) - (t 'mel-ccl-pq-rev)))) + (ccl-execute-on-string + (cond + ((eq mode 'text) 'mel-ccl-encode-uq) + ((eq mode 'comment) 'mel-ccl-encode-cq) + (t 'mel-ccl-encode-pq)) + [0 0 0 0 0 0 0 0 0] string nil t))) + (t + (defun q-encoding-ccl-encode-string (string &optional mode) + "Encode STRING to Q-encoding of encoded-word, and return the result. +MODE allows `text', `comment', `phrase' or nil. Default value is +`phrase'." + (decode-coding-string + string + (cond + ((eq mode 'text) 'mel-ccl-uq-rev) + ((eq mode 'comment) 'mel-ccl-cq-rev) + (t 'mel-ccl-pq-rev)))))) (defun q-encoding-ccl-decode-string (string) "Decode Q encoded STRING and return the result." diff --git a/mel-q.el b/mel-q.el index 953b549..e527f9e 100644 --- a/mel-q.el +++ b/mel-q.el @@ -40,7 +40,8 @@ (defsubst quoted-printable-quote-char (character) (concat "=" - (char-to-string (aref quoted-printable-hex-chars (ash character -4))) + (char-to-string (aref quoted-printable-hex-chars + (ash (logand character 255) -4))) (char-to-string (aref quoted-printable-hex-chars (logand character 15))))) (defun quoted-printable-internal-encode-region (start end) @@ -58,7 +59,7 @@ (forward-char) (setq col 0)) (t - (setq chr (char-after (point))) + (setq chr (logand (char-after (point)) 255)) (cond ((and (memq chr '(? ?\t)) ; encode WSP char before CRLF. (eq (char-after (1+ (point))) ?\n))