# Maximum number of little messages; probably need not be changed.
use constant MAX_NAG_MESSAGES => 6;
- # increment between sequence numbers for each type
- # For example, ?: pairs might have numbers 7,11,15,...
- use constant TYPE_SEQUENCE_INCREMENT => 4;
-
# Initialize constant hashes ...
my @q;
# places to break long lists.
my (
- $block_type, $current_depth,
- $depth, $i,
- $i_last_nonblank_token, $last_colon_sequence_number,
- $last_nonblank_token, $last_nonblank_type,
- $last_nonblank_block_type, $last_old_breakpoint_count,
- $minimum_depth, $next_nonblank_block_type,
- $next_nonblank_token, $next_nonblank_type,
- $old_breakpoint_count, $starting_breakpoint_count,
- $starting_depth, $token,
- $type, $type_sequence,
+ $block_type, $current_depth,
+ $depth, $i,
+ $i_last_nonblank_token, $last_nonblank_token,
+ $last_nonblank_type, $last_nonblank_block_type,
+ $last_old_breakpoint_count, $minimum_depth,
+ $next_nonblank_block_type, $next_nonblank_token,
+ $next_nonblank_type, $old_breakpoint_count,
+ $starting_breakpoint_count, $starting_depth,
+ $token, $type,
+ $type_sequence,
);
my (
$starting_depth = $nesting_depth_to_go[0];
- $block_type = ' ';
- $current_depth = $starting_depth;
- $i = -1;
- $last_colon_sequence_number = -1;
- $last_nonblank_token = ';';
- $last_nonblank_type = ';';
- $last_nonblank_block_type = ' ';
- $last_old_breakpoint_count = 0;
+ $block_type = ' ';
+ $current_depth = $starting_depth;
+ $i = -1;
+ $last_nonblank_token = ';';
+ $last_nonblank_type = ';';
+ $last_nonblank_block_type = ' ';
+ $last_old_breakpoint_count = 0;
$minimum_depth = $current_depth + 1; # forces update in check below
$old_breakpoint_count = 0;
$starting_breakpoint_count = get_forced_breakpoint_count();
my $saw_good_breakpoint;
my $i_line_end = -1;
my $i_line_start = -1;
+ my $i_last_colon = -1;
# loop over all tokens in this batch
while ( ++$i <= $max_index_to_go ) {
# handle any postponed closing breakpoints
if ( $is_closing_sequence_token{$token} ) {
if ( $type eq ':' ) {
- $last_colon_sequence_number = $type_sequence;
+ $i_last_colon = $i;
# retain break at a ':' line break
if ( ( $i == $i_line_start || $i == $i_line_end )
)
{
+ # don't break if # this has a side comment, and
# don't break at a '?' if preceded by ':' on
# this line of previous ?/: pair on this line.
# This is an attempt to preserve a chain of ?/:
- # expressions (elsif2.t). And don't break if
- # this has a side comment.
- $self->set_forced_breakpoint($i)
- unless (
- $type_sequence == (
- $last_colon_sequence_number +
- TYPE_SEQUENCE_INCREMENT
+ # expressions (elsif2.t).
+ if (
+ (
+ $i_last_colon < 0
+ || $parent_seqno_to_go[$i_last_colon] !=
+ $parent_seqno_to_go[$i]
)
- || $tokens_to_go[$max_index_to_go] eq '#'
- );
+ && $tokens_to_go[$max_index_to_go] ne '#'
+ )
+ {
+ $self->set_forced_breakpoint($i);
+ }
$self->set_closing_breakpoint($i);
} ## end if ( $i_colon <= 0 ||...)
} ## end elsif ( $token eq '?' )
=over 4
+=item B<Fix rare problem with formatting nested ternary statements>
+
+This update fixes an extremely rare problem in formatting nested ternary
+statements, illustrated in the following snippet:
+
+ # OLD: There should be a break before the '?' in line 11 here:
+ WriteMakefile(
+ (
+ $PERL_CORE ? ()
+ : (
+ (
+ eval { ExtUtils::MakeMaker->VERSION(6.48) }
+ ? ( MIN_PERL_VERSION => '5.006' )
+ : ()
+ ),
+ (
+ eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (
+ META_MERGE => {
+ #
+ }
+ )
+ : ()
+ ),
+ )
+ ),
+ );
+
+ # NEW: Line 12 correctly begins with a '?'
+ WriteMakefile(
+ (
+ $PERL_CORE ? ()
+ : (
+ (
+ eval { ExtUtils::MakeMaker->VERSION(6.48) }
+ ? ( MIN_PERL_VERSION => '5.006' )
+ : ()
+ ),
+ (
+ eval { ExtUtils::MakeMaker->VERSION(6.46) }
+ ? (
+ META_MERGE => {
+ #
+ }
+ )
+ : ()
+ ),
+ )
+ ),
+ );
+
+This fixes issue c050.
+
+22 Jul 2021.
+
=item B<Fix conflict of -bom and -scp parameters>
Automated testing with random parameters produced a case of instability caused