GNU bug report logs -
#44411
28.0.50; uudecode-decode-region-internal is broken
Previous Next
Reported by: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
Date: Tue, 3 Nov 2020 08:28:02 UTC
Severity: normal
Tags: patch
Found in version 28.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#44411: 28.0.50; uudecode-decode-region-internal is broken
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 44411 <at> debbugs.gnu.org.
--
44411: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=44411
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> Date: Thu, 05 Nov 2020 19:48:08 +0900
> From: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
> Cc: 44411 <at> debbugs.gnu.org
>
> > Can you augment your patch along these lines, please?
>
> Here is a revised one.
Thanks, pushed to the emacs-27 branch.
Since with this patch you have exhausted the amount of changes we can
accept from you without copyright assignment, would you like to start
the assignment process at this time?
[Message part 3 (message/rfc822, inline)]
When I call uudecode-decode-region-internal in multibyte buffer, it
fails to decode eight-bit characters.
The function makes string from uuencoded text by passing unsigned char
vlue (0-255) to char-to-string function, which makes multibyte-string.
After that, string is decoded as binary. But eight-bit characters are
never made in that way.
(let ((ch #xc8))
(decode-coding-string (char-to-string ch) 'binary))
-> "8"
Additionally, concat and char-to-string functions are called so
frequently that deocder is very slow for large data.
Please see the below patch.
diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index bcbd571b53..f9254aee75 100644
--- a/lisp/mail/uudecode.el
+++ b/lisp/mail/uudecode.el
@@ -149,12 +149,10 @@ uudecode-decode-region-internal
(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
@@ -166,26 +164,21 @@ uudecode-decode-region-internal
;;(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))
+ (setq result (apply #'unibyte-string (nreverse result)))
(if file-name
(with-temp-file file-name
(set-buffer-multibyte nil)
- (insert (apply #'concat (nreverse result))))
+ (insert 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))))
+ (insert result)
(delete-region (point) end))))))
;;;###autoload
--
Kazuhiro Ito
This bug report was last modified 4 years and 190 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.