From 4fbc69a9acc2a672aef251ed4a52ba26b03bab79 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 20 Apr 2021 09:35:38 -0700 Subject: [PATCH] Fix a bad line break choice at a slash --- lib/Perl/Tidy/Formatter.pm | 7 +++++++ local-docs/BugLog.pod | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ff20d384..3b4fc805 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3860,6 +3860,13 @@ EOM $bond_strength_to_go[$i] = $strength; + # Fix for case c001: be sure NO_BREAK's are enforced by later + # routines, except at a '?' because '?' as quote delimiter is + # deprecated. + if ( $strength >= NO_BREAK && $next_nonblank_type ne '?' ) { + $nobreak_to_go[$i] ||= 1; + } + DEBUG_BOND && do { my $str = substr( $token, 0, 15 ); $str .= ' ' x ( 16 - length($str) ); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 37b058de..f631a036 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,44 @@ =over 4 +=item B + +Random testing produced case c001 in which the following snipppet + + ok $mi/(@mtime-1) >= 0.75 && $ai/(@atime-1) >= 0.75 && + $ss/(@mtime+@atime) >= 0.2; + +when processed with these parameters + + --maximum-line-length=20 + --nowant-right-space=' / ' + --want-break-before='* /' + +produced the following result + + ok $mi + /( @mtime - 1 ) >= + 0.75 + && $ai + /( @atime - 1 ) + >= 0.75 + && $ss + /( @mtime + + @atime ) >= + 0.2; + +using 'perl -cw' on this snippet gives a syntax error + + syntax error at /tmp/issues.t line 5, near "/( " + (Might be a runaway multi-line // string starting on line 2) + +The error is due to perl's weird parsing rules near a possible indrect object. +This is a situation where perltidy must ignore a user spacing and line break +request. This should have been done but in this case a flag to prevent this +was not being propagated to later stages of formatting. This has been fixed. + +20 Apr 2021. + =item B Random testing produced case b1114 which gave unstable formatting with these @@ -18,7 +56,7 @@ and this snippet is(length(pack("j", 0)), $Config{ivsize}); -Fixed 19 Apr 2021. +Fixed 19 Apr 2021, eeeaf09. =item B @@ -27,7 +65,7 @@ The following lines produced an error message due to the side comment my $fragment = $parser-> #parse_html_string parse_balanced_chunk($I); -Fixed 18 Apr 2021. +Fixed 18 Apr 2021, c2030cf. =item B -- 2.39.5