From aa0f13737527705e31431efea636bb5f716fba2b Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 22 Aug 2020 06:15:50 -0700 Subject: [PATCH] changes preparing for next release, v20200822 --- CHANGES.md | 12 +++++-- bin/perltidy | 2 +- docs/ChangeLog.html | 27 +++++++++++++++ docs/Tidy.html | 2 +- docs/perltidy.html | 8 +++-- lib/Perl/Tidy.pm | 26 +++++++-------- lib/Perl/Tidy.pod | 2 +- lib/Perl/Tidy/Debugger.pm | 2 +- lib/Perl/Tidy/DevNull.pm | 2 +- lib/Perl/Tidy/Diagnostics.pm | 2 +- lib/Perl/Tidy/FileWriter.pm | 2 +- lib/Perl/Tidy/Formatter.pm | 2 +- lib/Perl/Tidy/HtmlWriter.pm | 4 +-- lib/Perl/Tidy/IOScalar.pm | 2 +- lib/Perl/Tidy/IOScalarArray.pm | 2 +- lib/Perl/Tidy/IndentationItem.pm | 2 +- lib/Perl/Tidy/LineBuffer.pm | 2 +- lib/Perl/Tidy/LineSink.pm | 2 +- lib/Perl/Tidy/LineSource.pm | 2 +- lib/Perl/Tidy/Logger.pm | 2 +- lib/Perl/Tidy/Tokenizer.pm | 39 ++++++++++++---------- lib/Perl/Tidy/VerticalAligner.pm | 2 +- lib/Perl/Tidy/VerticalAligner/Alignment.pm | 6 ++-- lib/Perl/Tidy/VerticalAligner/Line.pm | 2 +- 24 files changed, 97 insertions(+), 59 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b6ca55c6..a6f86deb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,14 +1,20 @@ # Perltidy Change Log -## 2020 06 19.02 +## 2020 08 22 - - Fix RT #133166, encoding not set for -st + - Fix RT #133166, encoding not set for -st. Also reported as RT #133171 + and git #35. + + This is a significant bug in version 20200616 which can corrupt data if + perltidy is run as a filter on encoded text. +**Please upgrade** - Fix issue RT #133161, perltidy -html was not working on pod - Fix issue git #33, allow control of space after '->' - - Vertical alignment has been improved. + - Vertical alignment has been improved. Numerous minor issues have + been fixed. - Formatting with the -lp option is improved. diff --git a/bin/perltidy b/bin/perltidy index ac6be0c6..8d345f49 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -4054,7 +4054,7 @@ The perltidy binary uses the Perl::Tidy module and is installed when that module =head1 VERSION -This man page documents perltidy version 20200619.02 +This man page documents perltidy version 20200822 =head1 BUG REPORTS diff --git a/docs/ChangeLog.html b/docs/ChangeLog.html index 4149d5f9..609978cc 100644 --- a/docs/ChangeLog.html +++ b/docs/ChangeLog.html @@ -1,5 +1,32 @@

Perltidy Change Log

+

2020 08 22

+ +
- Fix RT #133166, encoding not set for -st.  Also reported as RT #133171
+  and git #35. 
+
+  This is a significant bug in version 20200616 which can corrupt data if
+  perltidy is run as a filter on encoded text.
+
+ +

Please upgrade

+ +
- Fix issue RT #133161, perltidy -html was not working on pod
+
+- Fix issue git #33, allow control of space after '->'
+
+- Vertical alignment has been improved. Numerous minor issues have
+  been fixed.
+
+- Formatting with the -lp option is improved. 
+
+- Fixed issue git #32, misparse of bare 'ref' in ternary
+
+- When --assert-tidy is used and triggers an error, the first difference
+  between input and output files is shown in the error output. This is
+  a partial response to issue git #30.
+
+

2020 06 19

- Added support for Switch::Plain syntax, issue git #31.
diff --git a/docs/Tidy.html b/docs/Tidy.html
index c3501382..b6cf9995 100644
--- a/docs/Tidy.html
+++ b/docs/Tidy.html
@@ -372,7 +372,7 @@
 
 

VERSION

-

This man page documents Perl::Tidy version 20200619

+

This man page documents Perl::Tidy version 20200822

LICENSE

diff --git a/docs/perltidy.html b/docs/perltidy.html index 91e6b0f1..4e33e25f 100644 --- a/docs/perltidy.html +++ b/docs/perltidy.html @@ -330,6 +330,8 @@

