From: Steve Hancock Date: Sat, 18 Sep 2021 15:20:35 +0000 (-0700) Subject: Fix issue b1208 X-Git-Tag: 20210717.03~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0af132196f7a93897d858fcfcda2e380ccb76913;p=perltidy.git Fix issue b1208 --- diff --git a/CHANGES.md b/CHANGES.md index c33ffbff..fc69d3df 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ## 2021 07 17.02 + - Fix issue git #73, the -nfpva flag was not working correctly. + Some unwanted vertical alignments of spaced function perens + were being made. + - Update the man pages to clarify the flags -valign and -novalign for turning vertical alignment on and off (issue git #72). Added parameters -vc -vsc -vbc for separately turning off vertical diff --git a/MANIFEST b/MANIFEST index e190c918..3e7239d7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -76,6 +76,7 @@ t/snippets21.t t/snippets22.t t/snippets23.t t/snippets24.t +t/snippets25.t t/snippets3.t t/snippets4.t t/snippets5.t diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 4af2d966..a6e77fa0 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7383,6 +7383,36 @@ if ( ==> b1207.par <== --nowant-right-space='x' +==> b1208.in <== +# S1 + + my $home = ( + $^O =~ /mswin32/i + ? $ENV{HOME} + : ( + eval { ( getpwuid($>) )[7]; } ## end eval + || $ENV{HOME} + ) + ); + +# S2 + + my $home = ( + $^O =~ /mswin32/i + ? $ENV{HOME} + : ( + eval { + ( getpwuid($>) )[7]; + } ## end eval + || $ENV{HOME} + ) + ); + +==> b1208.par <== +--continuation-indentation=9 +--extended-continuation-indentation +--maximum-line-length=54 + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 68bf5bfd..1b0035dd 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1,4 +1,4 @@ -##################################################################### +#################################################################### # # The Perl::Tidy::Formatter package adds indentation, whitespace, and # line breaks to the token stream @@ -11551,8 +11551,9 @@ EOM # Get next nonblank on this line my $next_nonblank_token = ''; my $next_nonblank_token_type = 'b'; + my $Knnb; if ( $Ktoken_vars < $K_last ) { - my $Knnb = $Ktoken_vars + 1; + $Knnb = $Ktoken_vars + 1; if ( $rLL->[$Knnb]->[_TYPE_] eq 'b' && $Knnb < $K_last ) { @@ -11695,6 +11696,14 @@ EOM # If there is a pending one-line block .. if ( $index_start_one_line_block != UNDEFINED_INDEX ) { + # Fix for b1208: if a side comment follows this closing + # brace then we must include its length in the length test. + # Assume a minimum of 1 blank space to the comment. + my $added_length = + $side_comment_follows + ? 1 + $rLL->[$Knnb]->[_TOKEN_LENGTH_] + : 0; + # we have to terminate it if.. if ( @@ -11702,7 +11711,7 @@ EOM # initial estimate). note: must allow 1 space for this # token $self->excess_line_length( $index_start_one_line_block, - $max_index_to_go ) >= 0 + $max_index_to_go ) + $added_length >= 0 # or if it has too many semicolons || ( $semicolons_before_block_self_destruct == 0 diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 20e9de85..6d9682fe 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,34 @@ =over 4 +=item B + +Test with random parameters produced a formatting instability which could be +triggered when there is a short line length limit and there is a long side +comment on the closing brace of a sort/map/grep/eval block. The problem was +due to not correctly including the length of the side comment when testing to +see if the block could fit on one line. This update fixes issue b1208. + +18 Sep 2021. + +=item B + +The -nfpva parameter was not working correctly for functions called with +pointers. For example + + # OLD: perltidy -sfp -nfpva + $self->method ( 'parameter_0', 'parameter_1' ); + $self->method_with_long_name ( 'parameter_0', 'parameter_1' ); + + # FIXED: perltidy -sfp -nfpva + $self->method ( 'parameter_0', 'parameter_1' ); + $self->method_with_long_name ( 'parameter_0', 'parameter_1' ); + +The problem had to do with how the pointer tokens '->' are represented internally +and has been fixed. + +17 Sep 2021. + =item B Testing with random parameters produced another instability caused by misparsing @@ -24,7 +52,7 @@ Note in particular the different treatment of the first two print statements. This update fixes case b1207. -15 Sep 2021. +15 Sep 2021, 107586f. =item B