From: Steve Hancock Date: Sun, 2 Jun 2019 19:11:07 +0000 (-0700) Subject: bumped version; add delete_needless_paren() X-Git-Tag: 20190915~28 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=48f97e5501551efde5f065f15c04692007c335ce;p=perltidy.git bumped version; add delete_needless_paren() --- diff --git a/CHANGES.md b/CHANGES.md index 54f577f8..8c6fd31e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # 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 diff --git a/bin/perltidy b/bin/perltidy index 032fead7..15a06359 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -3735,7 +3735,7 @@ perlstyle(1), Perl::Tidy(3) =head1 VERSION -This man page documents perltidy version 20190601 +This man page documents perltidy version 20190601.01 =head1 BUG REPORTS diff --git a/dev-bin/build.pl b/dev-bin/build.pl index 416a68f7..50723e15 100755 --- a/dev-bin/build.pl +++ b/dev-bin/build.pl @@ -58,9 +58,9 @@ my $rcode = { '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) }, @@ -83,9 +83,9 @@ chk - view release CHecKlist status: $rstatus->{'CHK'} 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 @@ -119,6 +119,23 @@ sub autopilot { 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'; @@ -240,12 +257,11 @@ sub make_docs { 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; } diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 825b3570..7ee4d1ac 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -109,7 +109,7 @@ BEGIN { # Release version must be bumped, and it is probably past time for a # release anyway. - $VERSION = '20190601'; + $VERSION = '20190601.01'; } sub streamhandle { diff --git a/lib/Perl/Tidy.pod b/lib/Perl/Tidy.pod index 23c8b02b..6c677bc0 100644 --- a/lib/Perl/Tidy.pod +++ b/lib/Perl/Tidy.pod @@ -410,7 +410,7 @@ C in Tidy.pm. =head1 VERSION -This man page documents Perl::Tidy version 20190601 +This man page documents Perl::Tidy version 20190601.01 =head1 LICENSE diff --git a/lib/Perl/Tidy/Debugger.pm b/lib/Perl/Tidy/Debugger.pm index 2fe1bbb0..7a5d60ee 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/DevNull.pm b/lib/Perl/Tidy/DevNull.pm index e755e0c3..d126d3f5 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 = '20190601'; +our $VERSION = '20190601.01'; 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 f2d6ec94..f8175e1b 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index c7b31923..4c6ed7ff 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 = '20190601'; +our $VERSION = '20190601.01'; # 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 9766e25e..0d30a348 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 = '20190601'; +our $VERSION = '20190601.01'; # The Tokenizer will be loaded with the Formatter ##use Perl::Tidy::Tokenizer; # for is_keyword() @@ -9707,6 +9707,8 @@ sub send_lines_to_vertical_aligner { my $ibeg = $ri_first->[$n]; my $iend = $ri_last->[$n]; + delete_needless_alignments($ibeg, $iend ); + my ( $rtokens, $rfields, $rpatterns ) = make_alignment_patterns( $ibeg, $iend ); @@ -9900,6 +9902,69 @@ sub send_lines_to_vertical_aligner { ); } + 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 diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index 0d82978b..72bbf5f6 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 = '20190601'; +our $VERSION = '20190601.01'; use File::Basename; diff --git a/lib/Perl/Tidy/IOScalar.pm b/lib/Perl/Tidy/IOScalar.pm index 2bfb07fb..7c98aafb 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { my ( $package, $rscalar, $mode ) = @_; diff --git a/lib/Perl/Tidy/IOScalarArray.pm b/lib/Perl/Tidy/IOScalarArray.pm index 118f1590..0f152f0e 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { my ( $package, $rarray, $mode ) = @_; diff --git a/lib/Perl/Tidy/IndentationItem.pm b/lib/Perl/Tidy/IndentationItem.pm index b0edd0af..eb1aae6e 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/LineBuffer.pm b/lib/Perl/Tidy/LineBuffer.pm index ade5b2c3..fdd18151 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/LineSink.pm b/lib/Perl/Tidy/LineSink.pm index 98bea19b..2719e7fe 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/LineSource.pm b/lib/Perl/Tidy/LineSource.pm index 5d4ec98c..3b89ca8f 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/Logger.pm b/lib/Perl/Tidy/Logger.pm index 547a635d..1dd31db8 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 = '20190601'; +our $VERSION = '20190601.01'; sub new { diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index c7bc6ff7..a5202893 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 = '20190601'; +our $VERSION = '20190601.01'; use Perl::Tidy::LineBuffer; diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 2ae6e19b..ee490d66 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 = '20190601'; +our $VERSION = '20190601.01'; 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 8732e96e..f61d0c61 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 = '20190601'; +our $VERSION = '20190601.01'; { diff --git a/lib/Perl/Tidy/VerticalAligner/Line.pm b/lib/Perl/Tidy/VerticalAligner/Line.pm index 373896c1..e62ce3e7 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 = '20190601'; +our $VERSION = '20190601.01'; {