will cause the perltidy to treate the words 'method', 'fun', '_sub' and 'M4' to be treated the same as if they were 'sub'. Note that if the alias words are separated by spaces then the string of words should be placed in quotes.

+

Note that several other parameters accept a list of keywords, including 'sub' (see "Specifying Block Types"). You do not need to include any sub aliases in these lists. Just include keyword 'sub' if you wish, and all aliases are automatically included.

+ @@ -858,7 +860,7 @@ print $x /$y; }
-

If formatted in this way, the program will not run (at least with recent versions of perl) because the $x is taken to be a filehandle and / is assumed to start a quote. In a complex program, there might happen to be a / which terminates the multiline quote without a syntax error, allowing the program to run, but incorrectly.

+

If formatted in this way, the program will not run (at least with recent versions of perl) because the $x is taken to be a filehandle and / is assumed to start a quote. In a complex program, there might happen to be a / which terminates the multiline quote without a syntax error, allowing the program to run, but not as intended.

Related issues arise with other binary operator symbols, such as + and -, and in older versions of perl there could be problems with ternary operators. So to avoid changing program behavior, perltidy has the simple rule that whitespace around possible filehandles is left unchanged. Likewise, whitespace around barewords is left unchanged. The reason is that if the barewords are defined in other modules, or in code that has not even been written yet, perltidy will not have seen their prototypes and must treat them cautiously.

@@ -2632,7 +2634,7 @@

Controlling Vertical Alignment

-

Vertical alignment refers to lining up certain symbols in list of consecutive similar lines to improve readability. For example, the "fat commas" are aligned in the following statement:

+

