]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix c167
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 24 Dec 2022 00:24:10 +0000 (16:24 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 24 Dec 2022 00:24:10 +0000 (16:24 -0800)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm

index c66da71dcf661e27567e64437ede3b30b038f2ae..1501873863d1faac31fde392c289b5053199e5b8 100644 (file)
@@ -4385,6 +4385,11 @@ EOM
         }
     }
 
+    # Large values of -scl can cause convergence problems, issue c167
+    if ( $rOpts->{'short-concatenation-item-length'} > 12 ) {
+        $rOpts->{'short-concatenation-item-length'} = 12;
+    }
+
     # The freeze-whitespace option is currently a derived option which has its
     # own key
     $rOpts->{'freeze-whitespace'} = !$rOpts->{'add-whitespace'}
index e0178c5db0cb102a21ab912440ff48753fa7d1cb..d0353293e896de0e76d309043882a4fe6d4c0cc6 100644 (file)
@@ -17874,8 +17874,10 @@ sub break_equals {
                 # maximum is large enough that this should never happen.
                 $it_count++;
                 if ( $it_count > $it_count_max ) {
+                    my $KK  = $K_to_go[0];
+                    my $lno = $self->[_rLL_]->[$KK]->[_LINE_INDEX_];
                     DEVEL_MODE && Fault(<<EOM);
-iteration count=$it_count exceeds max=$it_count_max
+iteration count=$it_count exceeds max=$it_count_max, near line $lno
 EOM
                     goto RETURN;
                 }
@@ -17891,8 +17893,10 @@ EOM
                     # each iteration.  An error can only be due to a recent
                     # programming change.  We better stop here.
                     if (DEVEL_MODE) {
+                        my $KK  = $K_to_go[0];
+                        my $lno = $self->[_rLL_]->[$KK]->[_LINE_INDEX_];
                         Fault(
-"Program bug-infinite loop in recombine breakpoints\n"
+"Program bug-infinite loop in recombine breakpoints near line $lno\n"
                         );
                     }
                     $more_to_do = 0;
@@ -18914,6 +18918,10 @@ EOM
         # do not recombine lines with leading '.'
         elsif ( $type_ibeg_2 eq '.' ) {
             my $i_next_nonblank = min( $inext_to_go[$ibeg_2], $iend_2 );
+            my $summed_len_1    = $summed_lengths_to_go[ $iend_1 + 1 ] -
+              $summed_lengths_to_go[$ibeg_1];
+            my $summed_len_2 = $summed_lengths_to_go[ $iend_2 + 1 ] -
+              $summed_lengths_to_go[$ibeg_2];
             return
               unless (
 
@@ -18933,11 +18941,16 @@ EOM
                 # ... or this would strand a short quote , like this
                 #                . "some long quote"
                 #                . "\n";
-
-                || (   $types_to_go[$i_next_nonblank] eq 'Q'
+                || (
+                       $types_to_go[$i_next_nonblank] eq 'Q'
                     && $i_next_nonblank >= $iend_2 - 1
                     && $token_lengths_to_go[$i_next_nonblank] <
-                    $rOpts_short_concatenation_item_length )
+                    $rOpts_short_concatenation_item_length
+
+                    #  additional constraints to fix c167
+                    && (   $types_to_go[$iend_1] ne 'Q'
+                        || $summed_len_2 < $summed_len_1 )
+                )
               );
         }