From 6f219ddb44207e6b90e77fbff6c384cf8a43cb16 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 3 Feb 2022 07:57:42 -0800 Subject: [PATCH] fix rare instability with side comments and -xlp, case b1311 --- dev-bin/run_convergence_tests.pl.data | 42 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 21 +++++++------- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 332ad255..542e0449 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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 ' + ) + : () + ), +); + +# 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 ' + ) + : () + ), +); + +==> 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 ] ; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index d8abcb38..7d920fd1 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 } } -- 2.39.5