From: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44411@debbugs.gnu.org
Subject: bug#44411: 28.0.50; uudecode-decode-region-internal is broken
Date: Thu, 05 Nov 2020 19:48:08 +0900 [thread overview]
Message-ID: <86mtzw84gn.wl--xmue@d1.dion.ne.jp> (raw)
In-Reply-To: <83o8kdb0sj.fsf@gnu.org>
> OK, I agree also to your other optimizations, but can we please go a
> step further and avoid consing a string here? 'insert' is perfectly
> capable of inserting characters, not only strings. So in the
> unibyte-buffer case, just something like
>
> (apply #'insert (nreverse result))
>
> with 'result' being a list of bytes, will produce what you want. And
> in the multibyte-buffer case you just need to convert each byte to its
> Unicode-compatible codepoint, by using
>
> (decode-char 'eight-bit CH)
>
> probably in 'mapcar' or somesuch, and then call 'insert'.
>
> Can you augment your patch along these lines, please?
Here is a revised one.
diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index bcbd571b53..0dce9b7b72 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,26 @@ 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))
(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
--
Kazuhiro Ito
next prev parent reply other threads:[~2020-11-05 10:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 8:27 bug#44411: 28.0.50; uudecode-decode-region-internal is broken Kazuhiro Ito
2020-11-03 15:09 ` Lars Ingebrigtsen
2020-11-03 15:36 ` Eli Zaretskii
2020-11-04 8:26 ` Kazuhiro Ito
2020-11-04 15:26 ` Eli Zaretskii
2020-11-05 10:48 ` Kazuhiro Ito [this message]
2020-11-05 13:48 ` Eli Zaretskii
2020-11-07 9:42 ` Eli Zaretskii
2020-11-09 15:47 ` Kazuhiro Ito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86mtzw84gn.wl--xmue@d1.dion.ne.jp \
--to=kzhr@d1.dion.ne.jp \
--cc=44411@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).