]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix rare instability with side comments and -xlp, case b1311
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 3 Feb 2022 15:57:42 +0000 (07:57 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 3 Feb 2022 15:57:42 +0000 (07:57 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 332ad2555c126ba039e4ba80ec242e7b6bc84574..542e0449337cca1820674cdf16d5dcbcf35cc6ec 100644 (file)
@@ -9267,6 +9267,48 @@ isnt(
 --square-bracket-tightness=2
 --variable-maximum-line-length
 
+==> b1311.in <==
+# S1
+WriteMakefile(
+          'NAME'         => 'C4::Search',
+          'VERSION_FROM' => 'Search.pm',    # finds $VERSION
+          'PREREQ_PM'    => {},    # e.g., Module::Name => 1.1
+          (
+             $] >= 5.005
+             ?  ## Add these new keywords supported since 5.005
+             (
+                ABSTRACT_FROM =>
+                'Search.pm',    # retrieve abstract from module
+                AUTHOR => 'Koha Dev Team <info@koha.org>'
+             )
+             : ()
+          ),
+);
+
+# S2
+WriteMakefile(
+        'NAME'         => 'C4::Search',
+        'VERSION_FROM' => 'Search.pm',    # finds $VERSION
+        'PREREQ_PM'    => {},    # e.g., Module::Name => 1.1
+        (
+                $] >= 5.005
+                ? ## Add these new keywords supported since 5.005
+                  (
+                        ABSTRACT_FROM => 'Search.pm'
+                        ,    # retrieve abstract from module
+                        AUTHOR =>
+                          'Koha Dev Team <info@koha.org>'
+                  )
+                : ()
+        ),
+);
+
+==> b1311.par <==
+--extended-continuation-indentation
+--extended-line-up-parentheses
+--indent-columns=8
+--maximum-line-length=63
+
 ==> b140.in <==
 $cmd[ $i ]=[
         $s, $e, $cmd, \@hunk, $i ] ;
index d8abcb38feebe592999260e0d07411ab791a786b..7d920fd11bdf79f9f738884d0b42597233c9625c 100644 (file)
@@ -10758,7 +10758,7 @@ BEGIN {
         _iline_o_               => $i++,
         _K_o_                   => $i++,
         _K_c_                   => $i++,
-        _interrupded_list_rule_ => $i++,
+        _interrupted_list_rule_ => $i++,
     };
 }
 
@@ -10909,7 +10909,7 @@ sub collapsed_lengths {
         }
 
         # Use length to terminal comma if interrupded list rule applies
-        if ( @stack && $stack[-1]->[_interrupded_list_rule_] ) {
+        if ( @stack && $stack[-1]->[_interrupted_list_rule_] ) {
             my $K_c = $stack[-1]->[_K_c_];
             if (
                 defined($K_c)
@@ -10922,18 +10922,19 @@ sub collapsed_lengths {
             {
                 my $Kend = $K_terminal;
 
-                if ( $has_comment
-                    && !$rOpts_ignore_side_comment_lengths )
-                {
-                    $Kend = $K_last;
-                }
+                # This caused an instability in b1311 by making the result
+                # dependent on input.  It is not really necessary because the
+                # comment length is added at the end of the loop.
+                ##if ( $has_comment
+                ##    && !$rOpts_ignore_side_comment_lengths )
+                ##{
+                ##    $Kend = $K_last;
+                ##}
+
                 $len = $rLL->[$Kend]->[_CUMULATIVE_LENGTH_] -
                   $rLL->[ $K_first - 1 ]->[_CUMULATIVE_LENGTH_];
 
                 if ( $len > $max_prong_len ) { $max_prong_len = $len }
-
-                # TODO: if there are no sequence items in the line we could
-                # skip the loop as a minor optimization
             }
         }