]> git.donarmstrong.com Git - perltidy.git/commitdiff
new version #, minor alignment updates
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 16 Nov 2018 16:50:12 +0000 (08:50 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 16 Nov 2018 16:50:12 +0000 (08:50 -0800)
20 files changed:
CHANGES.md
MANIFEST
README.md
bin/perltidy
dev-bin/build.pl
docs/ChangeLog.html
docs/Tidy.html
docs/index.html
docs/index.md
docs/perltidy.html
lib/Perl/Tidy.pm
lib/Perl/Tidy.pod
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/Tokenizer.pm
lib/Perl/Tidy/VerticalAligner.pm
lib/Perl/Tidy/VerticalAligner/Alignment.pm
lib/Perl/Tidy/VerticalAligner/Line.pm
local-docs/ChangeLog.pod
local-docs/perltidy.md
t/snippets/README.md

index 0a63fa20bd779aa1e1676b2bc5daf7ec746d2d84..e13c27e900174a3ea3546721e86cb79785389339 100644 (file)
@@ -1,20 +1,14 @@
 # Perltidy Change Log
 
-## 2018 11 16
-
-    - The packaging for this version has changed. The Tidy.pm file has 
-      been split into a smaller Tidy.pm file plus supporting modules in the path
-      Perl/Tidy/*.
-
-    - A number of new installation test cases have been added. 
+## 2018 11 17
 
     - Fixed RT #126965, in which a ternary operator was misparsed if immediately
       following a function call without arguments, such as: 
         my $restrict_customer = shift ? 1 : 0;
 
     - Fixed RT #125012: bug in -mangle --delete-all-comments
-      A needed blank space bareword tokens was being removed when comments were
-      deleted
+      A needed blank space before bareword tokens was being removed when comments 
+      were deleted
 
     - Fixed RT #81852: Stacked containers and quoting operators. Quoted words
       (qw) delimited by container tokens ('{', '[', '(', '<') are now included in
@@ -39,8 +33,6 @@
 
     - Fixed RT #124594, license text desc. changed from 'GPL-2.0+' to 'gpl_2'
 
-    - RT #106493; source code repository is https://github.com/perltidy/perltidy
-
     - Fixed bug in which a warning about a possible code bug was issued in a
       script with brace errors. 
 
 
     - Fixed RT #127633, undesirable line break after return when -baao flag is set
 
-    - Vertical alignment has been improved in several ways.  Thanks especially to
-      Glenn for sending helpful snippets.
-
-      - In many cases, two lines which were previously left unaligned are now
-        aligned. 
-
-          OLD:
-          $expect = "1$expect" if $expect =~ /^e/i;
-          $p = "1$p" if defined $p and $p =~ /^e/i;
-      
-          NEW:
-          $expect = "1$expect" if $expect =~ /^e/i;
-          $p      = "1$p"      if defined $p and $p =~ /^e/i;
+    - Fixed RT #127035, vertical alignment. Vertical alignment has been improved 
+      in several ways.  Thanks especially to Michael Wardman and Glenn for sending 
+      helpful snippets. 
 
       - Alignment of the =~ operators has been reactivated.  
 
           is( pop()     // 7, 0, 'pop() // ... works' );
           is( pop @ARGV // 7, 3, 'pop @array // ... works' );
 
+      - The rules for alignment of just two lines have been adjusted,
+        hopefully to be a little better overall.  In some cases, two 
+        lines which were previously unaligned are now aligned, and vice-versa.
+
+          OLD:
+          $expect = "1$expect" if $expect =~ /^e/i;
+          $p = "1$p" if defined $p and $p =~ /^e/i;
+      
+          NEW:
+          $expect = "1$expect" if $expect =~ /^e/i;
+          $p      = "1$p"      if defined $p and $p =~ /^e/i;
+
+
+    - RT #106493; source code repository location has been added to docs; it is 
+         https://github.com/perltidy/perltidy
+
+    - The packaging for this version has changed. The Tidy.pm module is much 
+      smaller.  Supporting modules have been split out from it and placed below 
+      it in the path Perl/Tidy/*.
+
+    - A number of new installation test cases have been added. Updates are now
+      continuously tested at Travis CI against versions back to Perl 5.08.
+
 ## 2018 02 20
 
     - RT #124469, #124494, perltidy often making empty files.  The previous had
index 14ddbccfcfc7d7629b5c095a263cbb9ae4863907..18acd6efe92846bec250df82725f548adf4506da 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,8 +1,16 @@
-_config.yml
 bin/perltidy
 BUGS.md
 CHANGES.md
 COPYING
+docs/ChangeLog.html
+docs/COPYING.txt
+docs/index.html
+docs/index.md
+docs/INSTALL.html
+docs/perltidy.html
+docs/stylekey.html
+docs/Tidy.html
+docs/tutorial.html
 examples/bbtidy.pl
 examples/break_long_quotes.pl
 examples/ex_mp.pl
index fe007b2b00c6cbdd413ea162b3e6fec7f7c9797e..3028be4498a1b0b2b1fcbcd8bca4d6e60c069a23 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Welcome to Perltidy
+# Welcome to Perltidy!
 
 Perltidy is a tool to indent and reformat perl scripts.  It can also
 write scripts in html format.
@@ -6,7 +6,52 @@ write scripts in html format.
 Perltidy is free software released under the GNU General Public
 License -- please see the included file "COPYING" for details.
 
-Documentation can be found at the web site [at GitHub](https://perltidy.github.io/perltidy/) 
-or [at Sourceforge](perltidy.sourceforge.net)
+# PREREQUISITES
 
-A copy of the web site in contained in the docs folder of the distribution.
+`perltidy` should work with most standard Perl installations.
+The following modules are not required, but perltidy may use them if
+detected:
+
+    HTML::Entities  will be used to encode HTML entities if detected
+    Pod::Html will be used to format pod text
+
+The total disk space needed after removing the installation directory will
+about 2 Mb.  
+
+# DOWNLOAD
+
+There are two source distribution files:
+
+- A `.tgz` "tarball", with Unix-style &lt;lf> line endings, and 
+- A zip file, `.zip`, with Windows-style &lt;cr>&lt;lf> line endings.
+
+In addition, the web site has links to debian and RPM packages.
+
+# INSTALLATION
+
+For most standard installations, the standard Makefile.PL method should work:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+The INSTALL file has additional installation notes, and tells how
+to use perltidy without doing an installation.
+
+# WHAT NEXT
+
+Please see the CHANGES file for notices of any recent updates.
+
+Please see the BUGS file for a list of all known open bugs.
+
+Documentation can be found in the `docs` directory, and it can also be 
+found at http://perltidy.sourceforge.net
+
+Reading the brief tutorial should help you use perltidy effectively.  
+
+# FEEDBACK / BUG REPORTS
+
+A list of current bugs and issues can be found at the CPAN site [https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy](https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy)
+
+To report a new bug or problem, use the link on this page .  
index e7cb7e39fec389d0ca53b8288ff16531fdbd0dc8..b562145dbf22c2d0163fcfaaf2d6764f1d395ddb 100755 (executable)
@@ -3461,7 +3461,7 @@ perlstyle(1), Perl::Tidy(3)
 
 =head1 VERSION
 
-This man page documents perltidy version 20181116
+This man page documents perltidy version 20181117
 
 =head1 BUG REPORTS
 
index 69e8b0d1332d59745a7bcec14859b9961526c311..440c8cbdbf011997aa035aa95f14ecf5e77073ef 100755 (executable)
@@ -43,7 +43,7 @@ my $fh_log;
 # These are the main steps, in approximate order, for making a new version
 # Note: Since perl critic is in the .tidyallrc, a separate 'PC' step is not
 # needed
-my $rsteps = [qw( CHK V PC TIDY T CL POD DIST)];
+my $rsteps = [qw( CHK V PC TIDY T CL DOCS DIST)];
 
 my $rstatus = {};
 foreach my $step ( @{$rsteps} ) { $rstatus->{$step} = 'TBD' }
@@ -59,11 +59,12 @@ my $rcode = {
     'PC'   => \&run_perl_critic,
     'TIDY'  => \&run_tidyall,
     'T'    => \&make_tests,
-    'POD'  => \&make_docs,
+    'DOCS'  => \&make_docs,
     'DIST' => \&make_dist,
     'CL'   => sub {openurl($changelog)},
     'LOG'  => sub { openurl($logfile) },
     'DIR'  => sub { openurl("local-docs") },
+    'HTML' => sub { openurl("docs/index.html") },
 };
 
 open( $fh_log, ">", $logfile ) or die "cannot open log file $logfile: $!\n";
@@ -84,10 +85,11 @@ tidy  - run tidyall (tidy & critic)     status: $rstatus->{'TIDY'}
 pc    - run PerlCritic (critic only)    status: $rstatus->{'PC'}
 t     - make Tests                     status: $rstatus->{'T'}
 cl    - review/edit ChangeLog.pod       status: $rstatus->{'CL'}
-pod   - check and process POD docs      status: $rstatus->{'POD'}
+docs  - check and process POD & html    status: $rstatus->{'DOCS'}
 dist  - make a Distribution tar.gz      status: $rstatus->{'DIST'}
 dir   - browse doc files
 log   - view Log file
+html  - view html files
 
 q,x   - eXit
 
@@ -225,14 +227,19 @@ sub make_docs {
         local $" = ') (';
         print "These file(s) had errors: (@errors)\n";
         hitcr("See the log file");
-        $rstatus->{'POD'} = 'TBD';
+        $rstatus->{'DOCS'} = 'TBD';
         return;
     }
 
     # finish up
     my $result = sys_command("(cd local-docs; make)");
     print $result;
-    $rstatus->{'POD'} = $result =~ /Stop\./i ? 'TBD' : 'OK';
+    my $status = $result =~ /Stop\./i ? 'TBD' : 'OK';
+    if ($status eq 'OK') {
+        $result = sys_command("(cd bubba; make)");
+        print $result;
+    }
+    $rstatus->{'DOCS'} = $status;
     hitcr();
     return;
 }
index d11f144ed42ad7e92e465f194bdfacaad4b8797c..cbeb3ea5ed72b559f9a77327b1400425badfd729 100644 (file)
@@ -14,7 +14,7 @@
 <ul id="index">
   <li><a href="#Perltidy-Change-Log">Perltidy Change Log</a>
     <ul>
-      <li><a href="#pod2018-02-20.01">2018 02 20.01</a></li>
+      <li><a href="#pod2018-11-17">2018 11 17</a></li>
       <li><a href="#pod2018-02-20">2018 02 20</a></li>
       <li><a href="#pod2018-02-19">2018 02 19</a></li>
       <li><a href="#pod2018-01-01">2018 01 01</a></li>
 
 <h1 id="Perltidy-Change-Log">Perltidy Change Log</h1>
 
-<h2 id="pod2018-02-20.01">2018 02 20.01</h2>
+<h2 id="pod2018-11-17">2018 11 17</h2>
 
-<pre><code>  - The packaging for this version has changed. The Tidy.pm file has 
-    been split into a smaller Tidy.pm file plus supporting modules in the path
-    Perl/Tidy/*.
-
-  - Fixed RT #126965, in which a ternary operator was misparsed if immediately
+<pre><code>  - Fixed RT #126965, in which a ternary operator was misparsed if immediately
     following a function call without arguments, such as: 
       my $restrict_customer = shift ? 1 : 0;
 
   - Fixed RT #125012: bug in -mangle --delete-all-comments
-    A needed blank space bareword tokens was being removed when comments were
-    deleted
+    A needed blank space before bareword tokens was being removed when comments 
+    were deleted
 
   - Fixed RT #81852: Stacked containers and quoting operators. Quoted words
     (qw) delimited by container tokens (&#39;{&#39;, &#39;[&#39;, &#39;(&#39;, &#39;&lt;&#39;) are now included in
 
   - Fixed RT #124594, license text desc. changed from &#39;GPL-2.0+&#39; to &#39;gpl_2&#39;
 
-  - RT #106493; source code repository is https://github.com/perltidy/perltidy
-
-  - Numerous installation test snippets have been added. 
-
   - Fixed bug in which a warning about a possible code bug was issued in a
     script with brace errors. 
 
     some lines was was not entabbed.  This happened in code which was adjusted
     for vertical alignment and in hanging side comments. Thanks to Glenn.
 
-  - Vertical alignment has been improved in several ways.  Thanks especially to
-    Glenn for sending helpful snippets.
+  - Fixed RT #127633, undesirable line break after return when -baao flag is set
 
-    - In many cases, two lines which were previously left unaligned are now
-      aligned. 
-
-        OLD:
-        $expect = &quot;1$expect&quot; if $expect =~ /^e/i;
-        $p = &quot;1$p&quot; if defined $p and $p =~ /^e/i;
-    
-        NEW:
-        $expect = &quot;1$expect&quot; if $expect =~ /^e/i;
-        $p      = &quot;1$p&quot;      if defined $p and $p =~ /^e/i;
+  - Fixed RT #127035, vertical alignment. Vertical alignment has been improved 
+    in several ways.  Thanks especially to Michael Wardman and Glenn for sending 
+    helpful snippets. 
 
     - Alignment of the =~ operators has been reactivated.  
 
         NEW:
         is( pop       // 7, 7, &#39;pop // ... works&#39; );
         is( pop()     // 7, 0, &#39;pop() // ... works&#39; );
-        is( pop @ARGV // 7, 3, &#39;pop @array // ... works&#39; );</code></pre>
+        is( pop @ARGV // 7, 3, &#39;pop @array // ... works&#39; );
+
+    - The rules for alignment of just two lines have been adjusted,
+      hopefully to be a little better overall.  In some cases, two 
+      lines which were previously unaligned are now aligned, and vice-versa.
+
+        OLD:
+        $expect = &quot;1$expect&quot; if $expect =~ /^e/i;
+        $p = &quot;1$p&quot; if defined $p and $p =~ /^e/i;
+    
+        NEW:
+        $expect = &quot;1$expect&quot; if $expect =~ /^e/i;
+        $p      = &quot;1$p&quot;      if defined $p and $p =~ /^e/i;
+
+
+  - RT #106493; source code repository location has been added to docs; it is 
+       https://github.com/perltidy/perltidy
+
+  - The packaging for this version has changed. The Tidy.pm module is much 
+    smaller.  Supporting modules have been split out from it and placed below 
+    it in the path Perl/Tidy/*.
+
+  - A number of new installation test cases have been added. Updates are now
+    continuously tested at Travis CI against versions back to Perl 5.08.</code></pre>
 
 <h2 id="pod2018-02-20">2018 02 20</h2>
 
index e7daa5dd831865f7d0b4ca5826f1547c2bda4cd6..478b6ed65ebfcbd83611759b3ea5d1bef30688e4 100644 (file)
 
 <h1 id="VERSION">VERSION</h1>
 
-<p>This man page documents Perl::Tidy version 20180220.01</p>
+<p>This man page documents Perl::Tidy version 20181117</p>
 
 <h1 id="LICENSE">LICENSE</h1>
 
index 9bfa202f0ea1bd769cb4638ed47c4f19347d6010..a71ef597f070fa46fdbbb619c9042760b96884c0 100644 (file)
@@ -43,7 +43,7 @@ about 2 Mb.</p>
 
 <h2>Installation</h2>
 
-<p>Perl::Tidy can be installed directly from CPAN one of the available methods.</p>
+<p>Perl::Tidy can be installed directly from CPAN one of the standard methods.</p>
 
 <p>One way is to download a distribution file, unpack it and then 
 test and install using the Makefile.PL:</p>
@@ -54,13 +54,14 @@ make test
 make install
 </code></pre>
 
-<p>The <a href="./INSTALL.html">INSTALL file</a> has additional installation notes, and tells how
-to use perltidy without doing an installation.</p>
+<p>The <a href="./INSTALL.html">INSTALL file</a> has additional installation notes. They
+are mainly for older sytems but also tell how to use perltidy without doing an installation.</p>
 
 <h2>Links</h2>
 
 <ul>
 <li><a href="https://github.com/perltidy/perltidy">Perl::Tidy source code repository at GitHub</a></li>
+<li><a href="https://metacpan.org/pod/distribution/Code-TidyAll/bin/tidyall">tidyall</a> is a great tool for automatically running perltidy and other tools including perlcritic on a set of project files.</li>
 <li><a href="http://sourceforge.net/projects/tidyview">Tidyview</a> is a graphical program for tweaking your .perltidyrc configuration parameters.</li>
 <li><a href="https://github.com/vifo/SublimePerlTidy">A perltidy plugin for Sublime Text 2/3</a></li>
 </ul>
index 1652452419a9d2821f3abaad5f36483dfa65efb9..bc3e054b34cd2564d60996c3eba92fa9bc7979a2 100644 (file)
@@ -49,7 +49,7 @@ about 2 Mb.
 
 ## Installation
 
-Perl::Tidy can be installed directly from CPAN one of the available methods.
+Perl::Tidy can be installed directly from CPAN one of the standard methods.
 
 One way is to download a distribution file, unpack it and then 
 test and install using the Makefile.PL:
@@ -59,13 +59,13 @@ test and install using the Makefile.PL:
     make test
     make install
 
-The [INSTALL file](./INSTALL.html) has additional installation notes, and tells how
-to use perltidy without doing an installation.
-
+The [INSTALL file](./INSTALL.html) has additional installation notes. They
+are mainly for older sytems but also tell how to use perltidy without doing an installation.
 
 ## Links
 
  - [Perl::Tidy source code repository at GitHub](https://github.com/perltidy/perltidy)
+ - [tidyall](https://metacpan.org/pod/distribution/Code-TidyAll/bin/tidyall) is a great tool for automatically running perltidy and other tools including perlcritic on a set of project files.
  - [Tidyview](http://sourceforge.net/projects/tidyview) is a graphical program for tweaking your .perltidyrc configuration parameters.
  - [A perltidy plugin for Sublime Text 2/3](https://github.com/vifo/SublimePerlTidy)
 
index 4e9039a1fe980519b78e224bd977b4af46a03131..ca979b37ab335ded874d136a9cbe81f7ebdb95ff 100644 (file)
 
 <h1 id="VERSION">VERSION</h1>
 
-<p>This man page documents perltidy version 20180220.01</p>
+<p>This man page documents perltidy version 20181117</p>
 
 <h1 id="BUG-REPORTS">BUG REPORTS</h1>
 
index eb4cd3d984994ae1d96f1836d1a9eff195c1753b..6993cf4eeac7396888a274fac06b45e0943d27f9 100644 (file)
@@ -109,7 +109,7 @@ BEGIN {
     # Release version must be bumped, and it is probably past time for a
     # release anyway.
 
-    $VERSION = '20181116';
+    $VERSION = '20181117';
 }
 
 sub streamhandle {
@@ -358,7 +358,7 @@ EOM
     }
 
     my $get_hash_ref = sub {
-        my ($key)    = @_;
+        my ($key) = @_;
         my $hash_ref = $input_hash{$key};
         if ( defined($hash_ref) ) {
             unless ( ref($hash_ref) eq 'HASH' ) {
@@ -1582,7 +1582,7 @@ sub generate_options {
         $option_category{$opt} = $category_name[$category];
     }
 
-    $category              = 11;                          # HTML
+    $category = 11;                                       # HTML
     $option_category{html} = $category_name[$category];
 
     # routine to install and check options
index b71cef3724c517031dfc9db9d3a93266f1affaef..4929185ee070b0f4514d691dd6c9e20b62d73da0 100644 (file)
@@ -410,7 +410,7 @@ C<write_debug_entry> in Tidy.pm.
 
 =head1 VERSION
 
-This man page documents Perl::Tidy version 20181116
+This man page documents Perl::Tidy version 20181117
 
 =head1 LICENSE
 
index fbbfa1965da93e165bed77bb13f03fb70960f526..e8ea6b4a83653c44533e38026c357c34385fcd72 100644 (file)
@@ -9517,6 +9517,19 @@ sub send_lines_to_vertical_aligner {
                     }
                 }
 
+         # Convert a bareword within braces into a quote for matching. This will
+         # allow alignment of expressions like this:
+         #    local ( $SIG{'INT'} ) = IGNORE;
+         #    local ( $SIG{ALRM} )  = 'POSTMAN';
+                if (   $type eq 'w'
+                    && $i > $ibeg
+                    && $i < $iend
+                    && $types_to_go[ $i - 1 ] eq 'L'
+                    && $types_to_go[ $i + 1 ] eq 'R' )
+                {
+                    $type = 'Q';
+                }
+
                 # patch to make numbers and quotes align
                 if ( $type eq 'n' ) { $type = 'Q' }
 
index 4b04e8c581604326e873443c23872867eb1f5030..14c76c0ba2abb3fb4f461203f655b28f357ab615 100644 (file)
@@ -1496,11 +1496,11 @@ sub prepare_for_a_new_file {
     # ------------------------------------------------------------
 
     my %is_for_foreach;
-    @_                  = qw(for foreach);
+    @_ = qw(for foreach);
     @is_for_foreach{@_} = (1) x scalar(@_);
 
     my %is_my_our;
-    @_             = qw(my our);
+    @_ = qw(my our);
     @is_my_our{@_} = (1) x scalar(@_);
 
     # These keywords may introduce blocks after parenthesized expressions,
@@ -2409,7 +2409,7 @@ sub prepare_for_a_new_file {
     @is_zero_continuation_block_type{@_} = (1) x scalar(@_);
 
     my %is_not_zero_continuation_block_type;
-    @_                                       = qw(sort grep map do eval);
+    @_ = qw(sort grep map do eval);
     @is_not_zero_continuation_block_type{@_} = (1) x scalar(@_);
 
     my %is_logical_container;
@@ -2417,33 +2417,33 @@ sub prepare_for_a_new_file {
     @is_logical_container{@_} = (1) x scalar(@_);
 
     my %is_binary_type;
-    @_                  = qw(|| &&);
+    @_ = qw(|| &&);
     @is_binary_type{@_} = (1) x scalar(@_);
 
     my %is_binary_keyword;
-    @_                     = qw(and or err eq ne cmp);
+    @_ = qw(and or err eq ne cmp);
     @is_binary_keyword{@_} = (1) x scalar(@_);
 
     # 'L' is token for opening { at hash key
     my %is_opening_type;
-    @_                   = qw< L { ( [ >;
+    @_ = qw< L { ( [ >;
     @is_opening_type{@_} = (1) x scalar(@_);
 
     # 'R' is token for closing } at hash key
     my %is_closing_type;
-    @_                   = qw< R } ) ] >;
+    @_ = qw< R } ) ] >;
     @is_closing_type{@_} = (1) x scalar(@_);
 
     my %is_redo_last_next_goto;
-    @_                          = qw(redo last next goto);
+    @_ = qw(redo last next goto);
     @is_redo_last_next_goto{@_} = (1) x scalar(@_);
 
     my %is_use_require;
-    @_                  = qw(use require);
+    @_ = qw(use require);
     @is_use_require{@_} = (1) x scalar(@_);
 
     my %is_sub_package;
-    @_                  = qw(sub package);
+    @_ = qw(sub package);
     @is_sub_package{@_} = (1) x scalar(@_);
 
     # This hash holds the hash key in $tokenizer_self for these keywords:
@@ -2585,7 +2585,7 @@ sub prepare_for_a_new_file {
   #
   # -----------------------------------------------------------------------
 
-        my $line_of_tokens         = shift;
+        my $line_of_tokens = shift;
         my ($untrimmed_input_line) = $line_of_tokens->{_line_text};
 
         # patch while coding change is underway
@@ -4842,14 +4842,14 @@ sub increase_nesting_depth {
             if ( $nested_ternary_flag[ $current_depth[$aa] - 1 ] == 0 ) {
                 my $pdepth = $total_depth[$aa][ $current_depth[$aa] - 1 ];
                 if ( $pdepth == $total_depth - 1 ) {
-                    $indent                                         = 1;
+                    $indent = 1;
                     $nested_ternary_flag[ $current_depth[$aa] - 1 ] = -1;
                 }
             }
         }
     }
     $nested_statement_type[$aa][ $current_depth[$aa] ] = $statement_type;
-    $statement_type                                    = "";
+    $statement_type = "";
     return ( $seqno, $indent );
 }
 
@@ -7415,11 +7415,11 @@ BEGIN {
     # these functions have prototypes of the form (&), so when they are
     # followed by a block, that block MAY BE followed by an operator.
     # Smartmatch operator ~~ may be followed by anonymous hash or array ref
-    @q                     = qw( do eval );
+    @q = qw( do eval );
     @is_block_operator{@q} = (1) x scalar(@q);
 
     # these functions allow an identifier in the indirect object slot
-    @q                            = qw( print printf sort exec system say);
+    @q = qw( print printf sort exec system say);
     @is_indirect_object_taker{@q} = (1) x scalar(@q);
 
     # These tokens may precede a code block
@@ -7755,7 +7755,7 @@ BEGIN {
     delete $really_want_term{'Y'}; # indirect object, too risky to check syntax;
                                    # let perl do it
 
-    @q                             = qw(q qq qw qx qr s y tr m);
+    @q = qw(q qq qw qx qr s y tr m);
     @is_q_qq_qw_qx_qr_s_y_tr_m{@q} = (1) x scalar(@q);
 
     # These keywords are handled specially in the tokenizer code:
index 26d6598281d098a27b1e498e21cf7930a09cf0a6..f917b0dd34c5c4ebf41efa216f250c5eedef01e9 100644 (file)
@@ -1310,6 +1310,7 @@ sub fix_terminal_else {
         my $maximum_field_index = $old_line->get_jmax();
 
         # flush if this line has too many fields
+        # variable $GoToLoc indicates goto branch point, for debugging
         my $GoToLoc = 1;
         if ( $jmax > $maximum_field_index ) { goto NO_MATCH }
 
@@ -1594,6 +1595,7 @@ sub fix_terminal_else {
 
       NO_MATCH:
 
+        # variable $GoToLoc is for debugging
         #print "no match from $GoToLoc\n";
         ##print "no match jmax=$jmax  max=$maximum_field_index $group_list_type lines=$maximum_line_index token=$old_rtokens->[0]\n";
 
@@ -2058,22 +2060,27 @@ sub decide_if_aligned {
 
     my $group_list_type = $group_lines[0]->get_list_type();
 
-    # See if these two lines have leading equals type tokens which can be
-    # aligned without creating a big gap. These two below are an example that
-    # have a large gap and will not be aligned:
-    #  local (@pieces)            = split( /\./, $filename, 2 );
-    #  local ($just_dir_and_base) = $pieces[0];
-    my $good_leading_equals;
-    my $rtokens = $group_lines[0]->get_rtokens();
-    if ( $rtokens->[0] =~ /=/ ) {
-        my $rfields0 = $group_lines[0]->get_rfields();
-        my $rfields1 = $group_lines[1]->get_rfields();
-        my $len0     = length( $rfields0->[0] );
-        my $len1     = length( $rfields1->[0] );
-        my $gap      = abs( $len0 - $len1 );
-
-        # put a limit on the maximum gap we will allow here
-        $good_leading_equals = ( $gap > 8 ) ? 0 : 1;
+    my $rtokens        = $group_lines[0]->get_rtokens();
+    my $leading_equals = ( $rtokens->[0] =~ /=/ );
+
+   # A marginal match is a match which has different patterns. Normally, we
+   # should not allow exactly two lines to match if marginal. But we will modify
+   # this rule for two lines with a leading equals-like operator such that we
+   # match if the patterns to the left of the equals are the same. So for
+   # example the following two lines are a marginal match but have the same
+   # left side patterns, so we will align the equals.
+   #     my $orig = my $format = "^<<<<< ~~\n";
+   #     my $abc  = "abc";
+   # But these have a different left pattern so they will not be aligned
+   #     $xmldoc .= $`;
+   #     $self->{'leftovers'} .= "<bx-seq:seq" . $';
+    my $is_marginal = $marginal_match;
+    if ( $leading_equals && $is_marginal ) {
+        my $rpatterns0 = $group_lines[0]->get_rpatterns();
+        my $rpatterns1 = $group_lines[1]->get_rpatterns();
+        my $pat0       = $rpatterns0->[0];
+        my $pat1       = $rpatterns1->[0];
+        $is_marginal = $pat0 ne $pat1;
     }
 
     my $do_not_align = (
@@ -2083,15 +2090,16 @@ sub decide_if_aligned {
 
           && (
 
-            # don't align if it was marked as a 'marginal" match.
-            $marginal_match
+            # don't align if it was just a marginal match
+            $is_marginal    ##$marginal_match
 
+            # don't align two lines with big gap
+            # NOTE: I am not sure if this test is actually functional any longer
             || $group_maximum_gap > 12
 
-            # don't align lines with differing number of alignment tokens,
-            # unless the first common alignment is an equals
-            || ( ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen )
-                && !$good_leading_equals )
+            # or lines with differing number of alignment tokens
+            || ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen
+                && !$leading_equals )
           )
     );
 
index 194694e19323aa97514f47d545a935691f6094ab..14e796c2219f5f6093057da3582a99c645d49a5f 100644 (file)
@@ -43,7 +43,7 @@ use warnings;
     sub new {
         my ( $caller, %arg ) = @_;
         my $caller_is_obj = ref($caller);
-        my $class = $caller_is_obj || $caller;
+        my $class         = $caller_is_obj || $caller;
         ##no strict "refs";
         my $self = bless {}, $class;
 
index 7cd7cc7e507366fb62b5f47e5999b11919cbd786..30669a22b666260e797e0b782722dc142082c2eb 100644 (file)
@@ -41,7 +41,7 @@ use warnings;
     sub new {
         my ( $caller, %arg ) = @_;
         my $caller_is_obj = ref($caller);
-        my $class = $caller_is_obj || $caller;
+        my $class         = $caller_is_obj || $caller;
         ##no strict "refs";
         my $self = bless {}, $class;
 
index 636bdc16ec8e4bfccf7223bcee736a644bf67e67..8733a2163b2f29770a38623871297e5846bb92b0 100644 (file)
@@ -1,6 +1,6 @@
 =head1 Perltidy Change Log
 
-=head2 2018 11 16
+=head2 2018 11 17
 
 
   - Fixed RT #126965, in which a ternary operator was misparsed if immediately
@@ -8,8 +8,8 @@
       my $restrict_customer = shift ? 1 : 0;
 
   - Fixed RT #125012: bug in -mangle --delete-all-comments
-    A needed blank space bareword tokens was being removed when comments were
-    deleted
+    A needed blank space before bareword tokens was being removed when comments 
+    were deleted
 
   - Fixed RT #81852: Stacked containers and quoting operators. Quoted words
     (qw) delimited by container tokens ('{', '[', '(', '<') are now included in
   - Fixed RT #127633, undesirable line break after return when -baao flag is set
 
   - Fixed RT #127035, vertical alignment. Vertical alignment has been improved 
-    in several ways.  Thanks especially to Glenn and Michael Wardman for sending 
+    in several ways.  Thanks especially to Michael Wardman and Glenn for sending 
     helpful snippets. 
 
-    - In many cases, two lines which were previously left unaligned are now
-      aligned. 
-
-        OLD:
-        $expect = "1$expect" if $expect =~ /^e/i;
-        $p = "1$p" if defined $p and $p =~ /^e/i;
-    
-        NEW:
-        $expect = "1$expect" if $expect =~ /^e/i;
-        $p      = "1$p"      if defined $p and $p =~ /^e/i;
-
     - Alignment of the =~ operators has been reactivated.  
 
         OLD:
         is( pop()     // 7, 0, 'pop() // ... works' );
         is( pop @ARGV // 7, 3, 'pop @array // ... works' );
 
+    - The rules for alignment of just two lines have been adjusted,
+      hopefully to be a little better overall.  In some cases, two 
+      lines which were previously unaligned are now aligned, and vice-versa.
+
+        OLD:
+        $expect = "1$expect" if $expect =~ /^e/i;
+        $p = "1$p" if defined $p and $p =~ /^e/i;
+    
+        NEW:
+        $expect = "1$expect" if $expect =~ /^e/i;
+        $p      = "1$p"      if defined $p and $p =~ /^e/i;
+
+
   - RT #106493; source code repository location has been added to docs; it is 
        https://github.com/perltidy/perltidy
 
index 26b618492d9be7fc602c165153cd542a1f502f22..edb1eb4ca3124fedad282f28e66431df67cb32ea 100644 (file)
@@ -3274,7 +3274,7 @@ perlstyle(1), Perl::Tidy(3)
 
 # VERSION
 
-This man page documents perltidy version 20181116
+This man page documents perltidy version 20181117
 
 # BUG REPORTS
 
index b6b75710c821df472f253cade0100f89380ce8ab..41d473edf7058842628d429ccf52ae0f7c53013d 100644 (file)
@@ -136,6 +136,19 @@ corresponding to running with default parameters and the second with '-xyzzy' pa
 - Go up to the git root directory and run 'make test' to verify that all
 snippets are still working correctly
 
+
+## What to do if a test script fails
+
+If one of the test scripts fails it could be due to a bug which has been introduced
+or it could be a desirable formatting change introduced by a recent update. In either
+case just run 'make' and look at the differences.  The script will give the
+names of the cases with differences.  For example, if case 'align6.def' failed
+then the old expected result is 'expect/align6.def' and the new result is 'tmp/align6.def'.
+These files are the result of running perltidy on 'align6.def' with default parameters 
+('def.par').  After investigating and fixing any problems with the code,
+run 'make' again, and if all is well run the script it writes 'RUNME.sh'
+to create new snippets if necessary.
+
 ## How to clean up a .par file
 
 The '.par' parameter files are just .perltidyrc files, and they can be quite