# Perltidy Change Log
-## 2019 06 01
+## 2019 06 01.01
- rt #128477: Prevent inconsistent owner/group and setuid/setgid bits.
In the -b (--backup-and-modify-in-place) mode, an attempt is made to set ownership
=head1 VERSION
-This man page documents perltidy version 20190601
+This man page documents perltidy version 20190601.01
=head1 BUG REPORTS
'V' => \&update_version_number,
'PC' => \&run_perl_critic,
'TIDY' => \&run_tidyall,
+ 'MANIFEST' => \&make_manifest,
'T' => \&make_tests,
'DOCS' => \&make_docs,
- 'MANIFEST' => \&make_manifest,
'DIST' => \&make_dist,
'CL' => sub {openurl($changelog)},
'LOG' => sub { openurl($logfile) },
v - check/update Version Number status: $rstatus->{'V'}
tidy - run tidyall (tidy & critic) status: $rstatus->{'TIDY'}
pc - run PerlCritic (critic only) status: $rstatus->{'PC'}
+manifest - make MANIFEST status: $rstatus->{'MANIFEST'}
t - make Tests status: $rstatus->{'T'}
cl - review/edit CHANGES.md status: $rstatus->{'CL'}
-manifest - make MANIFEST status: $rstatus->{'MANIFEST'}
docs - check and process POD & html status: $rstatus->{'DOCS'}
dist - make a Distribution tar.gz status: $rstatus->{'DIST'}
log - view Log file
return;
}
+sub post_result {
+ my ($fout) = @_;
+
+ # copy contents of a text file to log and display it
+ my $fh;
+ if ( !open( $fh, '<', $fout ) ) {
+ hitcr("Strange: cannot open '$fout': $!.");
+ return;
+ }
+ my @lines = <$fh>;
+ foreach my $line (@lines) { $fh_log->print($line) }
+ $fh->close();
+ openurl("$fout");
+ hitcr();
+ return;
+}
+
sub run_tidyall {
my $fout = "tmp/tidyall.out";
$rstatus->{'TIDY'} = 'TBD';
sub make_manifest {
- # FIXME: show differences between old and new manifest
- my $result = sys_command("make manifest");
- print $result;
+ my $fout = "tmp/manifest.out";
+ my $result = sys_command("make manifest >$fout 2>$fout");
my $status = "OK";
$rstatus->{'MANIFEST'} = $status;
- hitcr();
+ post_result($fout);
return;
}
# Release version must be bumped, and it is probably past time for a
# release anyway.
- $VERSION = '20190601';
+ $VERSION = '20190601.01';
}
sub streamhandle {
=head1 VERSION
-This man page documents Perl::Tidy version 20190601
+This man page documents Perl::Tidy version 20190601.01
=head1 LICENSE
package Perl::Tidy::Debugger;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::DevNull;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new { my $self = shift; return bless {}, $self }
sub print { return }
sub close { return }
package Perl::Tidy::Diagnostics;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::FileWriter;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
# Maximum number of little messages; probably need not be changed.
my $MAX_NAG_MESSAGES = 6;
use strict;
use warnings;
use Carp;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
# The Tokenizer will be loaded with the Formatter
##use Perl::Tidy::Tokenizer; # for is_keyword()
my $ibeg = $ri_first->[$n];
my $iend = $ri_last->[$n];
+ delete_needless_alignments($ibeg, $iend );
+
my ( $rtokens, $rfields, $rpatterns ) =
make_alignment_patterns( $ibeg, $iend );
);
}
+ sub delete_needless_alignments {
+ my ( $ibeg, $iend ) = @_;
+
+ # Remove unwanted paren alignments. Excess alignment of parens
+ # can prevent other good alignments. For example, note the parens in
+ # the first two rows of the following snippet. They would normally get
+ # marked for alignment and aligned as follows:
+
+ # my $w = $columns * $cell_w + ( $columns + 1 ) * $border;
+ # my $h = $rows * $cell_h + ( $rows + 1 ) * $border;
+ # my $img = new Gimp::Image( $w, $h, RGB );
+
+ # This causes unnecessary paren alignment and prevents the third equals
+ # from aligning. If we remove the unwanted alignments we get:
+
+ # my $w = $columns * $cell_w + ( $columns + 1 ) * $border;
+ # my $h = $rows * $cell_h + ( $rows + 1 ) * $border;
+ # my $img = new Gimp::Image( $w, $h, RGB );
+
+ # A rule for doing this which works well is to remove alignment of
+ # parens whose containers do not contain other aligning tokens, with
+ # the exception that we always keep alignment of the first opening
+ # paren on a line (for things like 'if' and 'elsif' statements).
+
+ # First mark a location of a paren we should keep, such as one following
+ # something like a leading 'if', 'elsif',..
+ my $i_good_paren = -1;
+ if ( $iend > $ibeg ) {
+ if ( $types_to_go[$ibeg] eq 'k' ) {
+ $i_good_paren = $ibeg + 1;
+ if ( $types_to_go[$i_good_paren] eq 'b' ) {
+ $i_good_paren++;
+ }
+ }
+ }
+
+ my @imatch_list;
+
+ for my $i ( $ibeg .. $iend ) {
+ if ( $matching_token_to_go[$i] ne '' ) {
+ push @imatch_list, $i;
+
+ }
+ if ( $tokens_to_go[$i] eq ')' ) {
+
+ # undo the corresponding opening paren if:
+ # - it is at the top of the stack
+ # - and not the first overall opening paren
+ # - does not follow a leading keyword on this line
+ my $imate = $mate_index_to_go[$i];
+ if ( @imatch_list
+ && $imatch_list[-1] eq $imate
+ && ( $ibeg > 1 || @imatch_list > 1 )
+ && $imate > $i_good_paren )
+ {
+ $matching_token_to_go[$imate] = '';
+ pop @imatch_list;
+ }
+ }
+ }
+ return;
+ }
+
sub make_alignment_patterns {
# Here we do some important preliminary work for the
package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
use File::Basename;
use strict;
use warnings;
use Carp;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
my ( $package, $rscalar, $mode ) = @_;
use strict;
use warnings;
use Carp;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
my ( $package, $rarray, $mode ) = @_;
package Perl::Tidy::IndentationItem;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::LineBuffer;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::LineSink;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::LineSource;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::Logger;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
sub new {
package Perl::Tidy::Tokenizer;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
use Perl::Tidy::LineBuffer;
package Perl::Tidy::VerticalAligner;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
use Perl::Tidy::VerticalAligner::Alignment;
use Perl::Tidy::VerticalAligner::Line;
package Perl::Tidy::VerticalAligner::Alignment;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
{
package Perl::Tidy::VerticalAligner::Line;
use strict;
use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
{