From: Albert Dvornik Date: Tue, 11 May 1999 13:32:04 +0000 (-0400) Subject: deparse \&func() as \(&func()) for clarity X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c8c62db702b7e7b28e0c00febb0781eff4341baf;p=p5sagit%2Fp5-mst-13.2.git deparse \&func() as \(&func()) for clarity Message-ID: Subject: [PATCH 5.005_56] Deparse and \&func() (was Re: File::Find...) p4raw-id: //depot/perl@3400 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 3abb39a..5543a7b 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); }