From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kazuhiro Ito Newsgroups: gmane.emacs.bugs Subject: bug#44411: 28.0.50; uudecode-decode-region-internal is broken Date: Thu, 05 Nov 2020 19:48:08 +0900 Message-ID: <86mtzw84gn.wl--xmue@d1.dion.ne.jp> References: <86y2ji6e0y.wl--xmue@d1.dion.ne.jp> <83d00ucv0j.fsf@gnu.org> <86wnz14je7.wl--xmue@d1.dion.ne.jp> <83o8kdb0sj.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33655"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 Emacs/28.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO) Cc: 44411@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 05 11:49:16 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kacpO-0008bl-Ow for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Nov 2020 11:49:14 +0100 Original-Received: from localhost ([::1]:47046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kacpN-0002yo-OV for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Nov 2020 05:49:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kacpC-0002yQ-93 for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 05:49:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kacpC-0002t1-07 for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 05:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kacpB-0000nT-V7 for bug-gnu-emacs@gnu.org; Thu, 05 Nov 2020 05:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kazuhiro Ito Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Nov 2020 10:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44411 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44411-submit@debbugs.gnu.org id=B44411.16045732973005 (code B ref 44411); Thu, 05 Nov 2020 10:49:01 +0000 Original-Received: (at 44411) by debbugs.gnu.org; 5 Nov 2020 10:48:17 +0000 Original-Received: from localhost ([127.0.0.1]:51811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kacoS-0000mP-RD for submit@debbugs.gnu.org; Thu, 05 Nov 2020 05:48:17 -0500 Original-Received: from snd20014.auone-net.jp ([27.86.5.238]:16928 helo=dmta0004.auone-net.jp) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kacoP-0000mD-3F for 44411@debbugs.gnu.org; Thu, 05 Nov 2020 05:48:15 -0500 Original-Received: from kzhr.d1.dion.ne.jp by dmta0004.auone-net.jp with ESMTP id <20201105104810481.BPCM.95516.kzhr.d1.dion.ne.jp@dmta0004.auone-net.jp>; Thu, 5 Nov 2020 19:48:10 +0900 In-Reply-To: <83o8kdb0sj.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192705 Archived-At: > 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