emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 f5d7fb3: Fix 'uudecode-decode-region-internal' in multibyte buf


From: Eli Zaretskii
Subject: emacs-27 f5d7fb3: Fix 'uudecode-decode-region-internal' in multibyte buffers
Date: Sat, 7 Nov 2020 04:41:45 -0500 (EST)

branch: emacs-27
commit f5d7fb3a2dee3f9ae49151e3d01483aad7fb734b
Author: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix 'uudecode-decode-region-internal' in multibyte buffers
    
    * lisp/mail/uudecode.el (uudecode-decode-region-internal): Fix
    inserting the decoded string into a multibyte buffer.  Optimize by
    working with characters, not strings.  (Bug#44411)
    
    Copyright-paperwork-exempt: yes
---
 lisp/mail/uudecode.el | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index 9423275..8bcb392 100644
--- a/lisp/mail/uudecode.el
+++ b/lisp/mail/uudecode.el
@@ -162,12 +162,10 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
              (setq counter (1+ counter)
                    inputpos (1+ inputpos))
              (cond ((= counter 4)
-                    (setq result (cons
-                                  (concat
-                                   (char-to-string (ash bits -16))
-                                   (char-to-string (logand (ash bits -8) 255))
-                                   (char-to-string (logand bits 255)))
-                                  result))
+                    (setq result (cons (logand bits 255)
+                                       (cons (logand (ash bits -8) 255)
+                                             (cons (ash bits -16)
+                                                   result))))
                     (setq bits 0 counter 0))
                    (t (setq bits (ash bits 6)))))))
          (cond
@@ -179,26 +177,26 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
            ;;(error "uucode ends unexpectedly")
            (setq done t))
           ((= counter 3)
-           (setq result (cons
-                         (concat
-                          (char-to-string (logand (ash bits -16) 255))
-                          (char-to-string (logand (ash bits -8) 255)))
-                         result)))
+           (setq result (cons (logand (ash bits -8) 255)
+                              (cons (logand (ash bits -16) 255)
+                                    result))))
           ((= counter 2)
-           (setq result (cons
-                         (char-to-string (logand (ash bits -10) 255))
-                         result))))
+           (setq result (cons (logand (ash bits -10) 255)
+                              result))))
          (skip-chars-forward non-data-chars end))
        (if file-name
             (with-temp-file file-name
               (set-buffer-multibyte nil)
-              (insert (apply #'concat (nreverse result))))
+              (apply #'insert (nreverse result)))
          (or (markerp end) (setq end (set-marker (make-marker) end)))
          (goto-char start)
-         (if enable-multibyte-characters
-             (dolist (x (nreverse result))
-                (insert (decode-coding-string x 'binary)))
-           (insert (apply #'concat (nreverse result))))
+          (apply #'insert
+                 (nreverse
+                  (if enable-multibyte-characters
+                      (mapcar (lambda (ch)
+                                (or (decode-char 'eight-bit ch) ch))
+                              result)
+                    result)))
          (delete-region (point) end))))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]