_rstarting_multiline_qw_seqno_by_K_ => $i++,
_rending_multiline_qw_seqno_by_K_ => $i++,
_rKrange_multiline_qw_by_seqno_ => $i++,
-
+ _rcontains_multiline_qw_by_seqno_ => $i++,
};
# Array index names for _this_batch_ (in above list)
$self->[_rstarting_multiline_qw_seqno_by_K_] = {};
$self->[_rending_multiline_qw_seqno_by_K_] = {};
$self->[_rKrange_multiline_qw_by_seqno_] = {};
+ $self->[_rcontains_multiline_qw_by_seqno_] = {};
# This flag will be updated later by a call to get_save_logfile()
$self->[_save_logfile_] = defined($logger_object);
my $rstarting_multiline_qw_seqno_by_K = {};
my $rending_multiline_qw_seqno_by_K = {};
my $rKrange_multiline_qw_by_seqno = {};
+ my $rcontains_multiline_qw_by_seqno = {};
my $rlines = $self->[_rlines_];
my $rLL = $self->[_rLL_];
}
}
}
+
+ # For the -lp option we need to mark all parent containers of
+ # multiline quotes
+ if ($rOpts_line_up_parentheses) {
+
+ while ( my ( $qw_seqno, $rKrange ) =
+ each %{$rKrange_multiline_qw_by_seqno} )
+ {
+ my ( $Kbeg, $Kend ) = @{$rKrange};
+ my $parent_seqno = $self->parent_seqno_by_K($Kend);
+ next unless ($parent_seqno);
+
+ # If the first outer container exactly surrounds this qw, then -lp
+ # formatting seems to work so we will not mark it.
+ my $Kp = $self->K_previous_nonblank($Kbeg) if defined($Kbeg);
+ my $Kn = $self->K_next_nonblank($Kend) if defined($Kend);
+ my $seqno_p = defined($Kp) ? $rLL->[$Kp]->[_TYPE_SEQUENCE_] : undef;
+ my $seqno_n = defined($Kn) ? $rLL->[$Kn]->[_TYPE_SEQUENCE_] : undef;
+ my $is_tightly_contained =
+ defined($seqno_p) && defined($seqno_n) && $seqno_p eq $seqno_n;
+
+ $rcontains_multiline_qw_by_seqno->{$parent_seqno} =
+ !$is_tightly_contained;
+
+ # continue up the tree marking parent containers
+ while (1) {
+ $parent_seqno = $self->[_rparent_of_seqno_]->{$parent_seqno};
+ last
+ unless ( defined($parent_seqno)
+ && $parent_seqno ne SEQ_ROOT );
+ $rcontains_multiline_qw_by_seqno->{$parent_seqno} = 1;
+ }
+ }
+ }
+
$self->[_rstarting_multiline_qw_seqno_by_K_] =
$rstarting_multiline_qw_seqno_by_K;
$self->[_rending_multiline_qw_seqno_by_K_] =
$rending_multiline_qw_seqno_by_K;
$self->[_rKrange_multiline_qw_by_seqno_] = $rKrange_multiline_qw_by_seqno;
+ $self->[_rcontains_multiline_qw_by_seqno_] =
+ $rcontains_multiline_qw_by_seqno;
}
######################################
my $align_paren = 0;
my $excess = 0;
+ my $last_nonblank_seqno;
+ if ( defined($K_last_nonblank) ) {
+ $last_nonblank_seqno =
+ $rLL->[$K_last_nonblank]->[_TYPE_SEQUENCE_];
+ }
+
# initialization on empty stack..
if ( $max_gnu_stack_index == 0 ) {
$space_count = $level * $rOpts_indent_columns;
$space_count += $standard_increment;
}
+ # if this container holds a qw, add the standard increment
+ elsif ($last_nonblank_seqno
+ && $self->[_rcontains_multiline_qw_by_seqno_]
+ ->{$last_nonblank_seqno} )
+ {
+ $space_count += $standard_increment;
+ }
+
# otherwise use the space to the first non-blank level change token
else {