From: Steve Hancock Date: Tue, 27 Oct 2020 01:25:07 +0000 (-0700) Subject: fixed several instances of incorrect array indexing X-Git-Tag: 20201001.03~36 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c60f69491ad38adcbc7371d2ea49ad363c2e32e2;p=perltidy.git fixed several instances of incorrect array indexing --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 940db966..c7c22d5a 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -12756,6 +12756,7 @@ sub set_continuation_breaks { # ( $rho_ice * $Qs * $pi * $r_pellet**2 ); # if ( $line_count > 2 + && $i_lowest >= 0 # and we saw a possible break && $i_lowest < $i_test && $i_test > $imax - 2 && $nesting_depth_to_go[$i_begin] > @@ -13760,6 +13761,7 @@ sub set_continuation_breaks { # 4 - always open up if vt=0 # 5 - stable: even for one line blocks if vt=0 if ( !$is_long_term + && $saw_opening_structure && $tokens_to_go[$i_opening] =~ /^[\(\{\[]$/ && $index_before_arrow[ $depth + 1 ] > 0 && !$opening_vertical_tightness{ $tokens_to_go[$i_opening] } @@ -14317,8 +14319,7 @@ sub find_token_starting_list { my $i_opening_minus = $i_opening_paren; my $im1 = $i_opening_paren - 1; my $im2 = $i_opening_paren - 2; - my $im3 = $i_opening_paren - 3; - my $typem1 = $types_to_go[$im1]; + my $typem1 = $im1 >= 0 ? $types_to_go[$im1] : 'b'; my $typem2 = $im2 >= 0 ? $types_to_go[$im2] : 'b'; if ( $typem1 eq ',' || ( $typem1 eq 'b' && $typem2 eq ',' ) ) { diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 866efc11..bd88d804 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,13 @@ =over 4 +=item b + +Several instances of incorrect array indexing were found in testing and fixed. +These each involved incorrectly indexing with index -1. They were found by +placing undefs at the end of arrays. None of these was causing incorrect +formatting but they needed to be fixed. + =item b In stress testing perltidy with the -extrude option, the following test snippet