]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix c091, incorrect closing side comment
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 21 Oct 2021 00:07:36 +0000 (17:07 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 21 Oct 2021 00:07:36 +0000 (17:07 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index a125cbb7072b7d9645bf77536ee1cd3156cb8712..521139232f2e0d2c2f44bcf7802fb6650d56edde 100644 (file)
@@ -4653,6 +4653,11 @@ sub make_block_pattern {
             Warn("unrecognized block type $i after $abbrev, ignoring\n");
         }
     }
+
+    # Fix 2 for c091, prevent the pattern from matching an empty string
+    # '1 ' is an impossible block name.
+    if ( !@words ) { push @words, "1 " }
+
     my $pattern      = '(' . join( '|', @words ) . ')$';
     my $sub_patterns = "";
     if ( $seen{'sub'} ) {
@@ -24152,6 +24157,9 @@ sub add_closing_side_comment {
     if (
         $terminal_type eq '}'
 
+        # Fix 1 for c091, this is only for blocks
+        && $block_type_to_go[$i_terminal]
+
         # ..and either
         && (
 
index 97aae3dee39629b728dda9b0446e39bd8541e062..39d9b99ba9d2f226e02cdc7b4b01b2a2c74c4d4b 100644 (file)
@@ -2,6 +2,19 @@
 
 =over 4
 
+=item B<Fix c091, incorrect closing side comment>
+
+An error was discovered and corrected in the behavior of the --closing-side-comment
+(-csc) flag when only subs were being marked with the setting -cscl='sub'.  The problem
+was that in rare cases a closing paren could be marked with '## end'.  The cause of
+the problem is that the pattern matching regex which was generated for this case
+happens to match an empty string, and it could happen that certain parens
+had empty strings as block names.  This was fixed in two ways.  First, the
+regex was fixed so that it cannot match an empty string.  Second, a test for
+an empty string was added.
+
+20 Oct 2021.
+
 =item B<Issue c089, improve vertical alignment for lists without parens>
 
 An update was made to improve vertical alignment in situations where parens
@@ -68,7 +81,7 @@ as they would if they were contained in parens.  Some examples:
     is $av->[5],    "peep:$unop",           "...with correct 'o' param";
     is $av->[6],    "oldop:$kid",           "...and correct 'oldop' param";
 
-17 Oct 2021.
+20 Oct 2021, 1dffec5.
 
 =item B<Issue c087, breaking after anonymous sub>