diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-08 09:30:31 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-08 09:32:37 -0800 |
commit | 5830412df26e13be3cc236273645cb303514dae6 (patch) | |
tree | 367d8ea9d57eb726238c72f968babb2583886cf6 /dist | |
parent | 81bccfe42ad445b6e06432af7d7657baccd86a50 (diff) | |
download | perl-5830412df26e13be3cc236273645cb303514dae6.tar.gz |
Deparse filetest ops without llafr
Before this commit, (-e $_) + 72 deparsed incorrectly, because it
became -e($_) + 72, equivalent to -e ($_+72).
Concerning the removed comment, it’s more important to produce correct
code than nice-looking code.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/B-Deparse/Deparse.pm | 6 | ||||
-rw-r--r-- | dist/B-Deparse/t/deparse.t | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index 2ca91f6f2a..f400ed736b 100644 --- a/dist/B-Deparse/Deparse.pm +++ b/dist/B-Deparse/Deparse.pm @@ -2034,7 +2034,11 @@ sub ftst { my($op, $cx, $name) = @_; if (class($op) eq "UNOP") { # Genuine '-X' filetests are exempt from the LLAFR, but not - # l?stat(); for the sake of clarity, give'em all parens + # l?stat() + if ($name =~ /^-/) { + (my $kid = $self->deparse($op->first, 16)) =~ s/^\cS//; + return $self->maybe_parens("$name $kid", $cx, 16); + } return $self->maybe_parens_unop($name, $op->first, $cx); } elsif (class($op) =~ /^(SV|PAD)OP$/) { return $self->maybe_parens_func($name, $self->pp_gv($op, 1), $cx, 16); diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index de7b7640f0..820a5efadc 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -862,3 +862,9 @@ CORE::do({}); () = (last 1) + 3; () = (next 1) + 3; () = (redo 1) + 3; +() = (-R $_) + 3; +() = (-W $_) + 3; +() = (-X $_) + 3; +() = (-r $_) + 3; +() = (-w $_) + 3; +() = (-x $_) + 3; |