]> git.eshelyaron.com Git - emacs.git/commit
Fix replace-regexp-in-string substring match data translation
authorMattias Engdegård <mattiase@acm.org>
Wed, 25 Nov 2020 14:32:08 +0000 (15:32 +0100)
committerMattias Engdegård <mattiase@acm.org>
Thu, 26 Nov 2020 13:20:13 +0000 (14:20 +0100)
commit558b6dbca7bc933fe01255be9ebeffebd44a2645
tree32f4bc6b85c11d31a513afb4b804e7502d00808d
parent0287c5176867628e7acb834b3d5f26a150cfaf85
Fix replace-regexp-in-string substring match data translation

For certain patterns, re-matching the same regexp on the matched
substring does not produce correctly translated match data
(bug#15107 and bug#44861).

Using a new builtin function also improves performance since the
number of calls to string-match is halved.

Reported by Kevin Ryde and Shigeru Fukaya.

* lisp/subr.el (replace-regexp-in-string): Translate the match data
using match-data--translate instead of trusting a call to string-match
on the matched string to do the job.
* test/lisp/subr-tests.el (subr-replace-regexp-in-string):
Add test cases.
* src/search.c (Fmatch_data__translate): New internal function.
(syms_of_search): Register it as a subroutine.
lisp/subr.el
src/search.c
test/lisp/subr-tests.el