From: Steve Hancock Date: Tue, 8 Feb 2022 15:47:04 +0000 (-0800) Subject: fix b1315, b1316; instability involving -xlp and short max lines X-Git-Tag: 20220217~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1584fc2ed4deebeb7d5149d8a271e07477492759;p=perltidy.git fix b1315, b1316; instability involving -xlp and short max lines --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index d2fd516e..e1d6f06f 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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 ] ; diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index b0c98424..f3193dfa 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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. diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index d780160b..6847946f 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2343,9 +2343,9 @@ EOM $rkeep_break_hash->{'('} = 1; $rkeep_break_hash->{'['} = 1; Warn(<{'('} = 1; $rkeep_break_hash->{'['} = 1; Warn(<[$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' );