[gnus git] branch master updated: m0-5-100-g856fe7a =1= qp.el (quoted-printable-decode-region): Decode multiple bytes at once

Katsumi Yamaoka <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  856fe7a9bd702666fd7e0b18f003dc944bec93e5 (commit)
      from  873ba7b51ddfb07246cd874b7de72662308236c9 (commit)


- Log -----------------------------------------------------------------
commit 856fe7a9bd702666fd7e0b18f003dc944bec93e5
Author: Kenichi Handa <[email protected]>
Date:   Thu Aug 30 22:10:57 2012 +0000

    qp.el (quoted-printable-decode-region): Decode multiple bytes at once

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e852269..88969f0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -10,6 +10,11 @@
 	(gnus-notifications): Use `gnus-notifications-id-to-msg' to map
 	notifications id to messages.
 
+2012-08-30  Kenichi Handa  <[email protected]>
+
+	* qp.el (quoted-printable-decode-region): Decode multiple bytes at
+	once.
+
 2012-08-29  Julien Danjou  <[email protected]>
 
 	* gnus-notifications.el: New file.
diff --git a/lisp/qp.el b/lisp/qp.el
index c8481aa..8725268 100644
--- a/lisp/qp.el
+++ b/lisp/qp.el
@@ -53,7 +53,10 @@ them into characters should be done separately."
       ;; or both of which are lowercase letters in "abcdef", is
       ;; formally illegal. A robust implementation might choose to
       ;; recognize them as the corresponding uppercase letters.''
-      (let ((case-fold-search t))
+      (let ((case-fold-search t)
+	    (decode-hex #'(lambda (n1 n2)
+			    (+ (* (if (<= n1 ?9) (- n1 ?0) (+ (- n1 ?A) 10)) 16)
+			       (if (<= n2 ?9) (- n2 ?0) (+ (- n2 ?A) 10))))))
 	(narrow-to-region from to)
 	;; Do this in case we're called from Gnus, say, in a buffer
 	;; which already contains non-ASCII characters which would
@@ -65,12 +68,17 @@ them into characters should be done separately."
 		    (not (eobp)))
 	  (cond ((eq (char-after (1+ (point))) ?\n)
 		 (delete-char 2))
-		((looking-at "=[0-9A-F][0-9A-F]")
-		 (let ((byte (string-to-number (buffer-substring (1+ (point))
-							      (+ 3 (point)))
-					    16)))
-		   (mm-insert-byte byte 1)
-		   (delete-char 3)))
+		((looking-at "\\(=[0-9A-F][0-9A-F]\\)+")
+		 ;; Decode this sequence at once; i.e. by a single
+		 ;; deletion and insertion.
+		 (let* ((n (/ (- (match-end 0) (point)) 3))
+			(str (make-string n 0)))
+		   (dotimes (i n)
+		     (aset str i (funcall decode-hex (char-after (1+ (point)))
+					  (char-after (+ 2 (point)))))
+		     (forward-char 3))
+		   (delete-region (match-beginning 0) (match-end 0))
+		   (insert str)))
 		(t
 		 (message "Malformed quoted-printable text")
 		 (forward-char)))))

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    5 +++++
 lisp/qp.el     |   22 +++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.