summaryrefslogtreecommitdiff
path: root/x2p
diff options
context:
space:
mode:
authorWolfgang Laun <Wolfgang.Laun@alcatel.at>2007-07-23 13:28:02 +0200
committerAbhijit Menon-Sen <ams@wiw.org>2007-07-25 12:56:56 +0000
commite2f7306727f6521febe2479c66526982cbb5e4f5 (patch)
tree69e30cb98e6fb5a87f66a61bedfc9489e1a71f28 /x2p
parent575d891f3a62db583f6edb528b301cff13d09a96 (diff)
downloadperl-e2f7306727f6521febe2479c66526982cbb5e4f5.tar.gz
s2p.PL
Message-Id: <46A474A2.2060400@thalesgroup.com> p4raw-id: //depot/perl@31656
Diffstat (limited to 'x2p')
-rw-r--r--x2p/s2p.PL15
1 files changed, 11 insertions, 4 deletions
diff --git a/x2p/s2p.PL b/x2p/s2p.PL
index 0a8d5298d3..0ac27f9d70 100644
--- a/x2p/s2p.PL
+++ b/x2p/s2p.PL
@@ -69,6 +69,7 @@ $0 =~ s/^.*?(\w+)[\.\w]*$/$1/;
# (p)sed - a stream editor
# History: Aug 12 2000: Original version.
# Mar 25 2002: Rearrange generated Perl program.
+# Jul 23 2007: Fix bug in regex stripping (M.Thorland)
use strict;
use integer;
@@ -742,15 +743,21 @@ sub Comment($$$$$$){
0;
}
-
-sub stripRegex($$){
- my( $del, $sref ) = @_;
+# stripRegex from the current command. If we're in the first
+# part of s///, trailing spaces have to be kept as the initial
+# part of the replacement string.
+#
+sub stripRegex($$$){
+ my( $del, $sref, $sub ) = @_;
my $regex = $del;
print "stripRegex:$del:$$sref:\n" if $useDEBUG;
while( $$sref =~ s{^(.*?)(\\*)\Q$del\E(\s*)}{}s ){
my $sl = $2;
$regex .= $1.$sl.$del;
if( length( $sl ) % 2 == 0 ){
+ if( $sub && (length( $3 ) > 0) ){
+ $$sref = $3 . $$sref;
+ }
return $regex;
}
$regex .= $3;
@@ -1353,7 +1360,7 @@ sub Parse(){
}
if( $cmd =~ s{^([^\\\n])}{} ){
my $del = $1;
- my $regex = stripRegex( $del, \$cmd );
+ my $regex = stripRegex( $del, \$cmd, "s" );
if( ! defined( $regex ) ){
Warn( "malformed regular expression", $fl );
$error++;