From: Gerard Goossen <gerard@tty.nl>
Date: Tue, 26 Jun 2007 20:33:50 +0000 (+0200)
Subject: p55: correctly translate things like s//$#foo/ge
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b3f5cf18528ca19187726d11aa6582cb64debc65;p=p5sagit%2Fp5-mst-13.2.git

p55: correctly translate things like s//$#foo/ge
Message-ID: <20070626183350.GA11336@ostwald>

p4raw-id: //depot/perl@31552
---

diff --git a/mad/Nomad.pm b/mad/Nomad.pm
index 4fdd3a8..5ccda4f 100755
--- a/mad/Nomad.pm
+++ b/mad/Nomad.pm
@@ -1683,7 +1683,10 @@ sub ast {
     if ($rfirst[-1]->uni ne $llast[-1]->uni) {
 	push @newkids, @rfirst;
     }
-
+    # remove the fake '\n' if /e and '#' in replacement.
+    if (@mods and $mods[0] =~ m/e/ and ($self->madness('R'))[0]->uni =~ m/#/) {
+        unshift @rlast, bless {}, 'chomp'; # hack to remove '\n'
+    }
     push @newkids, $bits->{repl}, @rlast, @mods;
 
     my $retval = $self->newtype->new(Kids => [@newkids]);
diff --git a/mad/P5AST.pm b/mad/P5AST.pm
index d253c86..eaf3bd3 100644
--- a/mad/P5AST.pm
+++ b/mad/P5AST.pm
@@ -75,6 +75,9 @@ sub p5text {
 	    }
 	    $text .= $newtext;
 	}
+        elsif ($type eq "chomp") {
+            $text =~ s/\n$//g;
+        }
 	elsif ($type) {
 	    $text .= $kid->p5text(@_);
 	}
diff --git a/mad/t/p55.t b/mad/t/p55.t
index ef4c397..f3addd1 100644
--- a/mad/t/p55.t
+++ b/mad/t/p55.t
@@ -62,8 +62,6 @@ use File::Find;
 use Test::Differences;
 
 our %failing = map { $_, 1 } qw|
-../t/op/subst.t
-
 ../t/comp/require.t
 
 ../t/io/layers.t
@@ -83,6 +81,9 @@ our %failing = map { $_, 1 } qw|
 ../t/op/symbolcache.t
 
 ../t/op/threads.t
+
+../t/op/exec.t
+../t/io/say.t
 |;
 
 my @files;
@@ -139,13 +140,13 @@ for (my $i=0; $i<3; $i++) { }
 ########
 for (; $a<3; $a++) { }
 ########
-# TODO
+#
 s//$#foo/ge;
 ########
-# TODO
+#
 s//m#.#/ge;
 ########
-# TODO
+#
 eval { require 5.005 }
 ########
 # TODO Reduced test case from t/io/layers.t