summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Dvornik <bert@genscan.com>1999-05-11 09:32:04 -0400
committerGurusamy Sarathy <gsar@cpan.org>1999-05-12 10:40:11 +0000
commitc8c62db702b7e7b28e0c00febb0781eff4341baf (patch)
treee59b3117643654550bd3290e5151b68a91d1299b
parent45c0de28763808112fd2f46ea311b6bb0c6050b3 (diff)
downloadperl-c8c62db702b7e7b28e0c00febb0781eff4341baf.tar.gz
deparse \&func() as \(&func()) for clarity
Message-ID: <tqk8ufwm0b.fsf@puma.genscan.com> Subject: [PATCH 5.005_56] Deparse and \&func() (was Re: File::Find...) p4raw-id: //depot/perl@3400
-rw-r--r--ext/B/B/Deparse.pm23
1 files changed, 16 insertions, 7 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index 3abb39a0d1..5543a7b5e1 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -962,13 +962,22 @@ sub pp_refgen {
$kid->sibling->ppaddr eq "pp_anoncode") {
return "sub " .
$self->deparse_sub($self->padval($kid->sibling->targ));
- } elsif ($kid->ppaddr eq "pp_pushmark"
- and $kid->sibling->ppaddr =~ /^pp_(pad|rv2)[ah]v$/
- and not $kid->sibling->flags & OPf_REF) {
- # The @a in \(@a) isn't in ref context, but only when the
- # parens are there.
- return "\\(" . $self->deparse($kid->sibling, 1) . ")";
- }
+ } elsif ($kid->ppaddr eq "pp_pushmark") {
+ my $sib_ppaddr = $kid->sibling->ppaddr;
+ if ($sib_ppaddr =~ /^pp_(pad|rv2)[ah]v$/
+ and not $kid->sibling->flags & OPf_REF)
+ {
+ # The @a in \(@a) isn't in ref context, but only when the
+ # parens are there.
+ return "\\(" . $self->deparse($kid->sibling, 1) . ")";
+ } elsif ($kid->sibling->ppaddr eq 'pp_entersub') {
+ my $text = $self->deparse($kid->sibling, 1);
+ # Always show parens for \(&func()), but only with -p otherwise
+ $text = "($text)" if $self->{'parens'}
+ or $kid->sibling->private & OPpENTERSUB_AMPER;
+ return "\\$text";
+ }
+ }
}
$self->pfixop($op, $cx, "\\", 20);
}