develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000330.038] B::Deparse gug isolation

Thread Previous
From:
David Glasser
Date:
March 30, 2000 17:03
Subject:
Re: [ID 20000330.038] B::Deparse gug isolation
Message ID:
l03130301b509a95d75a0@[209.195.241.14]
[I got a bounce message, so apologies if anyone sees this twice.]

>% 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);



Thread Previous


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