develooper Front page | perl.perl5.porters | Postings from April 2001

[PATCH B::Deparse] fix string uninterpretation

Thread Next
From:
Robin Houston
Date:
April 26, 2001 09:13
Subject:
[PATCH B::Deparse] fix string uninterpretation
Message ID:
20010426171341.A27299@puffinry.freeserve.co.uk
[robin@dev perl-current]$ ./perl -Ilib -MO=Deparse -e'print <<x' -e'\$\$' -ex
print "\$$\n";
-e syntax OK


That's not right!
Patch follows.

 .robin.


--- ext/B/B/Deparse.pm.sent1	Thu Apr 26 17:05:59 2001
+++ ext/B/B/Deparse.pm	Thu Apr 26 17:09:09 2001
@@ -2754,15 +2754,15 @@
 # but not character escapes
 sub uninterp {
     my($str) = @_;
-    $str =~ s/(^|[^\\])([\$\@]|\\[uUlLQE])/$1\\$2/g;
+    $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\%\@]|\\[uUlLQE])/$1$2\\$3/g;
     return $str;
 }
 
 # the same, but treat $|, $), and $ at the end of the string differently
 sub re_uninterp {
     my($str) = @_;
-    $str =~ s/(^|[^\\])(\@|\\[uUlLQE])/$1\\$2/g;
-    $str =~ s/(^|[^\\])(\$[^)|])/$1\\$2/g;
+    $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\%\@](?!\||\)|$)|\\[uUlLQE])/$1$2\\$3/g
+;
     return $str;
 }
 

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About