*.DEBUG
*.ERR
*.LOG
-*.bak
*.ba1
+*.bak
*.log
*.sw?
*.tar.gz
MYMETA.yml
RUNME.sh
RUNME.sh
-blib/
archive/
+blib/
diff.txt
+junk*
local_docs/*.txt
perltidy-*.pl
perltidy.pl
pm_to_blib
tmp*/
-junk*
# Perltidy Change Log
-## 2018 02 20.01
+## 2018 11 16
+
+ - The packaging for this version has changed. The Tidy.pm file has
+ been split into a smaller Tidy.pm file plus supporting modules in the path
+ Perl/Tidy/*.
+
+ - A number of new installation test cases have been added.
+
+ - Fixed RT #126965, in which a ternary operator was misparsed if immediately
+ following a function call without arguments, such as:
+ my $restrict_customer = shift ? 1 : 0;
+
+ - Fixed RT #125012: bug in -mangle --delete-all-comments
+ A needed blank space bareword tokens was being removed when comments were
+ deleted
- Fixed RT #81852: Stacked containers and quoting operators. Quoted words
(qw) delimited by container tokens ('{', '[', '(', '<') are now included in
- Fixed RT #124594, license text desc. changed from 'GPL-2.0+' to 'gpl_2'
- - Numerous installation test snippets have been added.
+ - RT #106493; source code repository is https://github.com/perltidy/perltidy
+
+ - Fixed bug in which a warning about a possible code bug was issued in a
+ script with brace errors.
- added option --notimestamp or -nts to eliminate any time stamps in output
files. This is used to prevent differences in test scripts from causing
stamp on certain closing side comments. We need to avoid this in order
to test this feature in an installation test.
- - The packaging for this version has changed. The Tidy.pm file has
- been split into a smaller Tidy.pm file plus supporting modules in the path
- Perl/Tidy/*.
+ - Fixed bug with the entab option, -et=8, in which the leading space of
+ some lines was was not entabbed. This happened in code which was adjusted
+ for vertical alignment and in hanging side comments. Thanks to Glenn.
+
+ - Fixed RT #127633, undesirable line break after return when -baao flag is set
+
+ - Vertical alignment has been improved in several ways. Thanks especially to
+ Glenn for sending helpful snippets.
+
+ - In many cases, two lines which were previously left unaligned are now
+ aligned.
+
+ OLD:
+ $expect = "1$expect" if $expect =~ /^e/i;
+ $p = "1$p" if defined $p and $p =~ /^e/i;
+
+ NEW:
+ $expect = "1$expect" if $expect =~ /^e/i;
+ $p = "1$p" if defined $p and $p =~ /^e/i;
+
+ - Alignment of the =~ operators has been reactivated.
+
+ OLD:
+ $service_profile =~ s/^\s+|\s+$//g;
+ $host_profile =~ s/^\s+|\s+$//g;
+
+ NEW:
+ $service_profile =~ s/^\s+|\s+$//g;
+ $host_profile =~ s/^\s+|\s+$//g;
+
+ - Alignment of the // operator has been reactivated.
+
+ OLD:
+ is( pop // 7, 7, 'pop // ... works' );
+ is( pop() // 7, 0, 'pop() // ... works' );
+ is( pop @ARGV // 7, 3, 'pop @array // ... works' );
+
+ NEW:
+ is( pop // 7, 7, 'pop // ... works' );
+ is( pop() // 7, 0, 'pop() // ... works' );
+ is( pop @ARGV // 7, 3, 'pop @array // ... works' );
## 2018 02 20
# Welcome to Perltidy!
-Perltidy is a tool to indent and reformat scripts written in Perl5.
+Perltidy is a tool to indent and reformat perl scripts. It can also
+write scripts in html format.
-Documentation can be found on the [Perltidy GitHub page](https://perltidy.github.io/perltidy/)
-and also at the [Perltidy Sourceforge page](http://perltidy.sourceforge.net).
+Perltidy is free software released under the GNU General Public
+License -- please see the included file "COPYING" for details.
+# PREREQUISITES
+
+`perltidy` should work with most standard Perl installations.
+The following modules are not required, but perltidy may use them if
+detected:
+
+ HTML::Entities will be used to encode HTML entities if detected
+ Pod::Html will be used to format pod text
+
+The total disk space needed after removing the installation directory will
+about 2 Mb.
+
+# DOWNLOAD
+
+There are two source distribution files:
+
+- A `.tgz` "tarball", with Unix-style <lf> line endings, and
+- A zip file, `.zip`, with Windows-style <cr><lf> line endings.
+
+In addition, the web site has links to debian and RPM packages.
+
+# INSTALLATION
+
+For most standard installations, the standard Makefile.PL method should work:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+The INSTALL file has additional installation notes, and tells how
+to use perltidy without doing an installation.
+
+# WHAT NEXT
+
+Please see the CHANGES file for notices of any recent updates.
+
+Please see the BUGS file for a list of all known open bugs.
+
+Documentation can be found in the `docs` directory, and it can also be
+found at http://perltidy.sourceforge.net
+
+Reading the brief tutorial should help you use perltidy effectively.
+
+# FEEDBACK / BUG REPORTS
+
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
+
+To report a new bug or problem, use the link on this page .
=head1 VERSION
-This man page documents perltidy version 20180220.01
+This man page documents perltidy version 20181116
=head1 BUG REPORTS
$fh->close();
if ( !@errors ) {
$rstatus->{'TIDY'} = 'OK';
+ $rstatus->{'PC'} = 'TBD';
hitcr("Source OK.");
return;
}
# Release version must be bumped, and it is probably past time for a
# release anyway.
- $VERSION = '20180220.01';
+ $VERSION = '20181116';
}
sub streamhandle {
}
my $get_hash_ref = sub {
- my ($key) = @_;
+ my ($key) = @_;
my $hash_ref = $input_hash{$key};
if ( defined($hash_ref) ) {
unless ( ref($hash_ref) eq 'HASH' ) {
$option_category{$opt} = $category_name[$category];
}
- $category = 11; # HTML
+ $category = 11; # HTML
$option_category{html} = $category_name[$category];
# routine to install and check options
sub find_file_upwards {
my ( $search_dir, $search_file ) = @_;
- $search_dir =~ s{/+$}{};
+ $search_dir =~ s{/+$}{};
$search_file =~ s{^/+}{};
while (1) {
=head1 VERSION
-This man page documents Perl::Tidy version 20180220.01
+This man page documents Perl::Tidy version 20181116
=head1 LICENSE
);
@is_digraph{@q} = (1) x scalar(@q);
- @q = qw( ... **= <<= >>= &&= ||= //= <=> <<~ );
+ @q = qw( ... **= <<= >>= &&= ||= //= <=> <<~ );
@is_trigraph{@q} = (1) x scalar(@q);
@q = qw(
@q = qw(is if unless and or err last next redo return);
@is_if_unless_and_or_last_next_redo_return{@q} = (1) x scalar(@q);
- @q = qw(last next redo return);
+ @q = qw(last next redo return);
@is_last_next_redo_return{@q} = (1) x scalar(@q);
- @q = qw(sort map grep);
+ @q = qw(sort map grep);
@is_sort_map_grep{@q} = (1) x scalar(@q);
- @q = qw(sort map grep eval);
+ @q = qw(sort map grep eval);
@is_sort_map_grep_eval{@q} = (1) x scalar(@q);
- @q = qw(sort map grep eval do);
+ @q = qw(sort map grep eval do);
@is_sort_map_grep_eval_do{@q} = (1) x scalar(@q);
- @q = qw(if unless);
+ @q = qw(if unless);
@is_if_unless{@q} = (1) x scalar(@q);
- @q = qw(and or err);
+ @q = qw(and or err);
@is_and_or{@q} = (1) x scalar(@q);
# Identify certain operators which often occur in chains.
# Checkbutton => 'Transmission checked',
# -variable => \$TRANS
# This usually improves appearance so it seems ok.
- @q = qw(&& || and or : ? . + - * /);
+ @q = qw(&& || and or : ? . + - * /);
@is_chain_operator{@q} = (1) x scalar(@q);
# We can remove semicolons after blocks preceded by these keywords
@ok_to_add_semicolon_for_block_type{@q} = (1) x scalar(@q);
# 'L' is token for opening { at hash key
- @q = qw< L { ( [ >;
+ @q = qw< L { ( [ >;
@is_opening_type{@q} = (1) x scalar(@q);
# 'R' is token for closing } at hash key
- @q = qw< R } ) ] >;
+ @q = qw< R } ) ] >;
@is_closing_type{@q} = (1) x scalar(@q);
- @q = qw< { ( [ >;
+ @q = qw< { ( [ >;
@is_opening_token{@q} = (1) x scalar(@q);
- @q = qw< } ) ] >;
+ @q = qw< } ) ] >;
@is_closing_token{@q} = (1) x scalar(@q);
# Patterns for standardizing matches to block types for regular subs and
my $ws_in_container = sub {
my ($j) = @_;
- my $ws = WS_YES;
+ my $ws = WS_YES;
if ( $j + 1 > $jmax ) { return (WS_NO) }
# Patch to count '-foo' as single token so that
# Insert any essential whitespace between lines
# if last line was normal CODE.
- # Patch for rt #125012: use K_previous_code rather than '_nonblank'
+ # Patch for rt #125012: use K_previous_code rather than '_nonblank'
# because comments may disappear.
my $type_next = $rLL->[$Kfirst]->[_TYPE_];
my $token_next = $rLL->[$Kfirst]->[_TOKEN_];
my $rcopy =
copy_token_as_type( $rtoken_vars, 'q', $part1 );
$store_token->($rcopy);
- $token = $part2;
+ $token = $part2;
$rtoken_vars->[_TOKEN_] = $token;
}
$store_token_and_space->(
$rcopy, $rwhitespace_flags->[$KK] == WS_YES
);
- $token = $part2;
+ $token = $part2;
$rtoken_vars->[_TOKEN_] = $token;
# Second part goes without intermediate blank
my $rLL = $self->{rLL};
my $Klimit = $self->{Klimit};
- my $CODE_type = $rOpts->{'indent-only'} ? 'IO' : "";
+ my $CODE_type = $rOpts->{'indent-only'} ? 'IO' : "";
my $no_internal_newlines = 1 - $rOpts_add_newlines;
if ( !$CODE_type && $no_internal_newlines ) { $CODE_type = 'NIN' }
sub K_previous_code {
- # return the index K of the previous nonblank, non-comment token
+ # return the index K of the previous nonblank, non-comment token
# Call with $KK=undef to start search at the top of the array
my ( $self, $KK, $rLL ) = @_;
my $length_to_opening_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_opening_container->{$seqno};
+ my $KK = $K_opening_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
my $length_to_closing_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_closing_container->{$seqno};
+ my $KK = $K_closing_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
# a block is broken if the input line numbers of the braces differ
# we can only cuddle between broken blocks
- my ($seqno) = @_;
+ my ($seqno) = @_;
my $K_opening = $K_opening_container->{$seqno};
return unless ( defined($K_opening) );
my $K_closing = $K_closing_container->{$seqno};
my $length_to_opening_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_opening_container->{$seqno};
+ my $KK = $K_opening_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
return $lentot;
};
my $length_to_closing_seqno = sub {
my ($seqno) = @_;
- my $KK = $K_closing_container->{$seqno};
+ my $KK = $K_closing_container->{$seqno};
my $lentot = $KK <= 0 ? 0 : $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_];
##my $lentot = $rLL->[$KK]->[_CUMULATIVE_LENGTH_];
return $lentot;
##my $too_close = ($i_test==$max_index_to_go-1);
my $test_position = total_line_length( $i_test, $max_index_to_go );
- my $mll = maximum_line_length($i_test);
+ my $mll = maximum_line_length($i_test);
if (
Warn("unrecognized block type $i after $abbrev, ignoring\n");
}
}
- my $pattern = '(' . join( '|', @words ) . ')$';
+ my $pattern = '(' . join( '|', @words ) . ')$';
my $sub_patterns = "";
if ( $seen{'sub'} ) {
$sub_patterns .= '|' . $SUB_PATTERN;
}
}
$rOpts->{'closing-side-comment-prefix'} = $csc_prefix;
- $closing_side_comment_prefix_pattern = $csc_prefix_pattern;
+ $closing_side_comment_prefix_pattern = $csc_prefix_pattern;
return;
}
BEGIN {
my @q;
- @q = qw(sort grep map);
+ @q = qw(sort grep map);
@is_sort_grep_map{@q} = (1) x scalar(@q);
- @q = qw(for foreach);
+ @q = qw(for foreach);
@is_for_foreach{@q} = (1) x scalar(@q);
}
# If this becomes too much of a problem, we might give up and just clip
# them at zero.
## $levels_to_go[$max_index_to_go] = ( $level > 0 ) ? $level : 0;
- $levels_to_go[$max_index_to_go] = $level;
+ $levels_to_go[$max_index_to_go] = $level;
$nesting_depth_to_go[$max_index_to_go] = ( $slevel >= 0 ) ? $slevel : 0;
# link the non-blank tokens
}
}
- # Fix for rt #125506 Unexpected string formating
- # in which leading space of a terminal quote was removed
- $line =~ s/\s+$//;
+ # Fix for rt #125506 Unexpected string formating
+ # in which leading space of a terminal quote was removed
+ $line =~ s/\s+$//;
$line =~ s/^\s+// unless ($in_continued_quote);
$self->extract_token(0);
# A label can only be used on the next {
if ( $block_type =~ /:$/ ) { $csc_last_label = "" }
$csc_block_label{$type_sequence} = $csc_last_label;
- $csc_last_label = "";
+ $csc_last_label = "";
if ( $accumulating_text_for_block
&& $levels_to_go[$i] == $leading_block_text_level )
my $tok = my $raw_tok = $matching_token_to_go[$i];
- # map similar items
- if ($tok eq '!~') {$tok = '=~'}
+ # map similar items
+ if ( $tok eq '!~' ) { $tok = '=~' }
# make separators in different nesting depths unique
# by appending the nesting depth digit.
)
{
my $valid_flag = 1;
- my $spaces = ( $types_to_go[ $ibeg_next - 1 ] eq 'b' ) ? 1 : 0;
+ my $spaces = ( $types_to_go[ $ibeg_next - 1 ] eq 'b' ) ? 1 : 0;
@{$rvertical_tightness_flags} =
( 2, $spaces, $type_sequence_to_go[$ibeg_next], $valid_flag, );
}
# aligner. Assign qw quotes a value to allow qw opening and closing tokens
# to be treated somewhat like opening and closing tokens for stacking
# tokens by the vertical aligner.
- my ($ii) = @_;
+ my ($ii) = @_;
my $seqno = $type_sequence_to_go[$ii];
if ( $types_to_go[$ii] eq 'q' ) {
my $SEQ_QW = -1;
@is_vertical_alignment_type{@q} = (1) x scalar(@q);
# only align these at end of line
- @q = qw(&& ||);
+ @q = qw(&& ||);
@is_terminal_alignment_type{@q} = (1) x scalar(@q);
# eq and ne were removed from this list to improve alignment chances
$vert_last_nonblank_block_type = '';
# look at each token in this output line..
- my $count=0;
+ my $count = 0;
foreach my $i ( $ibeg .. $iend ) {
my $alignment_type = '';
my $type = $types_to_go[$i];
#--------------------------------------------------------
# patch for =~ operator. We only align this if it
- # is the first operator in a line, and the line is a simple
- # statement. Aligning them within a statement causes
- # interferes with other good alignments.
+ # is the first operator in a line, and the line is a simple
+ # statement. Aligning them within a statement causes
+ # interferes with other good alignments.
#--------------------------------------------------------
if ( $alignment_type eq '=~' ) {
my $terminal_type = $types_to_go[$i_terminal];
# then store the value
#--------------------------------------------------------
$matching_token_to_go[$i] = $alignment_type;
- $count++ if ($alignment_type);
+ $count++ if ($alignment_type);
if ( $type ne 'b' ) {
$vert_last_nonblank_type = $type;
$vert_last_nonblank_token = $token;
sub initialize_bond_strength_hashes {
my @q;
- @q = qw(if unless while until for foreach);
+ @q = qw(if unless while until for foreach);
@is_good_keyword_breakpoint{@q} = (1) x scalar(@q);
- @q = qw(lt gt le ge);
+ @q = qw(lt gt le ge);
@is_lt_gt_le_ge{@q} = (1) x scalar(@q);
#
# The decision about where to break a line depends upon a "bond
$right_bond_strength{'CORE::'} = NO_BREAK;
# breaking AFTER modulus operator is ok:
- @q = qw< % >;
+ @q = qw< % >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.1 * NOMINAL + 0.9 * STRONG ) x scalar(@q);
# Break AFTER weakest math operators + and -
# Make them weaker than * but a bit stronger than '.'
- @q = qw< + - >;
+ @q = qw< + - >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.91 * NOMINAL + 0.09 * WEAK ) x scalar(@q);
# make these a little weaker than nominal so that they get
# favored for end-of-line characters
- @q = qw< != == =~ !~ ~~ !~~ >;
+ @q = qw< != == =~ !~ ~~ !~~ >;
@left_bond_strength{@q} = (STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.9 * NOMINAL + 0.1 * WEAK ) x scalar(@q);
# break AFTER these
- @q = qw# < > | & >= <= #;
+ @q = qw# < > | & >= <= #;
@left_bond_strength{@q} = (VERY_STRONG) x scalar(@q);
@right_bond_strength{@q} =
( 0.8 * NOMINAL + 0.2 * WEAK ) x scalar(@q);
# section.
if ( !defined($bsr) ) { $bsr = VERY_STRONG }
if ( !defined($bsl) ) { $bsl = VERY_STRONG }
- my $bond_str = ( $bsr < $bsl ) ? $bsr : $bsl;
+ my $bond_str = ( $bsr < $bsl ) ? $bsr : $bsl;
my $bond_str_1 = $bond_str;
#---------------------------------------------------------------
elsif ( defined( $bias{$left_key} ) ) {
if ( !$want_break_before{$left_key} ) {
$bias{$left_key} += $delta_bias;
- $bond_str += $bias{$left_key};
+ $bond_str += $bias{$left_key};
}
}
\$do_not_break_apart,
$must_break_open,
);
- $bp_count = $forced_breakpoint_count - $fbc;
+ $bp_count = $forced_breakpoint_count - $fbc;
$do_not_break_apart = 0 if $must_break_open;
}
}
# set breaks for any unfinished lists ..
for ( my $dd = $current_depth ; $dd >= $minimum_depth ; $dd-- ) {
- $interrupted_list[$dd] = 1;
+ $interrupted_list[$dd] = 1;
$has_broken_sublist[$dd] = 1 if ( $dd < $current_depth );
set_comma_breakpoints($dd);
set_logical_breakpoints($dd)
# )
# if $style eq 'all';
- my $i_last_comma = $rcomma_index->[ $comma_count - 1 ];
+ my $i_last_comma = $rcomma_index->[ $comma_count - 1 ];
my $long_last_term = excess_line_length( 0, $i_last_comma ) <= 0;
my $long_first_term =
excess_line_length( $i_first_comma + 1, $max_index_to_go ) <= 0;
BEGIN {
my @q;
- @q = qw( && || );
+ @q = qw( && || );
@is_amp_amp{@q} = (1) x scalar(@q);
- @q = qw( ? : );
+ @q = qw( ? : );
@is_ternary{@q} = (1) x scalar(@q);
- @q = qw( + - * / );
+ @q = qw( + - * / );
@is_math_op{@q} = (1) x scalar(@q);
- @q = qw( + - );
+ @q = qw( + - );
@is_plus_minus{@q} = (1) x scalar(@q);
- @q = qw( * / );
+ @q = qw( * / );
@is_mult_div{@q} = (1) x scalar(@q);
}
# and the rest of the loop to do the join
if ($skip_Section_3) {
$forced_breakpoint_to_go[$iend_1] = 0;
- $n_best = $n;
+ $n_best = $n;
last;
}
my $type = $types_to_go[$ii];
# For now, a good break is either a comma or,
- # in a long chain, a 'return'.
- # Patch for RT #126633: added the $nmax>1 check to avoid
- # breaking after a return for a simple ternary. For longer
- # chains the break after return allows vertical alignment, so
- # it is still done. So perltidy -wba='?' will not break
- # immediately after the return in the following statement:
- # sub x {
- # return 0 ? 'aaaaaaaaaaaaaaaaaaaaa' :
- # 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
- # }
+ # in a long chain, a 'return'.
+ # Patch for RT #126633: added the $nmax>1 check to avoid
+ # breaking after a return for a simple ternary. For longer
+ # chains the break after return allows vertical alignment, so
+ # it is still done. So perltidy -wba='?' will not break
+ # immediately after the return in the following statement:
+ # sub x {
+ # return 0 ? 'aaaaaaaaaaaaaaaaaaaaa' :
+ # 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
+ # }
if (
(
$type eq ','
# what we do here but we'll guess that the old run used 4 spaces per level.
my $indent_columns = $tokenizer_self->{_indent_columns};
$indent_columns = 4 if ( !$indent_columns );
- $level = int( $spaces / $indent_columns );
+ $level = int( $spaces / $indent_columns );
return ($level);
}
# ------------------------------------------------------------
my %is_for_foreach;
- @_ = qw(for foreach);
+ @_ = qw(for foreach);
@is_for_foreach{@_} = (1) x scalar(@_);
my %is_my_our;
- @_ = qw(my our);
+ @_ = qw(my our);
@is_my_our{@_} = (1) x scalar(@_);
# These keywords may introduce blocks after parenthesized expressions,
'/' => sub {
my $is_pattern;
- # a pattern cannot follow certain keywords which take optional
- # arguments, like 'shift' and 'pop'. See also '?'.
+ # a pattern cannot follow certain keywords which take optional
+ # arguments, like 'shift' and 'pop'. See also '?'.
if ( $last_nonblank_type eq 'k'
&& $is_keyword_taking_optional_args{$last_nonblank_token} )
{
my $is_pattern;
# Patch for rt #126965
- # a pattern cannot follow certain keywords which take optional
- # arguments, like 'shift' and 'pop'. See also '/'.
+ # a pattern cannot follow certain keywords which take optional
+ # arguments, like 'shift' and 'pop'. See also '/'.
if ( $last_nonblank_type eq 'k'
&& $is_keyword_taking_optional_args{$last_nonblank_token} )
{
@is_zero_continuation_block_type{@_} = (1) x scalar(@_);
my %is_not_zero_continuation_block_type;
- @_ = qw(sort grep map do eval);
+ @_ = qw(sort grep map do eval);
@is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
my %is_logical_container;
@is_logical_container{@_} = (1) x scalar(@_);
my %is_binary_type;
- @_ = qw(|| &&);
+ @_ = qw(|| &&);
@is_binary_type{@_} = (1) x scalar(@_);
my %is_binary_keyword;
- @_ = qw(and or err eq ne cmp);
+ @_ = qw(and or err eq ne cmp);
@is_binary_keyword{@_} = (1) x scalar(@_);
# 'L' is token for opening { at hash key
my %is_opening_type;
- @_ = qw< L { ( [ >;
+ @_ = qw< L { ( [ >;
@is_opening_type{@_} = (1) x scalar(@_);
# 'R' is token for closing } at hash key
my %is_closing_type;
- @_ = qw< R } ) ] >;
+ @_ = qw< R } ) ] >;
@is_closing_type{@_} = (1) x scalar(@_);
my %is_redo_last_next_goto;
- @_ = qw(redo last next goto);
+ @_ = qw(redo last next goto);
@is_redo_last_next_goto{@_} = (1) x scalar(@_);
my %is_use_require;
- @_ = qw(use require);
+ @_ = qw(use require);
@is_use_require{@_} = (1) x scalar(@_);
my %is_sub_package;
- @_ = qw(sub package);
+ @_ = qw(sub package);
@is_sub_package{@_} = (1) x scalar(@_);
# This hash holds the hash key in $tokenizer_self for these keywords:
#
# -----------------------------------------------------------------------
- my $line_of_tokens = shift;
+ my $line_of_tokens = shift;
my ($untrimmed_input_line) = $line_of_tokens->{_line_text};
# patch while coding change is underway
my $str = $rtokens->[$i];
my $saw_modifier_e;
while ( $str =~ /\G$allowed_quote_modifiers/gc ) {
- my $pos = pos($str);
+ my $pos = pos($str);
my $char = substr( $str, $pos - 1, 1 );
$saw_modifier_e ||= ( $char eq 'e' );
}
if ( $nested_ternary_flag[ $current_depth[$aa] - 1 ] == 0 ) {
my $pdepth = $total_depth[$aa][ $current_depth[$aa] - 1 ];
if ( $pdepth == $total_depth - 1 ) {
- $indent = 1;
+ $indent = 1;
$nested_ternary_flag[ $current_depth[$aa] - 1 ] = -1;
}
}
}
}
$nested_statement_type[$aa][ $current_depth[$aa] ] = $statement_type;
- $statement_type = "";
+ $statement_type = "";
return ( $seqno, $indent );
}
$package =~ s/::$//;
my $pos = pos($input_line);
my $numc = $pos - $pos_beg;
- $tok = 'package ' . substr( $input_line, $pos_beg, $numc );
+ $tok = 'package ' . substr( $input_line, $pos_beg, $numc );
$type = 'i';
# Now we must convert back from character position
while ( $i < $max_token_index ) {
$i_save = $i unless ( $tok =~ /^\s*$/ );
- $tok = $rtokens->[ ++$i ];
+ $tok = $rtokens->[ ++$i ];
if ( ( $tok eq ':' ) && ( $rtokens->[ $i + 1 ] eq ':' ) ) {
$tok = '::';
$package =~ s/::$//;
my $pos = pos($input_line);
my $numc = $pos - $pos_beg;
- $tok = 'sub ' . substr( $input_line, $pos_beg, $numc );
+ $tok = 'sub ' . substr( $input_line, $pos_beg, $numc );
$type = 'i';
}
my $pos = pos($input_line);
my $pos_beg = $rtoken_map->[$i];
- my $str = substr( $input_line, $pos_beg, ( $pos - $pos_beg ) );
+ my $str = substr( $input_line, $pos_beg, ( $pos - $pos_beg ) );
# Reject if the closing '>' follows a '-' as in:
# if ( VERSION < 5.009 && $op-> name eq 'assign' ) { }
$pos = pos($input_line);
my $numc = $pos - $pos_beg;
$number = substr( $input_line, $pos_beg, $numc );
- $type = 'v';
+ $type = 'v';
report_v_string($number);
}
$pos = pos($input_line);
my $numc = $pos - $pos_beg;
$number = substr( $input_line, $pos_beg, $numc );
- $type = 'n';
+ $type = 'n';
}
}
}
my $numc = $pos - $pos_beg;
$number = substr( $input_line, $pos_beg, $numc );
- $type = 'n';
+ $type = 'n';
}
}
# these functions have prototypes of the form (&), so when they are
# followed by a block, that block MAY BE followed by an operator.
# Smartmatch operator ~~ may be followed by anonymous hash or array ref
- @q = qw( do eval );
+ @q = qw( do eval );
@is_block_operator{@q} = (1) x scalar(@q);
# these functions allow an identifier in the indirect object slot
- @q = qw( print printf sort exec system say);
+ @q = qw( print printf sort exec system say);
@is_indirect_object_taker{@q} = (1) x scalar(@q);
# These tokens may precede a code block
delete $really_want_term{'Y'}; # indirect object, too risky to check syntax;
# let perl do it
- @q = qw(q qq qw qx qr s y tr m);
+ @q = qw(q qq qw qx qr s y tr m);
@is_q_qq_qw_qx_qr_s_y_tr_m{@q} = (1) x scalar(@q);
# These keywords are handled specially in the tokenizer code:
uc
undef
);
- @is_keyword_taking_optional_args{@keyword_taking_optional_args} =
+ @is_keyword_taking_optional_args{@keyword_taking_optional_args} =
(1) x scalar(@keyword_taking_optional_args);
# These are not used in any way yet
&& $rvertical_tightness_flags->[2] == $cached_seqno )
{
$rvertical_tightness_flags->[3] ||= 1;
- $cached_line_valid ||= 1;
+ $cached_line_valid ||= 1;
}
}
&& $level_jump == 0 )
{
$j_terminal_match = fix_terminal_else( $rfields, $rtokens, $rpatterns );
- $jmax = @{$rfields} - 1;
+ $jmax = @{$rfields} - 1;
}
# --------------------------------------------------------------------
$new_fields[$j] = $current_field;
$new_matching_patterns[$j] = $current_pattern;
- $new_alignments[$j] = $old_line->get_alignment($k);
+ $new_alignments[$j] = $old_line->get_alignment($k);
$maximum_field_index = $j;
$old_line->set_alignments(@new_alignments);
unshift( @patterns, @{$rpatterns_old}[ 0 .. $jquestion ] );
# insert appropriate number of empty fields
- $jadd = $jquestion + 1;
+ $jadd = $jquestion + 1;
$fields[0] = $pad . $fields[0];
splice( @fields, 0, 0, ('') x $jadd ) if $jadd;
}
NO_MATCH:
##print "no match jmax=$jmax max=$maximum_field_index $group_list_type lines=$maximum_line_index token=$old_rtokens->[0]\n";
- # Make one last effort to retain a match of certain statements
- my $match = salvage_equality_matches($new_line, $old_line);
- my_flush() unless($match);
+ # Make one last effort to retain a match of certain statements
+ my $match = salvage_equality_matches( $new_line, $old_line );
+ my_flush() unless ($match);
return;
}
}
# $xpownm1 = $class->_pow( $class->_copy($x), $nm1 ); # x(i)^(n-1)
# We will only do this if there is one old line (and one new line)
- return unless ($maximum_line_index == 0 );
+ return unless ( $maximum_line_index == 0 );
return if ($is_matching_terminal_line);
# We are only looking for equality type statements
# The leading patterns must match
my $old_rpatterns = $old_line->get_rpatterns();
- my $rpatterns = $new_line->get_rpatterns();
- return if ( $old_rpatterns->[0] ne $rpatterns->[0] );
+ my $rpatterns = $new_line->get_rpatterns();
+ return if ( $old_rpatterns->[0] ne $rpatterns->[0] );
# Both should have side comment fields (should always be true)
- my $jmax_old = $old_line->get_jmax();
- my $jmax_new = $new_line->get_jmax();
- my $end_tok_old = $old_rtokens->[$jmax_old-1];
- my $end_tok_new = $rtokens->[$jmax_new-1];
+ my $jmax_old = $old_line->get_jmax();
+ my $jmax_new = $new_line->get_jmax();
+ my $end_tok_old = $old_rtokens->[ $jmax_old - 1 ];
+ my $end_tok_new = $rtokens->[ $jmax_new - 1 ];
my $have_side_comments =
defined($end_tok_old)
&& $end_tok_old eq '#'
# 'unless','||', '&&'. The reason is that (1) this isn't a great match, and
# (2) we will prevent possibly better matchs to follow. Here is an
# example. The match of the first two lines is rejected, and this allows
- # the second and third lines to match.
+ # the second and third lines to match.
# my $type = shift || "o";
# my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
# my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
# This logic can cause some unwanted losses of alignments, but it can retain
- # long runs of multiple-token alignments, so overall it is worthwhile.
- # If we had a peek at the subsequent line we could make a much better
+ # long runs of multiple-token alignments, so overall it is worthwhile.
+ # If we had a peek at the subsequent line we could make a much better
# decision here, but for now this is not available.
- for ( my $j = 1 ; $j < $jmax_new-1 ; $j++ ) {
- my $new_tok = $rtokens->[$j];
+ for ( my $j = 1 ; $j < $jmax_new - 1 ; $j++ ) {
+ my $new_tok = $rtokens->[$j];
my $is_good_alignment = ( $new_tok =~ /^(=|\?|if|unless|\|\||\&\&)/ );
- return if ($is_good_alignment);
+ return if ($is_good_alignment);
}
my $squeeze_line = sub {
$line_obj->{_rtokens} = $rtokens_new;
$line_obj->set_jmax($jmax_new);
};
-
+
# Okay, we will force a match at the equals-like token. We will fix both
# lines to have just 2 tokens and 3 fields:
$squeeze_line->($new_line);
# start over with a new group
initialize_for_new_group();
add_to_group($old_line);
- $current_line = $old_line;
+ $current_line = $old_line;
return 1;
}
# always align lists
!$group_list_type
- # always align lines with leading equality operators
- && !$leading_equals
+ # always align lines with leading equality operators
+ && !$leading_equals
&& (
# don't align two lines with big gap
|| $group_maximum_gap > 12
- # don't align lines with differing number of alignment tokens
+ # don't align lines with differing number of alignment tokens
|| ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen )
)
);
# and eliminate multiple colons might appear to be slow,
# but it's not an issue because we almost never come
# through here. In a typical file we don't.
- $seqno_string =~ s/^:+//;
+ $seqno_string =~ s/^:+//;
$last_nonblank_seqno_string =~ s/^:+//;
- $seqno_string =~ s/:+/:/g;
+ $seqno_string =~ s/:+/:/g;
$last_nonblank_seqno_string =~ s/:+/:/g;
# how many spaces can we outdent?
# Handle entab option
elsif ($rOpts_entab_leading_whitespace) {
- # Patch 12-nov-2018 based on report from Glenn. Extra padding was
- # not correctly entabbed, nor were side comments:
- # Increase leading space count for a padded line to get correct tabbing
+ # Patch 12-nov-2018 based on report from Glenn. Extra padding was
+ # not correctly entabbed, nor were side comments:
+ # Increase leading space count for a padded line to get correct tabbing
if ( $line =~ /^(\s+)(.*)$/ ) {
my $spaces = length($1);
if ( $spaces > $leading_space_count ) {
=head1 Perltidy Change Log
-=head2 2018 02 20.01
+=head2 2018 11 16
- - The packaging for this version has changed. The Tidy.pm file has
- been split into a smaller Tidy.pm file plus supporting modules in the path
- Perl/Tidy/*.
- Fixed RT #126965, in which a ternary operator was misparsed if immediately
following a function call without arguments, such as:
- Fixed RT #124594, license text desc. changed from 'GPL-2.0+' to 'gpl_2'
- - RT #106493; source code repository is https://github.com/perltidy/perltidy
-
- - Numerous installation test snippets have been added.
-
- Fixed bug in which a warning about a possible code bug was issued in a
script with brace errors.
some lines was was not entabbed. This happened in code which was adjusted
for vertical alignment and in hanging side comments. Thanks to Glenn.
- - Vertical alignment has been improved in several ways. Thanks especially to
- Glenn for sending helpful snippets.
+ - Fixed RT #127633, undesirable line break after return when -baao flag is set
+
+ - Fixed RT #127035, vertical alignment. Vertical alignment has been improved
+ in several ways. Thanks especially to Glenn and Michael Wardman for sending
+ helpful snippets.
- In many cases, two lines which were previously left unaligned are now
aligned.
is( pop() // 7, 0, 'pop() // ... works' );
is( pop @ARGV // 7, 3, 'pop @array // ... works' );
+ - RT #106493; source code repository location has been added to docs; it is
+ https://github.com/perltidy/perltidy
+
+ - The packaging for this version has changed. The Tidy.pm module is much
+ smaller. Supporting modules have been split out from it and placed below
+ it in the path Perl/Tidy/*.
+
+ - A number of new installation test cases have been added. Updates are now
+ continuously tested at Travis CI against versions back to Perl 5.08.
+
+
=head2 2018 02 20
- Upload Release to CPAN
- Update CPAN tickets
- Upload release to sourceforge
-- Update web site
+- Update web sites
# VERSION
-This man page documents perltidy version 20180220.01
+This man page documents perltidy version 20181116
# BUG REPORTS
-A list of current bugs and issues can be found at the CPAN site
-
- https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
To report a new bug or problem, use the link on this page.
+The source code repository is at [https://github.com/perltidy/perltidy](https://github.com/perltidy/perltidy).
+
# COPYRIGHT
Copyright (c) 2000-2018 by Steve Hancock