# 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.
=head1 VERSION
-This man page documents perltidy version 20200619.02
+This man page documents perltidy version 20200822
=head1 BUG REPORTS
<h1>Perltidy Change Log</h1>
+<h2>2020 08 22</h2>
+
+<pre><code>- 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.
+</code></pre>
+
+<p><strong>Please upgrade</strong></p>
+
+<pre><code>- 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.
+</code></pre>
+
<h2>2020 06 19</h2>
<pre><code>- Added support for Switch::Plain syntax, issue git #31.
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents Perl::Tidy version 20200619</p>
+<p>This man page documents Perl::Tidy version 20200822</p>
<h1 id="LICENSE">LICENSE</h1>
<p>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.</p>
+<p>Note that several other parameters accept a list of keywords, including 'sub' (see <a href="#Specifying-Block-Types">"Specifying Block Types"</a>). 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.</p>
+
</dd>
</dl>
print $x /$y;
}</code></pre>
-<p>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.</p>
+<p>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.</p>
<p>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.</p>
<h2 id="Controlling-Vertical-Alignment">Controlling Vertical Alignment</h2>
-<p>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:</p>
+<p>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:</p>
<pre><code> $data = $pkg->new(
PeerAddr => join( ".", @port[ 0 .. 3 ] ),
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents perltidy version 20200619</p>
+<p>This man page documents perltidy version 20200822</p>
<h1 id="BUG-REPORTS">BUG REPORTS</h1>
# Release version must be bumped, and it is probably past time for a
# release anyway.
- $VERSION = '20200619.02';
+ $VERSION = '20200822';
}
sub streamhandle {
# 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 '-' ) {
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 ) = @_;
# 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 ],
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.
=head1 VERSION
-This man page documents Perl::Tidy version 20200619.02
+This man page documents Perl::Tidy version 20200822
=head1 LICENSE
package Perl::Tidy::Debugger;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
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 }
package Perl::Tidy::Diagnostics;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
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;
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()
package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
use File::Basename;
# "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";
use strict;
use warnings;
use Carp;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
my ( $package, $rscalar, $mode ) = @_;
use strict;
use warnings;
use Carp;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
my ( $package, $rarray, $mode ) = @_;
package Perl::Tidy::IndentationItem;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
package Perl::Tidy::LineBuffer;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
package Perl::Tidy::LineSink;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
package Perl::Tidy::LineSource;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
package Perl::Tidy::Logger;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
sub new {
package Perl::Tidy::Tokenizer;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
use Perl::Tidy::LineBuffer;
# 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;
}
# 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;
}
# 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 );
# 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 );
}
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 ?/:
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' )
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 ) =
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 ) =
# 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} =
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;
package Perl::Tidy::VerticalAligner::Alignment;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
{
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};
package Perl::Tidy::VerticalAligner::Line;
use strict;
use warnings;
-our $VERSION = '20200619.02';
+our $VERSION = '20200822';
{