From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#29189: 25.3; Dired does not work with binary filenames Date: Sat, 18 Nov 2017 16:42:22 +0200 Message-ID: <83lgj3fy29.fsf@gnu.org> References: <3CE09384-E9D6-4DB9-853A-11088CF8DF80@gnu.org> <83a7ztp6p7.fsf@gnu.org> <83k1ywoq4z.fsf@gnu.org> <83h8u0on7y.fsf@gnu.org> <83po8ii56w.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1511016190 18077 195.159.176.226 (18 Nov 2017 14:43:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Nov 2017 14:43:10 +0000 (UTC) Cc: vianchielfaura@gmail.com, 29189@debbugs.gnu.org, schwab@suse.de To: Kenichi Handa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 18 15:43:06 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eG4Kl-0004Jz-Pf for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Nov 2017 15:43:04 +0100 Original-Received: from localhost ([::1]:50263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eG4Ks-0008HA-Vk for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Nov 2017 09:43:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eG4Kn-0008H5-8v for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 09:43:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eG4Kk-0000iM-6Z for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 09:43:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eG4Kk-0000hy-1n for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 09:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eG4Kj-0008MB-RW for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 09:43:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Nov 2017 14:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29189 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29189-submit@debbugs.gnu.org id=B29189.151101617332110 (code B ref 29189); Sat, 18 Nov 2017 14:43:01 +0000 Original-Received: (at 29189) by debbugs.gnu.org; 18 Nov 2017 14:42:53 +0000 Original-Received: from localhost ([127.0.0.1]:45665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eG4Kb-0008Lq-F6 for submit@debbugs.gnu.org; Sat, 18 Nov 2017 09:42:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eG4KZ-0008Lc-KX for 29189@debbugs.gnu.org; Sat, 18 Nov 2017 09:42:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eG4KT-0000XW-Cy for 29189@debbugs.gnu.org; Sat, 18 Nov 2017 09:42:46 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eG4KM-0000WO-KY; Sat, 18 Nov 2017 09:42:38 -0500 Original-Received: from [176.228.60.248] (port=4801 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eG4KL-00069A-M6; Sat, 18 Nov 2017 09:42:38 -0500 In-reply-to: <83po8ii56w.fsf@gnu.org> (message from Eli Zaretskii on Thu, 16 Nov 2017 18:00:55 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140058 Archived-At: > Date: Thu, 16 Nov 2017 18:00:55 +0200 > From: Eli Zaretskii > Cc: 29189@debbugs.gnu.org, schwab@suse.de > > > From: Allen Li > > Date: Wed, 15 Nov 2017 22:31:48 -0800 > > Cc: handa@gnu.org, Andreas Schwab , 29189@debbugs.gnu.org > > > > > diff --git a/lisp/files.el b/lisp/files.el > > > index b47411f..43198bc 100644 > > > --- a/lisp/files.el > > > +++ b/lisp/files.el > > > @@ -6803,10 +6803,13 @@ insert-directory > > > val (get-text-property (point) 'dired-filename)) > > > (goto-char (next-single-property-change > > > (point) 'dired-filename nil (point-max))) > > > - ;; Force no eol conversion on a file name, so > > > - ;; that CR is preserved. > > > - (decode-coding-region pos (point) > > > - (if val coding-no-eol coding)) > > > + (let ((fn (buffer-substring-no-properties pos (point)))) > > > + (delete-region pos (point)) > > > + (insert > > > + ;; Force no eol conversion on a file name, so > > > + ;; that CR is preserved. > > > + (decode-coding-string (string-make-unibyte fn) > > > + (if val coding-no-eol coding)))) > > > (if val > > > (put-text-property pos (point) > > > 'dired-filename t))))))) > > > > This patch works for me. > > Thanks for testing. I'm still worried that we need to force text to > be unibyte in order for the decoding to work. So I'd like to dig into > the code to understand why, and maybe try to fix it if I find some > problems there. If I succeed, the result will work faster, because > the above patch is less efficient that decode-coding-region. Let me > look into this and get back to you in a few days. I found that the alternative patch below solves the original problem without any changes needed in files.el, and without introducing any performance hits. Does anyone see a problem with this proposed patch? Kenichi? diff --git a/src/coding.c b/src/coding.c index d790ad0..eaad0d7 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7423,10 +7423,21 @@ decode_coding (struct coding_system *coding) while (nbytes-- > 0) { - int c = *src++; + int c; - if (c & 0x80) - c = BYTE8_TO_CHAR (c); + /* Copy raw bytes in their 2-byte forms as single characters. */ + if (CHAR_BYTE8_HEAD_P (*src) && nbytes > 0) + { + c = STRING_CHAR_ADVANCE (src); + nbytes--; + } + else + { + c = *src++; + + if (c & 0x80) + c = BYTE8_TO_CHAR (c); + } coding->charbuf[coding->charbuf_used++] = c; } produce_chars (coding, Qnil, 1);