]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed several instances of incorrect array indexing
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 27 Oct 2020 01:25:07 +0000 (18:25 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 27 Oct 2020 01:25:07 +0000 (18:25 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 940db966adcbf93bbcdc8115bf5f418f3de59e30..c7c22d5aaad4ff65b1237be9d224f1c4a0492137 100644 (file)
@@ -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 ',' ) ) {
index 866efc110f724c206e84ecf010d938bd0aaa4287..bd88d80443b4f4de700dd939aea2e75aa7c2f83d 100644 (file)
@@ -2,6 +2,13 @@
 
 =over 4
 
+=item b<Fixed several uses of undefined variables found in testing>
+
+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<Prevent syntax error by breaking dashed package names>
 
 In stress testing perltidy with the -extrude option, the following test snippet