my $iterm = $iter - 1;
if ( $saw_md5{$digest} != $iterm ) {
- # Blinking (oscillating) between two stable
- # end states. This has happened in the past
- # but at present there are no known instances.
+ # Blinking (oscillating) between two or more stable
+ # end states. This is unlikely to occur with normal
+ # parameters, but it can occur in stress testing
+ # with extreme parameter values, such as very short
+ # maximum line lengths. We want to catch and fix
+ # them when they happen.
$convergence_log_message = <<EOM;
BLINKER. Output for iteration $iter same as for $saw_md5{$digest}.
EOM
$rOpts->{'opening-brace-on-new-line'} = 1;
}
-
# it simplifies things if -bl is 0 rather than undefined
if ( !defined( $rOpts->{'opening-brace-on-new-line'} ) ) {
$rOpts->{'opening-brace-on-new-line'} = 0;
$rOpts->{'sub-alias-list'} = join ' ', @filtered_word_list;
}
+ # The freeze-whitespace option is currently a derived option which has its
+ # own key
+ $rOpts->{'freeze-whitespace'} = !$rOpts->{'add-whitespace'}
+ && !$rOpts->{'delete-old-whitespace'};
+
+ # Turn off certain options if whitespace is frozen
+ # Note: vertical alignment will be automatically shut off
+ if ( $rOpts->{'freeze-whitespace'} ) {
+ $rOpts->{'logical-padding'} = 0;
+ }
+
# Define $tabsize, the number of spaces per tab for use in
# guessing the indentation of source lines with leading tabs.
# Assume same as for this run if tabs are used , otherwise assume
$rOpts_indent_only,
$rOpts_static_block_comments,
+ $rOpts_add_whitespace,
+ $rOpts_delete_old_whitespace,
+ $rOpts_freeze_whitespace,
+
# Static hashes initialized in a BEGIN block
%is_assignment,
%is_keyword_returning_list,
$rOpts->{'keep-old-breakpoints-after'} = "";
}
- # Note: These additional parameters are made inactive by -iob.
- # They are silently turned off here because they are on by default.
+ # Note: These additional parameters are made inactive by -iob.
+ # They are silently turned off here because they are on by default.
# We would generate unexpected warnings if we issued a warning.
$rOpts->{'break-at-old-keyword-breakpoints'} = 0;
$rOpts->{'break-at-old-logical-breakpoints'} = 0;
$rOpts_indent_only = $rOpts->{'indent-only'};
$rOpts_static_block_comments = $rOpts->{'static-block-comments'};
+ $rOpts_add_whitespace = $rOpts->{'add-whitespace'};
+ $rOpts_delete_old_whitespace = $rOpts->{'delete-old-whitespace'};
+ $rOpts_freeze_whitespace = $rOpts->{'freeze-whitespace'};
+
# Note that both opening and closing tokens can access the opening
# and closing flags of their container types.
%opening_vertical_tightness = (
# (testfiles prnterr1.t with --extrude and mangle.t with --mangle)
|| $typel eq 'Z'
- # Added 'Y' here 16 Jan 2021 to prevent -mangle option from removing
+ # Added 'Y' here 16 Jan 2021 to prevent -mangle option from removing
# space after type Y. Otherwise, it will get parsed as type 'Z' later
# and any space would have to be added back manually if desired.
|| $typel eq 'Y'
my $CODE_type = "";
my $line_type = "";
- my $rOpts_add_whitespace = $rOpts->{'add-whitespace'};
- my $rOpts_delete_old_whitespace = $rOpts->{'delete-old-whitespace'};
my $rOpts_ignore_side_comment_lengths =
$rOpts->{'ignore-side-comment-lengths'};
# white space BEFORE the token is needed
next if ( $KK >= $Klast ); # skip terminal blank
my $Knext = $KK + 1;
- my $ws = $rwhitespace_flags->[$Knext];
+
+ if ($rOpts_freeze_whitespace) {
+ $store_token->($rtoken_vars);
+ next;
+ }
+
+ my $ws = $rwhitespace_flags->[$Knext];
if ( $ws == -1
|| $rOpts_delete_old_whitespace )
{
next unless ($do_not_delete);
}
- # make it just one character if allowed
- if ($rOpts_add_whitespace) {
- $rtoken_vars->[_TOKEN_] = ' ';
- }
+ # make it just one character
+ $rtoken_vars->[_TOKEN_] = ' ';
$store_token->($rtoken_vars);
next;
}
# RULE: do not weld to a hash brace unless it is preceded by @
if ( $inner_opening->[_TYPE_] eq 'L' ) {
- my $Kp = $self->K_previous_nonblank($Kinner_opening);
+ my $Kp = $self->K_previous_nonblank($Kinner_opening);
next unless ( defined($Kp) && $rLL->[$Kp]->[_TOKEN_] eq '@' );
}
# This is only for list containers
next unless $self->is_list_by_seqno($seqno);
- # and only for broken lists.
+ # and only for broken lists.
# Require container to span 3 or more line to avoid blinkers,
# so line difference must be 2 or more.
next
}
else {
- # Patch for git #51, a bare closing qw paren was not outdented
+ # Patch for git #51, a bare closing qw paren was not outdented
# if the flag '-nodelete-old-newlines is set
my $Kbeg_next = $self->K_next_code($Kend);
if ( defined($Kbeg_next) ) {
- $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
+ $ljump =
+ $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
}
}
my ( $self, $ri_first, $ri_last ) = @_;
my $rspecial_side_comment_type = $self->[_rspecial_side_comment_type_];
- my $rOpts_add_whitespace = $rOpts->{'add-whitespace'};
my $ralignment_type_to_go;
# Initialize the alignment array. Note that closing side comments can