From: Steve Hancock Date: Thu, 8 Dec 2022 17:38:00 +0000 (-0800) Subject: eliminate remaining loop labels X-Git-Tag: 20221112.02~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d737ea512d5b22fb92ff432d4d4a276f977602fc;p=perltidy.git eliminate remaining loop labels This update removes the remaining label loops. I prefer to avoid them because they introduce the possibility of subtle bugs. --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 26ac107d..d462f260 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -9260,7 +9260,7 @@ EOM return ( $severe_error, $rqw_lines ); } ## end sub resync_lines_and_tokens -sub check_for_break { +sub check_for_old_break { my ( $self, $KK, $rkeep_break_hash, $rbreak_hash ) = @_; # This sub is called to help implement flags: @@ -9399,9 +9399,9 @@ sub keep_old_line_breaks { foreach my $item ( @{$rKrange_code_without_comments} ) { my ( $Kfirst, $Klast ) = @{$item}; - $self->check_for_break( $Kfirst, \%keep_break_before_type, + $self->check_for_old_break( $Kfirst, \%keep_break_before_type, $rbreak_before_Kfirst ); - $self->check_for_break( $Klast, \%keep_break_after_type, + $self->check_for_old_break( $Klast, \%keep_break_after_type, $rbreak_after_Klast ); } return; @@ -17611,7 +17611,6 @@ sub break_equals { # Loop over all sub-sections. Note that we have to work backwards # from the end of the batch since the sections use original line # numbers, and the line numbers change as we go. - OUTER_LOOP: while ( my $section = pop @{$rsections} ) { my ( $nbeg, $nend ) = @{$section}; @@ -17628,10 +17627,14 @@ sub break_equals { while ($more_to_do) { - # Safety check for excess total iterations + # Emergency return on excess total iterations. The allowed + # maximum is large enough that this should never happen. $it_count++; if ( $it_count > $it_count_max ) { - last OUTER_LOOP; + DEVEL_MODE && Fault(<= $imax ); + last if ( $i_test >= $imax ); # Keep going if we have not reached the limit my $excess = @@ -20037,7 +20041,7 @@ sub break_lines_inner_loop { $maximum_line_length; if ( $excess < 0 ) { - next INNER_LOOP; + next; } elsif ( $excess == 0 ) { @@ -20066,7 +20070,7 @@ sub break_lines_inner_loop { } } else { - next INNER_LOOP; + next; } } else { @@ -20099,7 +20103,7 @@ sub break_lines_inner_loop { DEBUG_BREAK_LINES && do { $Msg .= " :do_not_strand next='$next_nonblank_type'"; }; - next INNER_LOOP; + next; } # Stop if here if we have a solution and the line will be too long @@ -20108,7 +20112,7 @@ sub break_lines_inner_loop { $Msg .= " :Done-too_long && i_lowest=$i_lowest at itest=$i_test, imax=$imax"; }; - last INNER_LOOP; + last; } }