&& $rOpts_continuation_indentation > $rOpts_indent_columns );
# Always ok to change ci for permanently broken containers
- if ( $ris_permanently_broken->{$seqno} ) {
- goto OK;
- }
+ if ( $ris_permanently_broken->{$seqno} ) { }
# Always OK if this list contains a broken sub-container with
# a non-terminal line-ending comma
- if ($has_list_with_lec) { goto OK }
+ elsif ($has_list_with_lec) { }
- # From here on we are considering a single container...
+ # Otherwise, we are considering a single container...
+ else {
- # A single container must have at least 1 line-ending comma:
- next unless ( $rlec_count_by_seqno->{$seqno} );
+ # A single container must have at least 1 line-ending comma:
+ next unless ( $rlec_count_by_seqno->{$seqno} );
- # Since it has a line-ending comma, it will stay broken if the -boc
- # flag is set
- if ($rOpts_break_at_old_comma_breakpoints) { goto OK }
+ my $OK;
- # OK if the container contains multiple fat commas
- # Better: multiple lines with fat commas
- if ( !$rOpts_ignore_old_breakpoints ) {
- my $rtype_count = $rtype_count_by_seqno->{$seqno};
- next unless ($rtype_count);
- my $fat_comma_count = $rtype_count->{'=>'};
- DEBUG_BBX
- && print STDOUT "BBX: fat comma count=$fat_comma_count\n";
- if ( $fat_comma_count && $fat_comma_count >= 2 ) { goto OK }
- }
-
- # The last check we can make is to see if this container could fit on a
- # single line. Use the least possible indentation estimate, ci=0,
- # so we are not subtracting $ci * $rOpts_continuation_indentation from
- # tabulated $maximum_text_length value.
- my $maximum_text_length = $maximum_text_length_at_level[$level];
- my $K_closing = $K_closing_container->{$seqno};
- my $length = $self->cumulative_length_before_K($K_closing) -
- $self->cumulative_length_before_K($KK);
- my $excess_length = $length - $maximum_text_length;
- DEBUG_BBX
- && print STDOUT
+ # Since it has a line-ending comma, it will stay broken if the
+ # -boc flag is set
+ if ($rOpts_break_at_old_comma_breakpoints) { $OK = 1 }
+
+ # OK if the container contains multiple fat commas
+ # Better: multiple lines with fat commas
+ if ( !$OK && !$rOpts_ignore_old_breakpoints ) {
+ my $rtype_count = $rtype_count_by_seqno->{$seqno};
+ next unless ($rtype_count);
+ my $fat_comma_count = $rtype_count->{'=>'};
+ DEBUG_BBX
+ && print STDOUT "BBX: fat comma count=$fat_comma_count\n";
+ if ( $fat_comma_count && $fat_comma_count >= 2 ) { $OK = 1 }
+ }
+
+ # The last check we can make is to see if this container could
+ # fit on a single line. Use the least possible indentation
+ # estimate, ci=0, so we are not subtracting $ci *
+ # $rOpts_continuation_indentation from tabulated
+ # $maximum_text_length value.
+ if ( !$OK ) {
+ my $maximum_text_length = $maximum_text_length_at_level[$level];
+ my $K_closing = $K_closing_container->{$seqno};
+ my $length = $self->cumulative_length_before_K($K_closing) -
+ $self->cumulative_length_before_K($KK);
+ my $excess_length = $length - $maximum_text_length;
+ DEBUG_BBX
+ && print STDOUT
"BBX: excess=$excess_length: maximum_text_length=$maximum_text_length, length=$length, ci=$ci\n";
- # OK if the net container definitely breaks on length
- if ( $excess_length > $length_tol ) {
- DEBUG_BBX
- && print STDOUT "BBX: excess_length=$excess_length\n";
- goto OK;
- }
+ # OK if the net container definitely breaks on length
+ if ( $excess_length > $length_tol ) {
+ $OK = 1;
+ DEBUG_BBX
+ && print STDOUT "BBX: excess_length=$excess_length\n";
+ }
- # Otherwise skip it
- next;
+ # Otherwise skip it
+ else { next }
+ }
+ }
#------------------------------------------------------------
# Part 3: Looks OK: apply -bbx=n and any related -bbxi=n flag
#------------------------------------------------------------
- OK:
-
DEBUG_BBX && print STDOUT "BBX: OK to break\n";
# -bbhbi=n
# a previous side comment should be forgotten. This involves
# checking several rules.
- # Return true to keep old comment location
- # Return false to forget old comment location
+ # Return true to KEEP old comment location
+ # Return false to FORGET old comment location
+ my $KEEP = 1;
+ my $FORGET = 0;
my $rfields = $line->{'rfields'};
my $is_hanging_side_comment = $line->{'is_hanging_side_comment'};
# RULE1: Never forget comment before a hanging side comment
- goto KEEP if ($is_hanging_side_comment);
+ return $KEEP if ($is_hanging_side_comment);
# RULE2: Forget a side comment after a short line difference,
# where 'short line difference' is computed from a formula.
my $short_diff = SC_LONG_LINE_DIFF / ( 1 + $alev_diff * $num5 );
- goto FORGET
+ return $FORGET
if ( $line_diff > $short_diff
|| !$self->[_rOpts_valign_side_comments_] );
# RULE3: Forget a side comment if this line is at lower level and
# ends a block
my $last_sc_level = $self->[_last_side_comment_level_];
- goto FORGET
+ return $FORGET
if ( $level < $last_sc_level
&& $is_closing_block_type{ substr( $rfields->[0], 0, 1 ) } );
# [0, 3, 6], [1, 4, 7], [2, 5, 8], # columns
# [0, 4, 8], [2, 4, 6]
# ) # diagonals
- goto FORGET
+ return $FORGET
if ( $cached_line_type == 2 || $cached_line_type == 4 );
}
# Otherwise, keep it alive
- goto KEEP;
-
- FORGET:
- return 0;
-
- KEEP:
- return 1;
+ return $KEEP;
}
sub align_side_comments {