Vertical alignment refers to lining up certain symbols in a list of consecutive similar lines to improve readability. For example, the "fat commas" are aligned in the following statement:

        $data = $pkg->new(
             PeerAddr => join( ".", @port[ 0 .. 3 ] ),   
@@ -3121,7 +3123,7 @@
 
 

VERSION

-

This man page documents perltidy version 20200619

+

This man page documents perltidy version 20200822

BUG REPORTS

diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index d4c6b254..50a8eab3 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -110,7 +110,7 @@ BEGIN { # Release version must be bumped, and it is probably past time for a # release anyway. - $VERSION = '20200619.02'; + $VERSION = '20200822'; } sub streamhandle { @@ -221,8 +221,8 @@ EOM # Case 1: handle encoded data if ($is_encoded_data) { if ( ref($fh) eq 'IO::File' ) { - ## binmode object call not available in older perl versions - ## $fh->binmode(":raw:encoding(UTF-8)"); + ## binmode object call not available in older perl versions + ## $fh->binmode(":raw:encoding(UTF-8)"); binmode $fh, ":raw:encoding(UTF-8)"; } elsif ( $filename eq '-' ) { @@ -1753,7 +1753,7 @@ sub compare_string_buffers { my ( $fho, $fnameo ) = streamhandle( \$bufo, 'r', $is_encoded_data ); return $msg unless ( $fho && $fhi ); # for safety, shouldn't happen my ( $linei, $lineo ); - my ( $counti, $counto ) = ( 0, 0 ); + my ( $counti, $counto ) = ( 0, 0 ); my ( $last_nonblank_line, $last_nonblank_count ) = ( "", 0 ); my $truncate = sub { my ( $str, $lenmax ) = @_; @@ -2358,14 +2358,14 @@ sub generate_options { # if max is undefined, there is no upper limit # Parameters not listed here have defaults %option_range = ( - 'format' => [ 'tidy', 'html', 'user' ], - 'output-line-ending' => [ 'dos', 'win', 'mac', 'unix' ], - 'space-backslash-quote' => [ 0, 2 ], - 'block-brace-tightness' => [ 0, 2 ], - 'keyword-paren-inner-tightness' => [ 0, 2 ], - 'brace-tightness' => [ 0, 2 ], - 'paren-tightness' => [ 0, 2 ], - 'square-bracket-tightness' => [ 0, 2 ], + 'format' => [ 'tidy', 'html', 'user' ], + 'output-line-ending' => [ 'dos', 'win', 'mac', 'unix' ], + 'space-backslash-quote' => [ 0, 2 ], + 'block-brace-tightness' => [ 0, 2 ], + 'keyword-paren-inner-tightness' => [ 0, 2 ], + 'brace-tightness' => [ 0, 2 ], + 'paren-tightness' => [ 0, 2 ], + 'square-bracket-tightness' => [ 0, 2 ], 'block-brace-vertical-tightness' => [ 0, 2 ], 'brace-vertical-tightness' => [ 0, 2 ], @@ -4030,7 +4030,7 @@ sub show_version { print STDOUT <<"EOM"; This is perltidy, v$VERSION -Copyright 2000-2019, Steve Hancock +Copyright 2000-2020, Steve Hancock Perltidy is free software and may be copied under the terms of the GNU General Public License, which is included in the distribution files. diff --git a/lib/Perl/Tidy.pod b/lib/Perl/Tidy.pod index 87d16194..16577ca6 100644 --- a/lib/Perl/Tidy.pod +++ b/lib/Perl/Tidy.pod @@ -432,7 +432,7 @@ The module 'Perl::Tidy' comes with a binary 'perltidy' which is installed when t =head1 VERSION -This man page documents Perl::Tidy version 20200619.02 +This man page documents Perl::Tidy version 20200822 =head1 LICENSE diff --git a/lib/Perl/Tidy/Debugger.pm b/lib/Perl/Tidy/Debugger.pm index e27870d1..e2f21021 100644 --- a/lib/Perl/Tidy/Debugger.pm +++ b/lib/Perl/Tidy/Debugger.pm @@ -7,7 +7,7 @@ package Perl::Tidy::Debugger; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/DevNull.pm b/lib/Perl/Tidy/DevNull.pm index 8f3d27f5..9a10a3c2 100644 --- a/lib/Perl/Tidy/DevNull.pm +++ b/lib/Perl/Tidy/DevNull.pm @@ -7,7 +7,7 @@ package Perl::Tidy::DevNull; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { my $self = shift; return bless {}, $self } sub print { return } sub close { return } diff --git a/lib/Perl/Tidy/Diagnostics.pm b/lib/Perl/Tidy/Diagnostics.pm index 0f5b463d..518fc1af 100644 --- a/lib/Perl/Tidy/Diagnostics.pm +++ b/lib/Perl/Tidy/Diagnostics.pm @@ -20,7 +20,7 @@ package Perl::Tidy::Diagnostics; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index fd4d71f4..e596bcfe 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -7,7 +7,7 @@ package Perl::Tidy::FileWriter; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; # Maximum number of little messages; probably need not be changed. my $MAX_NAG_MESSAGES = 6; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 1466d948..2b882a9b 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -12,7 +12,7 @@ package Perl::Tidy::Formatter; use strict; use warnings; use Carp; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; # The Tokenizer will be loaded with the Formatter ##use Perl::Tidy::Tokenizer; # for is_keyword() diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index bf4a82d1..f422f637 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -7,7 +7,7 @@ package Perl::Tidy::HtmlWriter; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; use File::Basename; @@ -695,7 +695,7 @@ sub pod_to_html { # "header!", "index!", "recurse!", "quiet!", "verbose!" foreach my $kw (qw(podheader podindex podrecurse podquiet podverbose)) { my $kwd = $kw; # allows us to strip 'pod' - if ( $rOpts->{$kw} ) { $kwd =~ s/^pod//; push @args, "--$kwd" } + if ( $rOpts->{$kw} ) { $kwd =~ s/^pod//; push @args, "--$kwd" } elsif ( defined( $rOpts->{$kw} ) ) { $kwd =~ s/^pod//; push @args, "--no$kwd"; diff --git a/lib/Perl/Tidy/IOScalar.pm b/lib/Perl/Tidy/IOScalar.pm index 49264e7f..97b3e8fc 100644 --- a/lib/Perl/Tidy/IOScalar.pm +++ b/lib/Perl/Tidy/IOScalar.pm @@ -10,7 +10,7 @@ package Perl::Tidy::IOScalar; use strict; use warnings; use Carp; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { my ( $package, $rscalar, $mode ) = @_; diff --git a/lib/Perl/Tidy/IOScalarArray.pm b/lib/Perl/Tidy/IOScalarArray.pm index 41e9f9e7..079faf19 100644 --- a/lib/Perl/Tidy/IOScalarArray.pm +++ b/lib/Perl/Tidy/IOScalarArray.pm @@ -14,7 +14,7 @@ package Perl::Tidy::IOScalarArray; use strict; use warnings; use Carp; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { my ( $package, $rarray, $mode ) = @_; diff --git a/lib/Perl/Tidy/IndentationItem.pm b/lib/Perl/Tidy/IndentationItem.pm index aa3dc699..09a28ce3 100644 --- a/lib/Perl/Tidy/IndentationItem.pm +++ b/lib/Perl/Tidy/IndentationItem.pm @@ -8,7 +8,7 @@ package Perl::Tidy::IndentationItem; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/LineBuffer.pm b/lib/Perl/Tidy/LineBuffer.pm index 6f04bf1e..07ceae28 100644 --- a/lib/Perl/Tidy/LineBuffer.pm +++ b/lib/Perl/Tidy/LineBuffer.pm @@ -12,7 +12,7 @@ package Perl::Tidy::LineBuffer; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/LineSink.pm b/lib/Perl/Tidy/LineSink.pm index 0e312a91..e2f6ad8b 100644 --- a/lib/Perl/Tidy/LineSink.pm +++ b/lib/Perl/Tidy/LineSink.pm @@ -8,7 +8,7 @@ package Perl::Tidy::LineSink; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/LineSource.pm b/lib/Perl/Tidy/LineSource.pm index f315ecd7..e5b6e458 100644 --- a/lib/Perl/Tidy/LineSource.pm +++ b/lib/Perl/Tidy/LineSource.pm @@ -8,7 +8,7 @@ package Perl::Tidy::LineSource; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/Logger.pm b/lib/Perl/Tidy/Logger.pm index 23f96658..01002e6e 100644 --- a/lib/Perl/Tidy/Logger.pm +++ b/lib/Perl/Tidy/Logger.pm @@ -7,7 +7,7 @@ package Perl::Tidy::Logger; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; sub new { diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index d329620f..d32cae6e 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -21,7 +21,7 @@ package Perl::Tidy::Tokenizer; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; use Perl::Tidy::LineBuffer; @@ -1826,8 +1826,9 @@ sub prepare_for_a_new_file { # a pattern cannot follow certain keywords which take optional # arguments, like 'shift' and 'pop'. See also '?'. - if ( $last_nonblank_type eq 'k' - && $is_keyword_rejecting_slash_as_pattern_delimiter{$last_nonblank_token} ) + if ( $last_nonblank_type eq 'k' + && $is_keyword_rejecting_slash_as_pattern_delimiter{ + $last_nonblank_token} ) { $is_pattern = 0; } @@ -2063,8 +2064,9 @@ sub prepare_for_a_new_file { # Patch for rt #126965 # a pattern cannot follow certain keywords which take optional # arguments, like 'shift' and 'pop'. See also '/'. - if ( $last_nonblank_type eq 'k' - && $is_keyword_rejecting_question_as_pattern_delimiter{$last_nonblank_token} ) + if ( $last_nonblank_type eq 'k' + && $is_keyword_rejecting_question_as_pattern_delimiter{ + $last_nonblank_token} ) { $is_pattern = 0; } @@ -2418,7 +2420,7 @@ sub prepare_for_a_new_file { # type = 'pp' for pre-increment, '++' for post-increment '++' => sub { - if ( $expecting == TERM ) { $type = 'pp' } + if ( $expecting == TERM ) { $type = 'pp' } elsif ( $expecting == UNKNOWN ) { my ( $next_nonblank_token, $i_next ) = find_next_nonblank_token( $i, $rtokens, $max_token_index ); @@ -2439,7 +2441,7 @@ sub prepare_for_a_new_file { # type = 'mm' for pre-decrement, '--' for post-decrement '--' => sub { - if ( $expecting == TERM ) { $type = 'mm' } + if ( $expecting == TERM ) { $type = 'mm' } elsif ( $expecting == UNKNOWN ) { my ( $next_nonblank_token, $i_next ) = find_next_nonblank_token( $i, $rtokens, $max_token_index ); @@ -2915,8 +2917,8 @@ EOM } my $pre_tok = $rtokens->[$i]; # get the next pre-token my $pre_type = $rtoken_type->[$i]; # and type - $tok = $pre_tok; - $type = $pre_type; # to be modified as necessary + $tok = $pre_tok; + $type = $pre_type; # to be modified as necessary $block_type = ""; # blank for all tokens except code block braces $container_type = ""; # blank for all tokens except some parens $type_sequence = ""; # blank for all tokens except ?/: @@ -4414,15 +4416,16 @@ sub operator_expected { if ( $tok eq '/' && $next_type eq '/' && $last_nonblank_type eq 'k' - && $is_keyword_rejecting_slash_as_pattern_delimiter{$last_nonblank_token} ) + && $is_keyword_rejecting_slash_as_pattern_delimiter{ + $last_nonblank_token} ) { $op_expected = OPERATOR; } - # Patch to allow a ? following 'split' to be a depricated pattern - # delimiter. This patch is coordinated with the omission of split from - # the list %is_keyword_rejecting_question_as_pattern_delimiter. This - # patch will force perltidy to guess. + # Patch to allow a ? following 'split' to be a depricated pattern + # delimiter. This patch is coordinated with the omission of split from + # the list %is_keyword_rejecting_question_as_pattern_delimiter. This + # patch will force perltidy to guess. elsif ($tok eq '?' && $last_nonblank_type eq 'k' && $last_nonblank_token eq 'split' ) @@ -5135,7 +5138,7 @@ sub peek_ahead_for_n_nonblank_pre_tokens { while ( $line = $tokenizer_self->{_line_buffer_object}->peek_ahead( $i++ ) ) { - $line =~ s/^\s*//; # trim leading blanks + $line =~ s/^\s*//; # trim leading blanks next if ( length($line) <= 0 ); # skip blank next if ( $line =~ /^#/ ); # skip comment ( $rpre_tokens, $rmap, $rpre_types ) = @@ -5155,7 +5158,7 @@ sub peek_ahead_for_nonblank_token { while ( $line = $tokenizer_self->{_line_buffer_object}->peek_ahead( $i++ ) ) { - $line =~ s/^\s*//; # trim leading blanks + $line =~ s/^\s*//; # trim leading blanks next if ( length($line) <= 0 ); # skip blank next if ( $line =~ /^#/ ); # skip comment my ( $rtok, $rmap, $rtype ) = @@ -8057,9 +8060,9 @@ BEGIN { # perl functions which may be unary operators. # This list is used to decide if a pattern delimited by slashes, /pattern/, - # can follow one of these keywords. + # can follow one of these keywords. @q = qw( - chomp eof eval fc lc pop shift uc undef + chomp eof eval fc lc pop shift uc undef ); @is_keyword_rejecting_slash_as_pattern_delimiter{@q} = diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index fba89490..c68c2613 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -1,7 +1,7 @@ package Perl::Tidy::VerticalAligner; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; use Perl::Tidy::VerticalAligner::Alignment; use Perl::Tidy::VerticalAligner::Line; diff --git a/lib/Perl/Tidy/VerticalAligner/Alignment.pm b/lib/Perl/Tidy/VerticalAligner/Alignment.pm index f7e1e4e9..1076c68e 100644 --- a/lib/Perl/Tidy/VerticalAligner/Alignment.pm +++ b/lib/Perl/Tidy/VerticalAligner/Alignment.pm @@ -7,7 +7,7 @@ package Perl::Tidy::VerticalAligner::Alignment; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; { @@ -34,13 +34,13 @@ our $VERSION = '20200619.02'; my ( $caller, %arg ) = @_; my $caller_is_obj = ref($caller); my $class = $caller_is_obj || $caller; - my $self = bless {}, $class; + my $self = bless {}, $class; foreach my $key ( keys %default_data ) { my $_key = '_' . $key; if ( exists $arg{$key} ) { $self->{$_key} = $arg{$key} } elsif ($caller_is_obj) { $self->{$_key} = $caller->{$_key} } - else { $self->{$_key} = $default_data{$_key} } + else { $self->{$_key} = $default_data{$_key} } } if ( !defined( $self->{_starting_column} ) ) { $self->{_starting_column} = $self->{_column}; diff --git a/lib/Perl/Tidy/VerticalAligner/Line.pm b/lib/Perl/Tidy/VerticalAligner/Line.pm index d80620a4..539c13af 100644 --- a/lib/Perl/Tidy/VerticalAligner/Line.pm +++ b/lib/Perl/Tidy/VerticalAligner/Line.pm @@ -8,7 +8,7 @@ package Perl::Tidy::VerticalAligner::Line; use strict; use warnings; -our $VERSION = '20200619.02'; +our $VERSION = '20200822'; { -- 2.39.5