Front page | perl.perl5.porters |
Postings from March 2000
Re: [ID 20000330.038] B::Deparse gug isolation
From:
David Glasser
Date:
March 30, 2000 17:01
Subject:
Re: [ID 20000330.038] B::Deparse gug isolation
Message ID:
l03130300b509a8212b69@[209.195.241.78]
>% perl -MO=Deparse -cwe 'sub foo { 23 }; foo'
>% perl -MO=Deparse -cwe 'sub foo { foo($x--) if $x }'
This patch should fix both of these, plus the bug that B::Deparse went bonkers if there was no "main" program code (just sub declarations and so forth). It appears to me that there may be a few more bugs in B::Deparse than just these.
(Standard this-is-my-first-patch caveat applies.)
--David Glasser, glasser@iname.com
--- lib/B/Deparse.pm.orig Thu Mar 30 19:06:05 2000
+++ lib/B/Deparse.pm Thu Mar 30 19:42:51 2000
@@ -254,15 +254,15 @@
if ($op->name eq "gv") {
my $gv = $self->maybe_padgv($op);
if ($op->next->name eq "entersub") {
- next if $self->{'subs_done'}{$$gv}++;
- next if class($gv->CV) eq "SPECIAL";
+ return if $self->{'subs_done'}{$$gv}++;
+ return if class($gv->CV) eq "SPECIAL";
$self->todo($gv, $gv->CV, 0);
$self->walk_sub($gv->CV);
} elsif ($op->next->name eq "enterwrite"
or ($op->next->name eq "rv2gv"
and $op->next->next->name eq "enterwrite")) {
- next if $self->{'forms_done'}{$$gv}++;
- next if class($gv->FORM) eq "SPECIAL";
+ return if $self->{'forms_done'}{$$gv}++;
+ return if class($gv->FORM) eq "SPECIAL";
$self->todo($gv, $gv->FORM, 1);
$self->walk_sub($gv->FORM);
}
@@ -378,7 +378,7 @@
while (scalar(@{$self->{'subs_todo'}})) {
push @text, $self->next_todo;
}
- print indent(join("", @text)), "\n" if @text;
+ print $self->indent(join("", @text)), "\n" if @text;
}
}
@@ -2252,7 +2252,7 @@
} else {
if (defined $proto and $proto eq "") {
return $kid;
- } elsif ($proto eq "\$") {
+ } elsif (defined $proto and $proto eq '$') {
return $self->maybe_parens_func($kid, $args, $cx, 16);
} elsif ($proto or $simple) {
return $self->maybe_parens_func($kid, $args, $cx, 5);