This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #120463] s/// and tr/// with wide delimiters
authorFather Chrysostomos <sprout@cpan.org>
Thu, 14 Nov 2013 22:29:51 +0000 (14:29 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 14 Nov 2013 22:29:51 +0000 (14:29 -0800)
commite68dd03a55114f7eaedbb2b0871e0facb8e91549
treea1e6fce8ee779aa32036734b924d33d7a0c716b3
parent58534900c38f976129529850bd5168d61c39a495
[perl #120463] s/// and tr/// with wide delimiters

$ perl -Mutf8 -e 's αaαα'
Substitution replacement not terminated at -e line 1.

What is happening is that the first scan goes past the delimiter at
the end of the pattern.  Then a single byte is compared (the previous
character against the first byte of the opening delimiter) to see
whether the parser needs to step back one byte before scanning the
second part.

That means you can do the equivalent of s/foo/|bar|g if / is replaced
with a wide character:

$ perl -l -Mutf8 -e '$_ = "a";  s αaα|b|; print'
b

This commit fixes it by giving toke.c:S_scan_str an extra parameter,
so it can tell the callers that need this (scan_subst and scan_trans)
where to start scanning the replacement.
embed.fnc
embed.h
proto.h
t/uni/lex_utf8.t
toke.c