return;
}
-=pod
-sub do_syntax_check {
- my ( $stream, $flags, $error_redirection ) = @_;
-
- ############################################################
- # This code is not reachable because syntax check is deactivated,
- # but it is retained for reference.
- ############################################################
-
- # We need a named input file for executing perl
- my ( $stream_filename, $is_tmpfile ) = get_stream_as_named_file($stream);
-
- # TODO: Need to add name of file to log somewhere
- # otherwise Perl output is hard to read
- if ( !$stream_filename ) { return $stream_filename, "" }
-
- # We have to quote the filename in case it has unusual characters
- # or spaces. Example: this filename #CM11.pm# gives trouble.
- my $quoted_stream_filename = '"' . $stream_filename . '"';
-
- # Under VMS something like -T will become -t (and an error) so we
- # will put quotes around the flags. Double quotes seem to work on
- # Unix/Windows/VMS, but this may not work on all systems. (Single
- # quotes do not work under Windows). It could become necessary to
- # put double quotes around each flag, such as: -"c" -"T"
- # We may eventually need some system-dependent coding here.
- $flags = '"' . $flags . '"';
-
- # now wish for luck...
- my $msg = qx/perl $flags $quoted_stream_filename $error_redirection/;
-
- if ($is_tmpfile) {
- unlink $stream_filename
- or Perl::Tidy::Die("couldn't unlink stream $stream_filename: $!\n");
- }
- return $stream_filename, $msg;
-}
-=cut
-
1;
}
}
-=pod
- # NOTE: This does not work yet. Version in print-line-of-tokens
- # is Still used until fixed
-
- # compare input/output indentation except for continuation lines
- # (because they have an unknown amount of initial blank space)
- # and lines which are quotes (because they may have been outdented)
- # Note: this test is placed here because we know the continuation flag
- # at this point, which allows us to avoid non-meaningful checks.
- my $structural_indentation_level = $rLL->[$Kfirst]->[_LEVEL_];
- compare_indentation_levels( $guessed_indentation_level,
- $structural_indentation_level )
- unless ( $rLL->[$Kfirst]->[_CI_LEVEL_] > 0
- || $guessed_indentation_level == 0
- && $rLL->[$Kfirst]->[_TYPE_] eq 'Q' );
-=cut
-
# Patch needed for MakeMaker. Do not break a statement
# in which $VERSION may be calculated. See MakeMaker.pm;
# this is based on the coding in it.
return;
}
- # TODO: Move to sub scan_comments
# compare input/output indentation except for continuation lines
# (because they have an unknown amount of initial blank space)
# and lines which are quotes (because they may have been outdented)
- # Note: this test is placed here because we know the continuation flag
- # at this point, which allows us to avoid non-meaningful checks.
my $structural_indentation_level = $rinput_token_array->[0]->[_LEVEL_];
compare_indentation_levels( $guessed_indentation_level,
$structural_indentation_level )
if ( $rOpts_one_line_block_semicolons == 0 ) {
$self->delete_one_line_semicolons( $ri_first, $ri_last );
}
- $self->send_lines_to_vertical_aligner( $ri_first, $ri_last,
- $do_not_pad );
+
+ # The line breaks for this batch of code have been finalized;
+ my $rlines_i;
+ for ( my $n = 0 ; $n < @{$ri_first} ; $n++ ) {
+ push @{$rlines_i}, [ $ri_first->[$n], $ri_last->[$n] ];
+ }
+ my $rcall_hash = {
+ rlines_i => $rlines_i,
+ do_not_pad => $do_not_pad,
+ };
+ $self->send_lines_to_vertical_aligner($rcall_hash);
# Insert any requested blank lines after an opening brace. We have to
# skip back before any side comment to find the terminal token
sub send_lines_to_vertical_aligner {
- my ( $self, $ri_first, $ri_last, $do_not_pad ) = @_;
+ my ( $self, $rcall_hash ) = @_;
+
+ my $do_not_pad = $rcall_hash->{do_not_pad};
+ my $rlines_i = $rcall_hash->{rlines_i};
+ if ( !@{$rlines_i} ) {
+ Fault("Error in send_lines_to_vertical_aligner: no lines");
+ return;
+ }
+ my ( $ri_first, $ri_last );
+ foreach my $rline ( @{$rlines_i} ) {
+ my ( $ibeg, $iend ) = @{$rline};
+ push @{$ri_first}, $ibeg;
+ push @{$ri_last}, $iend;
+ }
my $valign_batch_number = $self->increment_valign_batch_count();
my ( $i_opening, $ri_start, $ri_last, $rindentation_list ) = @_;
+ if ( !@{$ri_last} ) {
+ warning("Error in opening_indentation: no lines");
+ return;
+ }
+
my $nline = $rindentation_list->[0]; # line number of previous lookup
# reset line location if necessary
my @new_lines = @group_lines;
initialize_for_new_group();
- ##my $has_terminal_ternary = $new_lines[-1]->{_is_terminal_ternary};
-
# remove unmatched tokens in all lines
delete_unmatched_tokens( \@new_lines );
# BEFORE this line unless both it and the previous line have side
# comments. This prevents this line from pushing side coments out
# to the right.
- ##elsif ( $new_line->get_jmax() == 1 ) {
elsif ( $new_line->get_jmax() == 1 && !$keep_group_intact ) {
- # There are no matching tokens, so now check side comments:
+ # There are no matching tokens, so now check side comments.
+ # Programming note: accessing arrays with index -1 is
+ # risky in Perl, but we have verified there is at least one
+ # line in the group and that there is at least one field.
my $prev_comment = $group_lines[-1]->get_rfields()->[-1];
my $side_comment = $new_line->get_rfields()->[-1];
my_flush_code() unless ( $side_comment && $prev_comment );
my @seqno_last =
( split /:/, $last_nonblank_seqno_string );
my @seqno_now = ( split /:/, $seqno_string );
- if ( $seqno_now[-1] == $seqno_last[0]
+ if ( @seqno_now
+ && @seqno_last
+ && $seqno_now[-1] == $seqno_last[0]
&& $seqno_now[0] == $seqno_last[-1] )
{