From: Rafael Garcia-Suarez Date: Thu, 29 Nov 2001 15:48:15 +0000 (+0100) Subject: deparse -wl0 -i.bak X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d2bc402e011e53ceb88e1e15628b986d2ca5665f;p=p5sagit%2Fp5-mst-13.2.git deparse -wl0 -i.bak Message-ID: <20011129154815.C25817@rafael> p4raw-id: //depot/perl@13359 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index b84e8ea..3789b81 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -19,7 +19,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber cstring CVf_METHOD CVf_LOCKED CVf_LVALUE PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED); -$VERSION = 0.61; +$VERSION = 0.62; use strict; use warnings (); @@ -527,6 +527,18 @@ sub compile { my(@args) = @_; return sub { my $self = B::Deparse->new(@args); + # First deparse command-line args + if (defined $^I) { # deparse -i + print q(BEGIN { $^I = ).cstring($^I).qq(; }\n); + } + if ($^W) { # deparse -w + print qq(BEGIN { \$^W = $^W; }\n); + } + if ($/ ne "\n" or defined $O::savebackslash) { # deparse -l and -0 + my $fs = cstring($/) || 'undef'; + my $bs = cstring($O::savebackslash) || 'undef'; + print qq(BEGIN { \$/ = $fs; \$\\ = $bs; }\n); + } my @BEGINs = B::begin_av->isa("B::AV") ? B::begin_av->ARRAY : (); my @INITs = B::init_av->isa("B::AV") ? B::init_av->ARRAY : (); my @ENDs = B::end_av->isa("B::AV") ? B::end_av->ARRAY : (); diff --git a/ext/B/O.pm b/ext/B/O.pm index 50a445c..af9885b 100644 --- a/ext/B/O.pm +++ b/ext/B/O.pm @@ -42,7 +42,8 @@ sub import { die $compilesub; } - local ($\,$",$,) = (undef,' ',''); + local $savebackslash = $\; + local ($\,$",$,) = (undef,' ',''); &$compilesub(); close STDERR if $veryquiet; diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index b8e29a6..12f3e9e 100644 --- a/ext/B/t/deparse.t +++ b/ext/B/t/deparse.t @@ -98,11 +98,15 @@ my $path = join " ", map { qq["-I$_"] } @INC; $path .= " -MMac::err=unix" if $Is_MacOS; my $redir = $Is_MacOS ? "" : "2>&1"; -$a = `$^X $path "-MO=Deparse" -anle 1 $redir`; +$a = `$^X $path "-MO=Deparse" -anlwi.bak -e 1 $redir`; $a =~ s/(?:# )?-e syntax OK\n//g; # "# " for Mac OS +$a =~ s/.*possible typo.*\n//; # Remove warning line $a =~ s{\\340\\242}{\\s} if (ord("\\") == 224); # EBCDIC, cp 1047 or 037 $a =~ s{\\274\\242}{\\s} if (ord("\\") == 188); # $^O eq 'posix-bc' $b = <<'EOF'; +BEGIN { $^I = ".bak"; } +BEGIN { $^W = 1; } +BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = )) { chomp $_; our(@F) = split(" ", $_, 0);