Change 31656 by [EMAIL PROTECTED] on 2007/07/25 12:56:56

        Subject: [PATCH] s2p.PL
        From: Wolfgang Laun <[EMAIL PROTECTED]>
        Date: Mon, 23 Jul 2007 11:28:02 +0200
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/x2p/s2p.PL#26 edit

Differences ...

==== //depot/perl/x2p/s2p.PL#26 (text) ====
Index: perl/x2p/s2p.PL
--- perl/x2p/s2p.PL#25~29121~   2006-10-26 20:48:34.000000000 -0700
+++ perl/x2p/s2p.PL     2007-07-25 05:56:56.000000000 -0700
@@ -69,6 +69,7 @@
 # (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 @@
     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 @@
            }
            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++;
End of Patch.

Reply via email to