# Handle blank lines
if ( $CODE_type eq 'BL' ) {
- # If keep-old-blank-lines is zero, we delete all
- # old blank lines and let the blank line rules generate any
- # needed blanks.
-
- # and delete lines requested by the keyword-group logic
- my $kgb_keep = !( defined( $rwant_blank_line_after->{$i} )
- && $rwant_blank_line_after->{$i} == 2 );
-
- # But: the keep-old-blank-lines flag has priority over kgb flags
- $kgb_keep = 1 if ( $rOpts_keep_old_blank_lines == 2 );
+ # Keep this blank? Start with the flag -kbl=n, where
+ # n=0 ignore all old blank lines
+ # n=1 stable: keep old blanks, but limited by -mbl=n
+ # n=2 keep all old blank lines, regardless of -mbl=n
+ # If n=0 we delete all old blank lines and let blank line
+ # rules generate any needed blank lines.
+ my $kgb_keep = $rOpts_keep_old_blank_lines;
+
+ # Then delete lines requested by the keyword-group logic if
+ # allowed
+ if ( $kgb_keep == 1
+ && defined( $rwant_blank_line_after->{$i} )
+ && $rwant_blank_line_after->{$i} == 2 )
+ {
+ $kgb_keep = 0;
+ }
- # Do not delete a blank line following an =cut
- $kgb_keep = 1 if ( $i - $i_last_POD_END < 3 );
+ # But always keep a blank line following an =cut
+ if ( $i - $i_last_POD_END < 3 && !$kgb_keep ) {
+ $kgb_keep = 1;
+ }
- if ( $rOpts_keep_old_blank_lines && $kgb_keep ) {
+ if ($kgb_keep) {
$self->flush($CODE_type);
$file_writer_object->write_blank_code_line(
$rOpts_keep_old_blank_lines == 2 );
=over 4
+=item B<Fix conflict of -kbl=0 and essential space after =cut>
+
+Random testing produced a case where a blank line after an =cut
+was alternately being deleted and added due to a conflict with
+the flag setting -keep-old-blank-lines=0. This was resolved by giving
+prioritiy to the essential blank line after the =cut line.
+
+This fixes case b860. 11 Feb 2021.
+
=item B<Do not break one-line block at here target>
A blinking state produced by random testing was traced to a line of coding
unless ($INC{$file}) { die <<"END_DIE" }
-This fixes case b523. 11 Feb 2021.
+This fixes case b523. 11 Feb 2021, 6d5bb74.
=item B<Skip processing -kgb* flags in lists or if -maximum-consecutive-blank-lines=0>