From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Akinori MUSHA Newsgroups: gmane.emacs.bugs Subject: bug#37095: [PATCH] Save match data in ucs-normalize-region Date: Fri, 23 Aug 2019 16:21:58 +0900 Message-ID: References: <87k1b4sfni.fsf@mouse.gnus.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005519270590c3aadf" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="686"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Lars Ingebrigtsen , 37095@debbugs.gnu.org To: YAMAMOTO Mitsuharu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 23 09:23:21 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i13uq-0018It-Aq for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 09:23:20 +0200 Original-Received: from localhost ([::1]:52290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i13up-0004DY-7F for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 03:23:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33440) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i13ub-0004B3-Mf for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 03:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i13uY-00046a-TP for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 03:23:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i13uY-00046L-Hc for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 03:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i13uY-0006jk-Bn for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 03:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Akinori MUSHA Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Aug 2019 07:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37095 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed patch Original-Received: via spool by 37095-submit@debbugs.gnu.org id=B37095.156654494125837 (code B ref 37095); Fri, 23 Aug 2019 07:23:02 +0000 Original-Received: (at 37095) by debbugs.gnu.org; 23 Aug 2019 07:22:21 +0000 Original-Received: from localhost ([127.0.0.1]:39030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i13tt-0006ie-4d for submit@debbugs.gnu.org; Fri, 23 Aug 2019 03:22:21 -0400 Original-Received: from v055125.ppp.asahi-net.or.jp ([124.155.55.125]:30575 helo=mail.musha.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i13tq-0006iU-LB for 37095@debbugs.gnu.org; Fri, 23 Aug 2019 03:22:19 -0400 Original-Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (Authenticated sender: akinori) by mail.musha.org (Postfix) with ESMTPSA id 46FCX81RwjzsvjP for <37095@debbugs.gnu.org>; Fri, 23 Aug 2019 16:22:16 +0900 (JST) Original-Received: by mail-lf1-f52.google.com with SMTP id b17so6408765lff.7 for <37095@debbugs.gnu.org>; Fri, 23 Aug 2019 00:22:16 -0700 (PDT) X-Gm-Message-State: APjAAAUxHgBra4QlnT0oNMd1CYRroLkAF0qqQAuh9eilkMBH5+JuNNmz CPQqYwZ2c5FefaX4ZglABkvUueTiseCrglIqIAR5Pw== X-Google-Smtp-Source: APXvYqzgwz/91oVHs7Pq55FHPSEDqecIrl4atNZO7KnDPyUg33X7ogYU/eNegk3ctxgw29F45aDiPBoGy/uExs/P1Ic= X-Received: by 2002:a19:4f42:: with SMTP id a2mr1826415lfk.23.1566544934271; Fri, 23 Aug 2019 00:22:14 -0700 (PDT) In-Reply-To: X-Gmail-Original-Message-ID: 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: 209.51.188.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:165660 Archived-At: --0000000000005519270590c3aadf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks you both for the information. I don't insist if you don't think this way, but I think this bug was partly due to ucs-normalize-region being called only if the user is on a certain platform/filesystem and the file name actually needs normalization, so it would be better to fix such a function not to break a globally shared state like match data so that there's no room for more bugs of the same kind. Just my two yen. 2019-08-23=E6=97=A5(=E9=87=91) 14:06 YAMAMOTO Mitsuharu : > On Fri, 23 Aug 2019 12:51:29 +0900, > Lars Ingebrigtsen wrote: > > > > Akinori MUSHA writes: > > > > > A patch generated by git format-patch is attached below, which simply > > > wraps `ucs-normalize-region` with `save-match-data`. > > > > > > I'm a user of the Emacs Mac port by mituharu was investigating a bug > > > where dired fails to open a certain local directory on macOS. The > > > error was raised at `replace-match` in the `insert-directory` > > > function: > > > > > > ``` > > > (when (re-search-forward "^ *\\(total\\)" nil t) > > > (let ((available (get-free-disk-space "."))) > > > (when available > > > ;; Replace "total" with "used", to avoid confusion. > > > (replace-match "total used in directory" nil nil ni= l > 1) > > > ``` > > > > > > And it turned out the match data changed after returning from > > > `get-free-disk-space` and that was why `replace-match` failed. > > > > You don't say what Emacs version you're reporting this bug for, but the > > following patch was applied in February 2018 to the Emacs trunk, so I > > think this problem has been fixed by now: > > For the Mac port, the "work" branch already contains a similar change: > > > https://bitbucket.org/mituharu/emacs-mac/commits/b651c3a6bab6795202e2ebcd= 4396d665909cc210 > > It will shortly be included in the next release based on Emacs 26.3 RC1. > > YAMAMOTO Mitsuharu > mituharu@math.s.chiba-u.ac.jp > > --0000000000005519270590c3aadf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks you both for the information.

I = don't insist if you don't think this way, but I think this bug was = partly due to ucs-normalize-region being called only if the user is on a ce= rtain platform/filesystem and the file name actually needs normalization, s= o it would be better to fix such a function not to break a globally shared = state like match data so that there's no room for more bugs of the same= kind.

Just my two yen.

2019-08-23=E6=97= =A5(=E9=87=91) 14:06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>:<= br>
On Fri, 23 Aug 2= 019 12:51:29 +0900,
Lars Ingebrigtsen wrote:
>
> Akinori MUSHA <knu@iDaemons.org> writes:
>
> > A patch generated by git format-patch is attached below, which si= mply
> > wraps `ucs-normalize-region` with `save-match-data`.
> >
> > I'm a user of the Emacs Mac port by mituharu was investigatin= g a bug
> > where dired fails to open a certain local directory on macOS.=C2= =A0 The
> > error was raised at `replace-match` in the `insert-directory`
> > function:
> >
> > ```
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (re-search-f= orward "^ *\\(total\\)" nil t)
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((avai= lable (get-free-disk-space ".")))
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(whe= n available
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0;; Replace "total" with "used", to avoid confusion.<= br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(replace-match "total used in directory" nil nil nil 1)
> > ```
> >
> > And it turned out the match data changed after returning from
> > `get-free-disk-space` and that was why `replace-match` failed. >
> You don't say what Emacs version you're reporting this bug for= , but the
> following patch was applied in February 2018 to the Emacs trunk, so I<= br> > think this problem has been fixed by now:

For the Mac port, the "work" branch already contains a similar ch= ange:

=C2=A0 http= s://bitbucket.org/mituharu/emacs-mac/commits/b651c3a6bab6795202e2ebcd4396d6= 65909cc210

It will shortly be included in the next release based on Emacs 26.3 RC1.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0YAMAMOTO Mitsuha= ru
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mituharu@math.s.chiba-u.ac.jp

--0000000000005519270590c3aadf--