]> git.donarmstrong.com Git - perltidy.git/commitdiff
bumped version; add delete_needless_paren()
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 2 Jun 2019 19:11:07 +0000 (12:11 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 2 Jun 2019 19:11:07 +0000 (12:11 -0700)
22 files changed:
CHANGES.md
bin/perltidy
dev-bin/build.pl
lib/Perl/Tidy.pm
lib/Perl/Tidy.pod
lib/Perl/Tidy/Debugger.pm
lib/Perl/Tidy/DevNull.pm
lib/Perl/Tidy/Diagnostics.pm
lib/Perl/Tidy/FileWriter.pm
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/HtmlWriter.pm
lib/Perl/Tidy/IOScalar.pm
lib/Perl/Tidy/IOScalarArray.pm
lib/Perl/Tidy/IndentationItem.pm
lib/Perl/Tidy/LineBuffer.pm
lib/Perl/Tidy/LineSink.pm
lib/Perl/Tidy/LineSource.pm
lib/Perl/Tidy/Logger.pm
lib/Perl/Tidy/Tokenizer.pm
lib/Perl/Tidy/VerticalAligner.pm
lib/Perl/Tidy/VerticalAligner/Alignment.pm
lib/Perl/Tidy/VerticalAligner/Line.pm

index 54f577f8b020be46919cb660c18ca189c298a612..8c6fd31ef9ff2c790d11880fb869e6db2ec3be86 100644 (file)
@@ -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
index 032fead7b29b03b946c08557f98d7b9e3ce0c241..15a063596cab6d69f3815ef07b1d97910ae77d1a 100755 (executable)
@@ -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
 
index 416a68f79efcd82a4e4c5d719bbc047959ad0211..50723e15d921c626d942291190df3622d9dfaab5 100755 (executable)
@@ -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;
 }
 
index 825b3570b25729a1e8daa53697077659307389ea..7ee4d1ac4fe58d0bc37f327321fdc5d518343aa7 100644 (file)
@@ -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 {
index 23c8b02bd102590096795812211ed8bb13e23f5b..6c677bc08b1e2b95c0d912d528baa4585db156cd 100644 (file)
@@ -410,7 +410,7 @@ C<write_debug_entry> in Tidy.pm.
 
 =head1 VERSION
 
-This man page documents Perl::Tidy version 20190601
+This man page documents Perl::Tidy version 20190601.01
 
 =head1 LICENSE
 
index 2fe1bbb07a5ba8694a232f2a3109cae74b4f4975..7a5d60ee1a6a9dbf3c0603866c1a9d3a00064dcb 100644 (file)
@@ -7,7 +7,7 @@
 package Perl::Tidy::Debugger;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index e755e0c307245c2fb3ab6e3332f3eebad7773e93..d126d3f5100f6af44a9da00b584319721be36e09 100644 (file)
@@ -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 }
index f2d6ec94f6b7b31cd7a4e089b92c484ae6e615ca..f8175e1b0c368c77e84a36c42b1cd5eb06fa47ed 100644 (file)
@@ -20,7 +20,7 @@
 package Perl::Tidy::Diagnostics;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index c7b31923eb98a9a9ac0043a305b647e9d3312216..4c6ed7ff92254b4add247c89918c323e5eaaab08 100644 (file)
@@ -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;
index 9766e25ed4ef04250c4df5aac289330e0a108821..0d30a348b3647a81b3921edf6969f3613cf053fb 100644 (file)
@@ -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
index 0d82978ba7039cd21fed041a38f9228d013e67cf..72bbf5f61440c88f938660442d4e6eeb85efc509 100644 (file)
@@ -7,7 +7,7 @@
 package Perl::Tidy::HtmlWriter;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 use File::Basename;
 
index 2bfb07fbaf055f806043a80b0e39f19c9d1143ea..7c98aafbc39ebc135397aea0d604c2cabb5bb552 100644 (file)
@@ -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 ) = @_;
index 118f1590922ebf73496ae6feba15cfabd04d0398..0f152f0e597f9a2c5bc5af88c5762255de2ecfd4 100644 (file)
@@ -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 ) = @_;
index b0edd0afd26ec85c21cc44ad52ec68ae887dac26..eb1aae6e6c19997a9a58d8cfddd57ac23b21a90c 100644 (file)
@@ -8,7 +8,7 @@
 package Perl::Tidy::IndentationItem;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index ade5b2c37b41b60f991ab897bf7822e0d19e39c4..fdd181517595f5ee849fe43c4e9f9d63aa5618dd 100644 (file)
@@ -12,7 +12,7 @@
 package Perl::Tidy::LineBuffer;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index 98bea19bf66baebd7e53fc1e8265ff0fbe51b20f..2719e7fec0165e65c3db3a7239119dc6548417fe 100644 (file)
@@ -8,7 +8,7 @@
 package Perl::Tidy::LineSink;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index 5d4ec98c77bb442f0dfa170333be5ef1f01b3158..3b89ca8f4bbe674cc72e14ca8eb25a2a5286a594 100644 (file)
@@ -8,7 +8,7 @@
 package Perl::Tidy::LineSource;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index 547a635d6ffe6e6001867d1f3de3f8d134de38dc..1dd31db8e2f5e823e064306328e2a75e5adad84e 100644 (file)
@@ -7,7 +7,7 @@
 package Perl::Tidy::Logger;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 sub new {
 
index c7bc6ff7f9b8b0f63b84cc6a3b5bd758aebd31c7..a5202893aec183861f41cccfdc2a33802b32b5d5 100644 (file)
@@ -21,7 +21,7 @@
 package Perl::Tidy::Tokenizer;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 use Perl::Tidy::LineBuffer;
 
index 2ae6e19bab5781dc7abdfd18a423b754c53c8c97..ee490d66dd7ac08074d7cb9fdf3e2ac72154c932 100644 (file)
@@ -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;
index 8732e96e89e7948f86f7de543bd4c1b412c93653..f61d0c61de3319dcb31202b4520556377acfd95b 100644 (file)
@@ -7,7 +7,7 @@
 package Perl::Tidy::VerticalAligner::Alignment;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 {
 
index 373896c1c351ce5c274e9cdd93c83d1bd0a74b8d..e62ce3e777e5a9690126a435cc19fc0e7744814a 100644 (file)
@@ -8,7 +8,7 @@
 package Perl::Tidy::VerticalAligner::Line;
 use strict;
 use warnings;
-our $VERSION = '20190601';
+our $VERSION = '20190601.01';
 
 {