]> git.donarmstrong.com Git - perltidy.git/commitdiff
Modify space rule between binary plus or minus and a bareword
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 18 Feb 2021 16:27:37 +0000 (08:27 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 18 Feb 2021 16:27:37 +0000 (08:27 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 77e30990ee364db1825988a9a0472061bbf6c00e..bed33a0dacb22c9b53b64f3668ba95532c4792bf 100644 (file)
@@ -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 =~ /\$$/
index 5d46dcbec050ca618a66cce45b76fc16a3cdb37b..3ff851af039a8fff83516a6966ecafaf658e1e7e 100644 (file)
@@ -2,6 +2,13 @@
 
 =over 4
 
+=item B<Modify space rule between binary plus or minus and a bareword>
+
+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<Do not apply -xci if it would put tokens beyond the maximum line length>
 
 This update fixes cases b899 b935.