From: Steve Hancock Date: Thu, 18 Feb 2021 16:27:37 +0000 (-0800) Subject: Modify space rule between binary plus or minus and a bareword X-Git-Tag: 20210402~42 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a8564c8a1a36e7fdae06ef69243f1677495df682;p=perltidy.git Modify space rule between binary plus or minus and a bareword --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 77e30990..bed33a0d 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2432,10 +2432,7 @@ EOM # it may turn into a function evaluation, like here # between '&' and 'O_ACCMODE', producing a syntax error [File.pm] # $opts{rdonly} = (($opts{mode} & O_ACCMODE) == O_RDONLY); - # +-: binary plus and minus would get converted into unary - # plus and minus on next pass through the tokenizer. This can - # lead to blinkers: cases b660 b670 b780 b781 b787 b788 b790 - @q = qw( Q & + - ); + @q = qw( Q & ); @is_type_with_space_before_bareword{@q} = (1) x scalar(@q); } @@ -2537,9 +2534,17 @@ EOM # $a = - III; || $tokenl_is_dash && $typer =~ /^[wC]$/ - # keep space between types Q & + - and a bareword + # keep space between types Q & and a bareword || $is_type_with_space_before_bareword{$typel} + # +-: binary plus and minus before a bareword could get + # converted into unary plus and minus on next pass through the + # tokenizer. This can lead to blinkers: cases b660 b670 b780 + # b781 b787 b788 b790 So we keep a space unless the +/- clearly + # follows an operator + || ( ( $typel eq '+' || $typel eq '-' ) + && $typell !~ /^[niC\)\}\]R]$/ ) + # keep a space between a token ending in '$' and any word; # this caused trouble: "die @$ if $@" || $typel eq 'i' && $tokenl =~ /\$$/ diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 5d46dcbe..3ff851af 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,13 @@ =over 4 +=item B + +The update of 13 Feb 2021, cf414fe, has been modified to be less restrictive. +Space between a binary plus and minus and a bareword may now be removed in +some cases where no tokenization ambiguity exists. +18 Feb 2021. + =item B This update fixes cases b899 b935.