]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1315, b1316; instability involving -xlp and short max lines
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Feb 2022 15:47:04 +0000 (07:47 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Feb 2022 15:47:04 +0000 (07:47 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm

index d2fd516e502c09adb7633efd5b803a3a70201137..e1d6f06f026860c7a30ec1a53c387da451cdbff5 100644 (file)
@@ -9353,6 +9353,56 @@ WriteMakefile(
 --indent-columns=8
 --maximum-line-length=54
 
+==> b1315.in <==
+# S1
+our %EXPORT_TAGS
+        = (
+   'all' => [
+              qw(
+
+                      )
+   ]
+        );
+
+# S2
+our %EXPORT_TAGS
+        = (
+ 'all' => [
+  qw(
+
+          ) ]
+        );
+
+
+==> b1315.par <==
+--closing-brace-indentation=2
+--continuation-indentation=8
+--extended-line-up-parentheses
+--indent-columns=1
+--maximum-line-length=18
+--stack-closing-square-bracket
+--variable-maximum-line-length
+
+==> b1316.in <==
+# S1
+$garage->add_path(
+           qw( move_car move_LPs move_sofa
+                    hoover_floor wash_floor )
+);
+
+# S2
+$garage->add_path(
+        qw( move_car move_LPs move_sofa
+                 hoover_floor wash_floor ));
+
+==> b1316.par <==
+--continuation-indentation=9
+--delete-old-whitespace
+--extended-line-up-parentheses
+--maximum-line-length=44
+--paren-tightness=2
+--paren-vertical-tightness-closing=2
+
 ==> b140.in <==
 $cmd[ $i ]=[
         $s, $e, $cmd, \@hunk, $i ] ;
index b0c9842435695558ba8f1010ab1f710c1b1217c8..f3193dfaf4b1a0cb5ae6a3278b021cc3c5e0ce7e 100644 (file)
@@ -1666,13 +1666,12 @@ EOM
             $source_object->close_input_file();
         }
 
+        #------------------------------------------------------------------
+        # For string output, store the result to the destination, encoding
+        # if requested. This is a fix for issue git #83 (tidyall issue)
+        #------------------------------------------------------------------
         if ($use_destination_buffer) {
 
-            #------------------------------------------------------------------
-            # For string output, store the result to the destination, encoding
-            # if appropriate. This is a fix for issue git #83 (tidyall issue)
-            #------------------------------------------------------------------
-
             # At this point, all necessary encoding has been done except for
             # output to a string or array ref. We use the -eos flag to decide
             # if we should encode.
index d780160b2588fcb033b9dcd498cfe4013988c8cf..6847946f7aec53a0688f390697d36ef815b5db0b 100644 (file)
@@ -2343,9 +2343,9 @@ EOM
         $rkeep_break_hash->{'('} = 1;
         $rkeep_break_hash->{'['} = 1;
         Warn(<<EOM);
-Sorry, but the format for the -kbb and -kba flags for container tokens is
-changing for consistency with other parameters.  You entered '{' which
-currently matches '{' '(' and '[', but in the future it will only match '{'.
+Sorry, but the format for the -kbb and -kba flags is changing a little.
+You entered '{' which currently matches '{' '(' and '[',
+but in the future it will only match '{'.
 To prevent this message please do one of the following:
   use '{ ( [' if you want to match all opening containers, or
   use '(' or '[' to match just those containers, or
@@ -2361,9 +2361,9 @@ EOM
         $rkeep_break_hash->{'('} = 1;
         $rkeep_break_hash->{'['} = 1;
         Warn(<<EOM);
-Sorry, but the format for the -kbb and -kba flags for container tokens is changing a
-little to allow generalization and for consistency with other parameters.  You entered '}'
-which currently still matches '}' ')' and ']', but in the future it will only match '}'.
+Sorry, but the format for the -kbb and -kba flags is changing a little.
+You entered '}' which currently matches each of '}' ')' and ']',
+but in the future it will only match '}'.
 To prevent this message please do one of the following:
   use '} ) ]' if you want to match all closing containers, or
   use ')' or ']' to match just those containers, or
@@ -10850,7 +10850,9 @@ sub collapsed_lengths {
 
         # Handle an intermediate line of a multiline qw quote. These may
         # require including some -ci or -i spaces.  See cases c098/x063.
-        if ( $K_first == $K_last && $rLL->[$K_first]->[_TYPE_] eq 'q' ) {
+        # Updated to check all lines (not just $K_first==$K_last) to fix b1316
+        my $K_begin_loop = $K_first;
+        if ( $rLL->[$K_first]->[_TYPE_] eq 'q' ) {
 
             my $KK       = $K_first;
             my $level    = $rLL->[$KK]->[_LEVEL_];
@@ -10894,9 +10896,13 @@ sub collapsed_lengths {
 
             if ( $len > $max_prong_len ) { $max_prong_len = $len }
 
-            # We can skip the loop over tokens below
             $last_nonblank_type = 'q';
-            next;
+
+            $K_begin_loop = $K_first + 1;
+
+            # We can skip to the next line if more tokens
+            next if ( $K_begin_loop > $K_last );
+
         }
         $K_start_multiline_qw = undef;
 
@@ -10940,7 +10946,7 @@ sub collapsed_lengths {
         }
 
         # Loop over tokens on this line ...
-        foreach my $KK ( $K_first .. $K_terminal ) {
+        foreach my $KK ( $K_begin_loop .. $K_terminal ) {
 
             my $type = $rLL->[$KK]->[_TYPE_];
             next if ( $type eq 'b' );