1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-08 03:23:57 -04:00

making some enhancements to the $1 code, to accept \$1 and ${1} correctly

This commit is contained in:
Ryan Voots 2010-03-12 17:26:24 -05:00
parent 46e20d0106
commit d170d67001

View file

@ -342,7 +342,7 @@ sub _fact_substitute
my ($matchstart, $matchend) = ($-[0], $+[0]); my ($matchstart, $matchend) = ($-[0], $+[0]);
my @caps = map {substr($pred, $-[$_], $+[$_] - $-[$_])} 1..$#+; my @caps = map {substr($pred, $-[$_], $+[$_] - $-[$_])} 1..$#+;
my $realsubst = $subst; my $realsubst = $subst;
$realsubst =~ s/\$(\d+)/$caps[$1-1]/eg; $realsubst =~ s/(?<!\\)\$(?:\{(\d+)\}|(\d+))/$caps[$1-1]/eg;
substr $pred, $matchstart, $matchend-$matchstart, $realsubst; substr $pred, $matchstart, $matchend-$matchstart, $realsubst;
pos $pred = $matchstart+length($realsubst); #set the new position, might have an off by one? pos $pred = $matchstart+length($realsubst); #set the new position, might have an off by one?
@ -358,7 +358,7 @@ sub _fact_substitute
{ {
my @caps = map {substr($pred, $-[$_], $+[$_] - $-[$_])} 1..$#+; my @caps = map {substr($pred, $-[$_], $+[$_] - $-[$_])} 1..$#+;
my $realsubst = $subst; my $realsubst = $subst;
$realsubst =~ s/\$(\d+)/$caps[$1-1]/eg; $realsubst =~ s/(?<!\\)\$(?:\{(\d+)\}|(\d+))/$caps[$1-1]/eg;
$pred =~ s/$regex/$realsubst/; $pred =~ s/$regex/$realsubst/;
} }