From aa1a019e10fda5a606a24d04ce9a91049f7957f6 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 20 Oct 2021 17:07:36 -0700 Subject: [PATCH] Fix c091, incorrect closing side comment --- lib/Perl/Tidy/Formatter.pm | 8 ++++++++ local-docs/BugLog.pod | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a125cbb7..52113923 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 && ( diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 97aae3de..39d9b99b 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,19 @@ =over 4 +=item B + +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 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 -- 2.39.5