From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Allen Li Newsgroups: gmane.emacs.bugs Subject: bug#29189: 25.3; Dired does not work with binary filenames Date: Fri, 1 Dec 2017 21:21:14 -0800 Message-ID: References: <3CE09384-E9D6-4DB9-853A-11088CF8DF80@gnu.org> <83a7ztp6p7.fsf@gnu.org> <83k1ywoq4z.fsf@gnu.org> <83h8u0on7y.fsf@gnu.org> <83po8ii56w.fsf@gnu.org> <83lgj3fy29.fsf@gnu.org> <831skserz8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1512192134 24828 195.159.176.226 (2 Dec 2017 05:22:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 2 Dec 2017 05:22:14 +0000 (UTC) Cc: Andreas Schwab , 29189@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 02 06:22:10 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 1eL0Fb-00064r-03 for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Dec 2017 06:22:07 +0100 Original-Received: from localhost ([::1]:34399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eL0Fi-00079F-5w for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Dec 2017 00:22:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eL0FZ-00073q-7Y for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:22:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eL0FW-0002kB-1j for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:22:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60420) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eL0FV-0002jp-Ul for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:22:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eL0FV-0002yI-Lh for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:22:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Allen Li Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Dec 2017 05:22: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.151219208611379 (code B ref 29189); Sat, 02 Dec 2017 05:22:01 +0000 Original-Received: (at 29189) by debbugs.gnu.org; 2 Dec 2017 05:21:26 +0000 Original-Received: from localhost ([127.0.0.1]:40867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL0Ev-0002xS-7F for submit@debbugs.gnu.org; Sat, 02 Dec 2017 00:21:25 -0500 Original-Received: from mail-qk0-f172.google.com ([209.85.220.172]:39351) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL0Er-0002xE-CH for 29189@debbugs.gnu.org; Sat, 02 Dec 2017 00:21:21 -0500 Original-Received: by mail-qk0-f172.google.com with SMTP id u184so15771412qkd.6 for <29189@debbugs.gnu.org>; Fri, 01 Dec 2017 21:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CPqbeYTyFQaOA3VKe/JoB3Y5ff38Qwio3oQJuZztT3E=; b=K9ec5emnWwTq4tx4+NB6lbhZ0zIbXKeOFpy4PDCReiAI37diGKtfW0gGgTaUt0j/Vv Fh92GCoZdYwlZOAUu2fZvmF3uzb6ZOsz0CXGm7eJ2GdU22pIWRVPV88LACtWCCEMEfxa r2yWwUNib51l0LVjYXTDH5yn03syC0ahwYIp8rphYh+3swbWhz+ExEtDQRsVE5CK5rr5 7KEZdYs/RbAsAE74d+6Kp7HTcz+81ap6s0KWe2zVZqmO5gxVQGpKta/Azc1XFHEA1gBu 5sy7UjVJLgiSSsFDI2XTo9yLBsw2Qdmx/Q65VEeOXNIpVvsIhE3EFSw6HwuAVwXJrw5y BLUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CPqbeYTyFQaOA3VKe/JoB3Y5ff38Qwio3oQJuZztT3E=; b=fFseazAK2DQrNZz1+rvtGy3Q7YoxoJh7WFJPqlDsXpAYAPR5xnl4CHr0iLVi4tkfLD VRQUo/QUDoZN/98kyBTqiN1ZVqIBGEsBiHosxTsERz1+F87j9AE5m08tOr9KZ9nLyOZ7 CQhWzfqpWENvnAYxpMcUYh/ClVvggRaV1JIqXvuIOe9TTkQEQYAY3bCftgub6ntl/Sxf ZHrRM9u+NF0U9DX1Is4HS5f7f2zt3OWwjHCh8tQ4cjueZwrhnaj7gQiAEt/71WnVh+Jc Hi0TG3XVWf8NvUv1MpCOYRsP5dUvs/X/4bJFerViYSbBydoXQ9+WK5kHWvTgJoDazl4T FR7A== X-Gm-Message-State: AKGB3mKxkuLelON1Lf3oKK/K7M0nvK1MJrjlUPtP1BiDT6v/o39B7031 MOBXBJfS+sBHykg+TmA/QoaFSazYrwTUEqCodPc= X-Google-Smtp-Source: AGs4zMbMu55CWCBmCfpr7xWR8GxU3FcIB/Z2FoCqDhHG7kiQMYpz/urYp2g4m44waG9hhZw6TaCojBoR5iAHWGYZdNw= X-Received: by 10.55.18.134 with SMTP id 6mr11610690qks.136.1512192075547; Fri, 01 Dec 2017 21:21:15 -0800 (PST) Original-Received: by 10.237.52.161 with HTTP; Fri, 1 Dec 2017 21:21:14 -0800 (PST) In-Reply-To: <831skserz8.fsf@gnu.org> 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:140611 Archived-At: On Mon, Nov 20, 2017 at 10:15 AM, Eli Zaretskii wrote: > Right you are, thanks. Updated patch below. > > diff --git a/src/coding.c b/src/coding.c > index d790ad0..ac55f87 100644 > --- a/src/coding.c > +++ b/src/coding.c > @@ -7423,10 +7423,23 @@ 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 from multibyte > + text as single characters. */ > + if (coding->src_multibyte > + && 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); I applied this patch to master (0b6f4f2c60) and it fixes the bug and doesn't crash Emacs immediately. The code also looks right, but I am not familiar with Emacs's C code. A few questions. Why do we have to handle multibyte strings in this function decode_coding? (I found the answer in the docs) Can you briefly explain how Emacs internally stores unibyte and multibyte strings? (I found the answer in character.h) After doing the above research, I can more confidently say this is right, but having an expert opinion would be nice.