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: Tue, 03 Nov 2020 17:27:41 +0900 Message-ID: <86y2ji6e0y.wl--xmue@d1.dion.ne.jp> 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="37687"; 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) (with unibyte mode) To: 44411@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 03 09:28:11 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 1kZrfm-0009iX-W7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 09:28:10 +0100 Original-Received: from localhost ([::1]:45146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZrfm-0008Gl-2Y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 03:28:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZrff-0008GY-18 for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 03:28:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZrfe-0002fO-O0 for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 03:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kZrfe-0006yr-LE for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 03:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kazuhiro Ito Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2020 08:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44411 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160439207826821 (code B ref -1); Tue, 03 Nov 2020 08:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Nov 2020 08:27:58 +0000 Original-Received: from localhost ([127.0.0.1]:43277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZrfZ-0006yX-S2 for submit@debbugs.gnu.org; Tue, 03 Nov 2020 03:27:58 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:33894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZrfY-0006yQ-LC for submit@debbugs.gnu.org; Tue, 03 Nov 2020 03:27:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZrfY-0008F4-DX for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 03:27:56 -0500 Original-Received: from snd00004.auone-net.jp ([111.86.247.4]:53920 helo=dmta0004.auone-net.jp) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZrfU-0002XV-Lw for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 03:27:55 -0500 Original-Received: from kzhr.d1.dion.ne.jp by dmta0004.auone-net.jp with ESMTP id <20201103082743382.ZODW.95516.kzhr.d1.dion.ne.jp@dmta0004.auone-net.jp>; Tue, 3 Nov 2020 17:27:43 +0900 X-Hashcash: 1:20:201103:bug-gnu-emacs@gnu.org::Q100fm868IIO3wC0:00000000000000000000000000000000000000007tF4 Received-SPF: pass client-ip=111.86.247.4; envelope-from=kzhr@d1.dion.ne.jp; helo=dmta0004.auone-net.jp X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 03:27:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:192591 Archived-At: 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