};
# Initialized in check_options. These are constants and could
-# also be initialized in a BEGIN block.
+# just as well be initialized in a BEGIN block.
use vars qw{
%is_do_follower
%is_if_brace_follower
$index_max_forced_break
};
-# Hashes used by the weld-nested option (-wn).
-# These will be moved into $self.
-use vars qw{
- %weld_len_left_closing
- %weld_len_right_closing
- %weld_len_left_opening
- %weld_len_right_opening
-};
-
# Arrays holding the batch of tokens currently being processed.
# These are being moved into the _rbatch_vars_ sub-array of $self.
use vars qw{
$self->[_saw_VERSION_in_this_file_] = !$rOpts->{'pass-version-line'};
$self->[_saw_END_or_DATA_] = 0;
- $self->[_rweld_len_left_closing_] = {}; # weld flags
- $self->[_rweld_len_right_closing_] = {}; # weld flags
- $self->[_rweld_len_left_opening_] = {}; # weld flags
- $self->[_rweld_len_right_opening_] = {}; # weld flags
+ # Hashes which control container welding
+ $self->[_rweld_len_left_closing_] = {};
+ $self->[_rweld_len_right_closing_] = {};
+ $self->[_rweld_len_left_opening_] = {};
+ $self->[_rweld_len_right_opening_] = {};
bless $self, $class;
sub weld_containers {
# do any welding operations
- my $self = shift;
-
- # initialize weld length hashes needed later for checking line lengths.
- # TODO: These should eventually be stored in $self rather than be package
- # vars.
- %weld_len_left_closing = ();
- %weld_len_right_closing = ();
- %weld_len_left_opening = ();
- %weld_len_right_opening = ();
+ my ($self) = @_;
return if ( $rOpts->{'indent-only'} );
return unless ( $rOpts->{'add-newlines'} );
}
sub weld_cuddled_blocks {
- my $self = shift;
+ my ($self) = @_;
+
+ my $rweld_len_right_closing = $self->[_rweld_len_right_closing_];
# This routine implements the -cb flag by finding the appropriate
# closing and opening block braces and welding them together.
my $dlen =
$rLL->[$Kon]->[_CUMULATIVE_LENGTH_] -
$rLL->[ $Ko - 1 ]->[_CUMULATIVE_LENGTH_];
- $weld_len_right_closing{$closing_seqno} = $dlen;
+ $rweld_len_right_closing->{$closing_seqno} = $dlen;
# Set flag that we want to break the next container
# so that the cuddled line is balanced.
}
sub weld_nested_containers {
- my $self = shift;
+ my ($self) = @_;
+
+ my $rweld_len_left_closing = $self->[_rweld_len_left_closing_];
+ my $rweld_len_left_opening = $self->[_rweld_len_left_opening_];
+ my $rweld_len_right_closing = $self->[_rweld_len_right_closing_];
+ my $rweld_len_right_opening = $self->[_rweld_len_right_opening_];
# This routine implements the -wn flag by "welding together"
# the nested closing and opening tokens which were previously
}
- $weld_len_left_closing{$outer_seqno} = $len_close;
- $weld_len_right_opening{$outer_seqno} = $len_open;
+ $rweld_len_left_closing->{$outer_seqno} = $len_close;
+ $rweld_len_right_opening->{$outer_seqno} = $len_open;
$inner_seqno = $outer_seqno;
}
# sweep from outer to inner
foreach my $seqno ( reverse @{$item} ) {
- $weld_len_right_closing{$seqno} =
- $len_close - $weld_len_left_closing{$seqno};
- $weld_len_left_opening{$seqno} =
- $len_open - $weld_len_right_opening{$seqno};
+ $rweld_len_right_closing->{$seqno} =
+ $len_close - $rweld_len_left_closing->{$seqno};
+ $rweld_len_left_opening->{$seqno} =
+ $len_open - $rweld_len_right_opening->{$seqno};
}
}
foreach my $seq ( @{$weld} ) {
print <<EOM;
seq=$seq
- left_opening=$weld_len_left_opening{$seq};
- right_opening=$weld_len_right_opening{$seq};
- left_closing=$weld_len_left_closing{$seq};
- right_closing=$weld_len_right_closing{$seq};
+ left_opening=$rweld_len_left_opening->{$seq};
+ right_opening=$rweld_len_right_opening->{$seq};
+ left_closing=$rweld_len_left_closing->{$seq};
+ right_closing=$rweld_len_right_closing->{$seq};
EOM
}
sub weld_nested_quotes {
my $self = shift;
+ my $rweld_len_left_closing = $self->[_rweld_len_left_closing_];
+ my $rweld_len_right_opening = $self->[_rweld_len_right_opening_];
+
my $rLL = $self->[_rLL_];
return unless ( defined($rLL) && @{$rLL} );
# OK to weld
# FIXME: Are these always correct?
- $weld_len_left_closing{$outer_seqno} = 1;
- $weld_len_right_opening{$outer_seqno} = 2;
+ $rweld_len_left_closing->{$outer_seqno} = 1;
+ $rweld_len_right_opening->{$outer_seqno} = 2;
# QW PATCH 1 (Testing)
# undo CI for welded quotes
my ( $self, $seqno, $type_or_tok ) = @_;
+ my $rweld_len_left_closing = $self->[_rweld_len_left_closing_];
+ my $rweld_len_left_opening = $self->[_rweld_len_left_opening_];
+
# Given the sequence number of a token, and the token or its type,
# return the length of any weld to its left
my $weld_len;
if ($seqno) {
if ( $is_closing_type{$type_or_tok} ) {
- $weld_len = $weld_len_left_closing{$seqno};
+ $weld_len = $rweld_len_left_closing->{$seqno};
}
elsif ( $is_opening_type{$type_or_tok} ) {
- $weld_len = $weld_len_left_opening{$seqno};
+ $weld_len = $rweld_len_left_opening->{$seqno};
}
}
if ( !defined($weld_len) ) { $weld_len = 0 }
my ( $self, $seqno, $type_or_tok ) = @_;
+ my $rweld_len_right_closing = $self->[_rweld_len_right_closing_];
+ my $rweld_len_right_opening = $self->[_rweld_len_right_opening_];
+
# Given the sequence number of a token, and the token or its type,
# return the length of any weld to its right
my $weld_len;
if ($seqno) {
if ( $is_closing_type{$type_or_tok} ) {
- $weld_len = $weld_len_right_closing{$seqno};
+ $weld_len = $rweld_len_right_closing->{$seqno};
}
elsif ( $is_opening_type{$type_or_tok} ) {
- $weld_len = $weld_len_right_opening{$seqno};
+ $weld_len = $rweld_len_right_opening->{$seqno};
}
}
if ( !defined($weld_len) ) { $weld_len = 0 }