From unknown Wed Jun 25 03:53:38 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#37095 <37095@debbugs.gnu.org> To: bug#37095 <37095@debbugs.gnu.org> Subject: Status: [PATCH] Save match data in ucs-normalize-region Reply-To: bug#37095 <37095@debbugs.gnu.org> Date: Wed, 25 Jun 2025 10:53:38 +0000 retitle 37095 [PATCH] Save match data in ucs-normalize-region reassign 37095 emacs submitter 37095 Akinori MUSHA severity 37095 minor tag 37095 fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 20 03:25:28 2019 Received: (at submit) by debbugs.gnu.org; 20 Aug 2019 07:25:28 +0000 Received: from localhost ([127.0.0.1]:60835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hzyWF-0004v1-J8 for submit@debbugs.gnu.org; Tue, 20 Aug 2019 03:25:27 -0400 Received: from lists.gnu.org ([209.51.188.17]:53188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hzyWD-0004ur-Dt for submit@debbugs.gnu.org; Tue, 20 Aug 2019 03:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46182) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzyWB-0003P4-Il for bug-gnu-emacs@gnu.org; Tue, 20 Aug 2019 03:25:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_20,RCVD_IN_SORBS_DUL, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzyWA-0003OY-7y for bug-gnu-emacs@gnu.org; Tue, 20 Aug 2019 03:25:23 -0400 Received: from v055125.ppp.asahi-net.or.jp ([124.155.55.125]:31566 helo=mail.musha.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hzyW9-0003LU-Sz for bug-gnu-emacs@gnu.org; Tue, 20 Aug 2019 03:25:22 -0400 Received: from am-machimachi.local (ae161184.dynamic.ppp.asahi-net.or.jp [14.3.161.184]) (Authenticated sender: akinori) by mail.musha.org (Postfix) with ESMTPSA id 46CMZp6Qc9zsNBf for ; Tue, 20 Aug 2019 16:18:10 +0900 (JST) From: Akinori MUSHA Subject: [PATCH] Save match data in ucs-normalize-region To: bug-gnu-emacs@gnu.org Openpgp: preference=signencrypt Autocrypt: addr=knu@iDaemons.org; prefer-encrypt=mutual; keydata= mQGiBDjXWqERBACDCxgN9+yMfpm3yvkYp+P4Uw6xxPdcZ9RvnTRkBX9zXaRgSPmMzeZ63LpB 99uVphVZrv/EdlyTf+cRdz6VXXRcTBloA/FsyY86IluBnWCH054WyXzr7az5WB9yDbPnlwcS L919bq0UqTuQUlQswdQAoDQG5LNNZNa0T01ydYtNlwCg3weSI/nEJrGCXGy2wrjg8LiwQ28D /Re2JHQPTYqDEZl6wj5U83wT55ChnTrjPRbGmr/CUdJP6CZQg6+DXYGYulcp3oL4btcdFDRF glJzmQNkUYmqiVC20SMVKUctrOCAI60P7VE40UtXz9EounPSRQQ1lSdMNeRwrZ9o7IcrSj0E Bw8lw3d2WxyM2Rs2crZWfOI2mu8dA/9LbmAw5sLk5Lo5i41nAWP76pyuGxSia6zMRdML6yno C5kmyrI9TwW5LNU/Lsq1Ru2XSA+CwSBpTt0vdwS88dDwPGxRuUHhWVpa1M5t7K7uYODB1cD5 AyNoNnR/lHpxfPZOJNdA3OPgfssN9K+PIuhbBU5xONCoAcdC9TEqSezfUrQhQWtpbm9yaSBN VVNIQSA8YWtpbm9yaUBtdXNoYS5vcmc+iF4EExECAB4FAkEA3xICGwMGCwkIBwMCAxUCAwMW AgECHgECF4AACgkQkgvvx5/Z4e6/swCeOoZdtSIMGoURsJgz0s54M4v9XYsAnjfKKN3F+2/O BM7j0QGWFqkw26/nuQENBDjXWqwQBAC09OxAmKbGn9FETdMA/5abvOY7JgNcFhQutEVnJ90m F/npBucWkCRbOr83t+NB0h5Te+lV/c+mjPyOemfWdAK4R9zQsat+ZqATv4Vgiy0UbJ/5TPfS raNK+QkXnxcDrhpcJXZhX6VYzbWdRSn8xSZzPT19qq0BFafz9UhZKXnLDwAEDQP/dpZe0jWw rED/Kbyr8CDoEKuun/5gPi5xmNz9iJlyvcsdOgok7yen0HHWgdaZAGX3GzjpB5gAaISX/kK6 6s+NeM1XQ7YXpcI8naf0jPa6N3SNWjLf3xPxLbMk0SyaGnrnSQNikk/HBk2Nqyn0kcEaaBbd frgkuuQWPnBDrq2EdOOIRgQYEQIABgUCONdarAAKCRCSC+/Hn9nh7oxxAKC+gMyhZmSZdTvT 3a2Y0RDOx5kRLACeP3JEvGZAZuo1sJeEw504+jr81Xq5AQ0EONdarBAEALT07ECYpsaf0URN 0wD/lpu85jsmA1wWFC60RWcn3SYX+ekG5xaQJFs6vze340HSHlN76VX9z6aM/I56Z9Z0ArhH 3NCxq35moBO/hWCLLRRsn/lM99Kto0r5CRefFwOuGlwldmFfpVjNtZ1FKfzFJnM9PX2qrQEV p/P1SFkpecsPAAQNA/92ll7SNbCsQP8pvKvwIOgQq66f/mA+LnGY3P2ImXK9yx06CiTvJ6fQ cdaB1pkAZfcbOOkHmABohJf+Qrrqz414zVdDthelwjydp/SM9ro3dI1aMt/fE/EtsyTRLJoa eudJA2KST8cGTY2rKfSRwRpoFt1+uCS65BY+cEOurYR044hGBBgRAgAGBQI411qsAAoJEJIL 78ef2eHujHEAoL6AzKFmZJl1O9PdrZjREM7HmREsAJ4/ckS8ZkBm6jWwl4TDnTj6OvzVeg== Message-ID: Date: Tue, 20 Aug 2019 16:18:06 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="00KXSRts8NEdTXlYtD6hBmhV1jhPWzwFq" X-detected-operating-system: by eggs.gnu.org: FreeBSD [generic] [fuzzy] X-Received-From: 124.155.55.125 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --00KXSRts8NEdTXlYtD6hBmhV1jhPWzwFq Content-Type: multipart/mixed; boundary="5sMkWRVSFxXz0oljOufcQ0mjH7itPVZ4p"; protected-headers="v1" From: Akinori MUSHA To: bug-gnu-emacs@gnu.org Message-ID: Subject: [PATCH] Save match data in ucs-normalize-region --5sMkWRVSFxXz0oljOufcQ0mjH7itPVZ4p Content-Type: multipart/mixed; boundary="------------6A994AA2AFB0CBC22F4DF09E" Content-Language: en-US This is a multi-part message in MIME format. --------------6A994AA2AFB0CBC22F4DF09E Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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 nil 1) ``` And it turned out the match data changed after returning from `get-free-disk-space` and that was why `replace-match` failed. Inside of `get-free-disk-space` most platforms uses a generic method to get the free space, and that part is fine because it is surrounded by `save-match-data`. However, the Mac port is one of the few platforms that implements a native 'file-system-info` function, which is called if it exists. Then, the `file-system-info` in `src/mac.c` calls ENCODE_FILE() on a given directory name, which in the end calls `ucs-normalize-region` to normalize the filename, where the match data is clobbered. https://bitbucket.org/mituharu/emacs-mac/src/df827786d7a7fb0a0e2f27577af6= 7e32d9a888a9/src/mac.c#lines-2337 ENCODE_FILE() is transparently called by many C functions, which means `ucs-normalize-region` can be called at unpredictable timings, so I think it should keep match data unchanged. --=20 Akinori MUSHA / https://akinori.org/ --------------6A994AA2AFB0CBC22F4DF09E Content-Type: text/plain; charset=UTF-8; name="0001-Save-match-data-in-ucs-normalize-region.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Save-match-data-in-ucs-normalize-region.patch" =46rom 11d49adcbadcfcbe844f873e63ba1d596f72e4c5 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Mon, 19 Aug 2019 23:53:50 +0900 Subject: [PATCH] Save match data in ucs-normalize-region * lisp/international/ucs-normalize.el (ucs-normalize-region): Save match data. This function can be transparently called via ENCODE_FILE() when the underlying filesytem uses normalized Unicode filenames, so it requires much care not to cause any side effects. --- lisp/international/ucs-normalize.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lisp/international/ucs-normalize.el b/lisp/international/ucs= -normalize.el index 6f1e770c09..d02d4b8e3e 100644 --- a/lisp/international/ucs-normalize.el +++ b/lisp/international/ucs-normalize.el @@ -514,19 +514,20 @@ ucs-normalize-region (narrow-to-region from to) (goto-char (point-min)) (let (start-pos starter) - (while (re-search-forward quick-check-regexp nil t) - (setq starter (string-to-char (match-string 0))) - (setq start-pos (match-beginning 0)) - (ucs-normalize-block - ;; from - (if (or (=3D start-pos (point-min)) - (and (=3D 0 (ucs-normalize-ccc starter)) - (not (memq starter ucs-normalize-combining-chars= )))) - start-pos (1- start-pos)) - ;; to - (if (looking-at ucs-normalize-combining-chars-regexp) - (match-end 0) (1+ start-pos)) - translation-table composition-predicate)))))) + (save-match-data + (while (re-search-forward quick-check-regexp nil t) + (setq starter (string-to-char (match-string 0))) + (setq start-pos (match-beginning 0)) + (ucs-normalize-block + ;; from + (if (or (=3D start-pos (point-min)) + (and (=3D 0 (ucs-normalize-ccc starter)) + (not (memq starter ucs-normalize-combining-cha= rs)))) + start-pos (1- start-pos)) + ;; to + (if (looking-at ucs-normalize-combining-chars-regexp) + (match-end 0) (1+ start-pos)) + translation-table composition-predicate))))))) =20 ;; ---------------------------------------------------------------------= ----------- =20 --=20 2.22.0 --------------6A994AA2AFB0CBC22F4DF09E-- --5sMkWRVSFxXz0oljOufcQ0mjH7itPVZ4p-- --00KXSRts8NEdTXlYtD6hBmhV1jhPWzwFq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQQIHQmcFwWGHUtwsEqSC+/Hn9nh7gUCXVuesgAKCRCSC+/Hn9nh 7tCCAJoCBTbInI2ezz8OZ5zGFncY2bOJrgCg2bzX3M3dH7ge+oCp6TfEE5Eh13I= =HLx7 -----END PGP SIGNATURE----- --00KXSRts8NEdTXlYtD6hBmhV1jhPWzwFq-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 22 23:51:35 2019 Received: (at 37095) by debbugs.gnu.org; 23 Aug 2019 03:51:35 +0000 Received: from localhost ([127.0.0.1]:38735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i10bv-0005CO-Cc for submit@debbugs.gnu.org; Thu, 22 Aug 2019 23:51:35 -0400 Received: from quimby.gnus.org ([80.91.231.51]:39452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i10bs-0005CG-Uj for 37095@debbugs.gnu.org; Thu, 22 Aug 2019 23:51:33 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i10bp-0003Se-K6; Fri, 23 Aug 2019 05:51:31 +0200 From: Lars Ingebrigtsen To: Akinori MUSHA Subject: Re: bug#37095: [PATCH] Save match data in ucs-normalize-region References: Date: Fri, 23 Aug 2019 05:51:29 +0200 In-Reply-To: (Akinori MUSHA's message of "Tue, 20 Aug 2019 16:18:06 +0900") Message-ID: <87k1b4sfni.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: 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 [...] Content analysis details: (-2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.9 DKIM_ADSP_NXDOMAIN No valid author signature and domain not in DNS -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 37095 Cc: 37095@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) 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 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 think this problem has been fixed by now: diff --git a/lisp/files.el b/lisp/files.el index 91aa95d631..75d3b7b1e7 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6473,9 +6473,10 @@ get-free-disk-space space (normally, the number of free 1KB blocks). If DIR's free space cannot be obtained, this function returns nil." - (let ((avail (nth 2 (file-system-info dir)))) - (if avail - (format "%.0f" (/ avail 1024))))) + (save-match-data + (let ((avail (nth 2 (file-system-info dir)))) + (if avail + (format "%.0f" (/ avail 1024)))))) ;; The following expression replaces `dired-move-to-filename-regexp'. (defvar directory-listing-before-filename-regexp -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 22 23:51:38 2019 Received: (at control) by debbugs.gnu.org; 23 Aug 2019 03:51:38 +0000 Received: from localhost ([127.0.0.1]:38738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i10by-0005Ce-LI for submit@debbugs.gnu.org; Thu, 22 Aug 2019 23:51:38 -0400 Received: from quimby.gnus.org ([80.91.231.51]:39466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i10bx-0005CX-91 for control@debbugs.gnu.org; Thu, 22 Aug 2019 23:51:37 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i10bu-0003Sl-Ko for control@debbugs.gnu.org; Fri, 23 Aug 2019 05:51:36 +0200 Date: Fri, 23 Aug 2019 05:51:34 +0200 Message-Id: <87imqosfnd.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #37095 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 37095 fixed close 37095 27.1 quit Content analysis details: (-2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.9 DKIM_ADSP_NXDOMAIN No valid author signature and domain not in DNS -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) tags 37095 fixed close 37095 27.1 quit From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 23 01:06:15 2019 Received: (at 37095) by debbugs.gnu.org; 23 Aug 2019 05:06:16 +0000 Received: from localhost ([127.0.0.1]:38864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i11mB-0000iH-K8 for submit@debbugs.gnu.org; Fri, 23 Aug 2019 01:06:15 -0400 Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:49847) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i11m8-0000i7-Iv for 37095@debbugs.gnu.org; Fri, 23 Aug 2019 01:06:13 -0400 Received: from mathent.math.s.chiba-u.ac.jp (mathent [192.168.32.5]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 461A2F0919; Fri, 23 Aug 2019 14:06:12 +0900 (JST) (envelope-from mituharu@math.s.chiba-u.ac.jp) Date: Fri, 23 Aug 2019 14:06:12 +0900 Message-ID: From: YAMAMOTO Mitsuharu To: Lars Ingebrigtsen Subject: Re: bug#37095: [PATCH] Save match data in ucs-normalize-region In-Reply-To: <87k1b4sfni.fsf@mouse.gnus.org> References: <87k1b4sfni.fsf@mouse.gnus.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: Faculty of Science, Chiba University MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 37095 Cc: Akinori MUSHA , 37095@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 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 > 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/b651c3a6bab6795202e2ebcd4396d665909cc210 It will shortly be included in the next release based on Emacs 26.3 RC1. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 23 03:22:21 2019 Received: (at 37095) by debbugs.gnu.org; 23 Aug 2019 07:22:21 +0000 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 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 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) 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) MIME-Version: 1.0 References: <87k1b4sfni.fsf@mouse.gnus.org> In-Reply-To: From: Akinori MUSHA Date: Fri, 23 Aug 2019 16:21:58 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: bug#37095: [PATCH] Save match data in ucs-normalize-region To: YAMAMOTO Mitsuharu Content-Type: multipart/alternative; boundary="0000000000005519270590c3aadf" X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 37095 Cc: Lars Ingebrigtsen , 37095@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) --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-- From unknown Wed Jun 25 03:53:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 20 Sep 2019 11:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator