summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2001-11-29 16:48:15 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-29 13:47:07 +0000
commitd2bc402e011e53ceb88e1e15628b986d2ca5665f (patch)
tree34927ca945071eed1d42b7befb56940b2531efe5 /ext
parentf8b4d74fa5fd7bb98a4694c41f28371fcf64a67a (diff)
downloadperl-d2bc402e011e53ceb88e1e15628b986d2ca5665f.tar.gz
deparse -wl0 -i.bak
Message-ID: <20011129154815.C25817@rafael> p4raw-id: //depot/perl@13359
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B/Deparse.pm14
-rw-r--r--ext/B/O.pm3
-rw-r--r--ext/B/t/deparse.t6
3 files changed, 20 insertions, 3 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index b84e8ea540..3789b813f9 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 50a445cf49..af9885bf65 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 b8e29a697f..12f3e9e462 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($_ = <ARGV>)) {
chomp $_;
our(@F) = split(" ", $_, 0);