From b9a5f5d18587814527e9091674ff48c1e8900a6d Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 17 Jan 2021 07:16:20 -0800 Subject: [PATCH] Do not let -kgb option delete essential blank after a pod =cut --- lib/Perl/Tidy/Formatter.pm | 28 +++++++++++++++++++--------- local-docs/BugLog.pod | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f30a8d14..76d5c6b8 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1391,31 +1391,36 @@ EOM if ( $rOpts->{'break-at-old-method-breakpoints'} ) { Warn("Conflicting parameters: -iob and -bom; -bom will be ignored\n" ); + $rOpts->{'break-at-old-method-breakpoints'} = 0; } if ( $rOpts->{'break-at-old-comma-breakpoints'} ) { Warn("Conflicting parameters: -iob and -boc; -boc will be ignored\n" ); + $rOpts->{'break-at-old-comma-breakpoints'} = 0; } if ( $rOpts->{'break-at-old-semicolon-breakpoints'} ) { Warn("Conflicting parameters: -iob and -bos; -bos will be ignored\n" ); + $rOpts->{'break-at-old-semicolon-breakpoints'} = 0; } if ( $rOpts->{'keep-old-breakpoints-before'} ) { Warn("Conflicting parameters: -iob and -kbb; -kbb will be ignored\n" ); + $rOpts->{'keep-old-breakpoints-before'} = ""; } if ( $rOpts->{'keep-old-breakpoints-after'} ) { Warn("Conflicting parameters: -iob and -kba; -kba will be ignored\n" ); + $rOpts->{'keep-old-breakpoints-after'} = ""; } - # Note: there are additional parameters that can be made inactive by - # -iob, but they are on by default so we would generate excessive - # warnings if we noted them. They are: - # $rOpts->{'break-at-old-keyword-breakpoints'} - # $rOpts->{'break-at-old-logical-breakpoints'} - # $rOpts->{'break-at-old-ternary-breakpoints'} - # $rOpts->{'break-at-old-attribute-breakpoints'} + # Note: These additional parameters are made inactive by -iob. + # They are silently turned off here because they are on by default. + # We would generate unexpected warnings if we issued a warning. + $rOpts->{'break-at-old-keyword-breakpoints'} = 0; + $rOpts->{'break-at-old-logical-breakpoints'} = 0; + $rOpts->{'break-at-old-ternary-breakpoints'} = 0; + $rOpts->{'break-at-old-attribute-breakpoints'} = 0; } # very frequently used parameters made global for efficiency @@ -7948,8 +7953,9 @@ sub process_all_lines { # set locations for blanks around long runs of keywords my $rwant_blank_line_after = $self->keyword_group_scan(); - my $line_type = ""; - my $i = -1; + my $line_type = ""; + my $i_last_POD_END = -1; + my $i = -1; foreach my $line_of_tokens ( @{$rlines} ) { $i++; @@ -7984,6 +7990,7 @@ sub process_all_lines { # put a blank line after an =cut which comes before __END__ and __DATA__ # (required by podchecker) if ( $last_line_type eq 'POD_END' && !$self->[_saw_END_or_DATA_] ) { + $i_last_POD_END = $i; $file_writer_object->reset_consecutive_blank_lines(); if ( !$in_format_skipping_section && $input_line !~ /^\s*$/ ) { $self->want_blank_line(); @@ -8010,6 +8017,9 @@ sub process_all_lines { # But: the keep-old-blank-lines flag has priority over kgb flags $kgb_keep = 1 if ( $rOpts_keep_old_blank_lines == 2 ); + # Do not delete a blank line following an =cut + $kgb_keep = 1 if ( $i - $i_last_POD_END < 3 ); + if ( $rOpts_keep_old_blank_lines && $kgb_keep ) { $self->flush($CODE_type); $file_writer_object->write_blank_code_line( diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index af08da14..777aea46 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,35 @@ =over 4 +=item B + +A blinking state was found in random testing for the following snippet + + =head1 TODO + + handle UNIMARC encodings + + =cut + + use strict; + use warnings; + +when run with the following parameters + + --keyword-group-blanks-size='2.8' + --keyword-group-blanks-before=0 + +The space after the =cut was alternately being added as an essential blank +which is required by pod utilities, and then deleted by these parameters. +This was fixed 17 Jan 2021. + +=item B + +In random testing, the cause of a blinker was traced to both flags +--ignore-old-breakpoints and --break-at-old-comma-breakpoints being set. +There is a warning message but the -boc flag was not actually being +turned off. This was fixed 17 Jan 2021. + =item B A space following a token type 'Y' (filehandle) should not be removed. -- 2.39.5