GNU bug report logs -
#37095
[PATCH] Save match data in ucs-normalize-region
Previous Next
Reported by: Akinori MUSHA <knu <at> iDaemons.org>
Date: Tue, 20 Aug 2019 07:26:02 UTC
Severity: minor
Tags: fixed, patch
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> mouse.gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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/df827786d7a7fb0a0e2f27577af67e32d9a888a9/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.
--
Akinori MUSHA / https://akinori.org/
[0001-Save-match-data-in-ucs-normalize-region.patch (text/plain, attachment)]
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 5 years and 279 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.