]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix a bad line break choice at a slash
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 20 Apr 2021 16:35:38 +0000 (09:35 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 20 Apr 2021 16:35:38 +0000 (09:35 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index ff20d38447f615194790fa9f2444ad44fb59e5c3..3b4fc80574428190b5e6fdfcef5bed0470847659 100644 (file)
@@ -3860,6 +3860,13 @@ EOM
 
             $bond_strength_to_go[$i] = $strength;
 
+            # Fix for case c001: be sure NO_BREAK's are enforced by later
+            # routines, except at a '?' because '?' as quote delimiter is
+            # deprecated.
+            if ( $strength >= NO_BREAK && $next_nonblank_type ne '?' ) {
+                $nobreak_to_go[$i] ||= 1;
+            }
+
             DEBUG_BOND && do {
                 my $str = substr( $token, 0, 15 );
                 $str .= ' ' x ( 16 - length($str) );
index 37b058de640d189444e64438c55684a80d98c1d0..f631a03637a175c172719c8f0a06a671b2b29905 100644 (file)
@@ -2,6 +2,44 @@
 
 =over 4
 
+=item B<Fix a bad line break choice at a slash>
+
+Random testing produced case c001 in which the following snipppet
+
+   ok $mi/(@mtime-1) >= 0.75 && $ai/(@atime-1) >= 0.75 &&
+            $ss/(@mtime+@atime) >= 0.2;
+
+when processed with these parameters
+
+    --maximum-line-length=20
+    --nowant-right-space=' / '
+    --want-break-before='* /'
+
+produced the following result
+
+    ok $mi
+      /( @mtime - 1 ) >=
+      0.75
+      && $ai
+      /( @atime - 1 )
+      >= 0.75
+      && $ss
+      /( @mtime +
+          @atime ) >=
+      0.2;
+
+using 'perl -cw' on this snippet gives a syntax error
+
+    syntax error at /tmp/issues.t line 5, near "/( "
+        (Might be a runaway multi-line // string starting on line 2)
+
+The error is due to perl's weird parsing rules near a possible indrect object.
+This is a situation where perltidy must ignore a user spacing and line break
+request.  This should have been done but in this case a flag to prevent this
+was not being propagated to later stages of formatting.  This has been fixed.
+
+20 Apr 2021.
+
 =item B<Fix rare problem with -lp -wn>
 
 Random testing produced case b1114 which gave unstable formatting with these 
@@ -18,7 +56,7 @@ and this snippet
     is(length(pack("j", 0)),
         $Config{ivsize});
 
-Fixed 19 Apr 2021.
+Fixed 19 Apr 2021, eeeaf09.
 
 =item B<Fix issue git#63>
 
@@ -27,7 +65,7 @@ The following lines produced an error message due to the side comment
     my $fragment = $parser->    #parse_html_string
       parse_balanced_chunk($I);
 
-Fixed 18 Apr 2021.
+Fixed 18 Apr 2021, c2030cf.
 
 =item B<Avoid welding at sort/map/grep paren calls>