GNU bug report logs -
#15107
24.3; replace-regexp-in-string wrong on \`
Previous Next
Reported by: Kevin Ryde <user42 <at> zip.com.au>
Date: Thu, 15 Aug 2013 22:17:02 UTC
Severity: normal
Tags: confirmed, patch
Merged with 44861
Found in versions 24.3, 25.1, 27.1
Done: Mattias EngdegÄrd <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
replace-regexp-in-string behaves incorrectly if a regexp has \` among
its matches.
(replace-regexp-in-string "\\`\\|X" "Z" "--XX--" t t)
=>
"Z--ZXZX--"
where I expected
"Z--ZZ--"
This seems to be due to the optimization in replace-regexp-in-string
which re-matches on the matched substring. \' can match the substring
where it did not match in the middle of the full string. In the example
above "X" is the match in the full string, but on taking that "X" as a
substring it can match "\\`".
Probably similar mismatches on the substring occur for things like \' ^
$ \b \< etc. Maybe the comment in the code about munging the match data
would be a better way.
In GNU Emacs 24.3.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2013-05-29 on blah.blah, modified by Debian
System Description: Debian GNU/Linux testing/unstable
Configured using:
`configure '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
'--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes'
'--with-x-toolkit=lucid' '--with-toolkit-scroll-bars' '--without-gconf'
'build_alias=i486-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
'LDFLAGS=-Wl,-z,relro -Wl,-znocombreloc'
'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LANG: en_AU
locale-coding-system: iso-latin-1-unix
default enable-multibyte-characters: t
This bug report was last modified 4 years and 170 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.