From: Steve Hancock Date: Mon, 19 Feb 2024 18:08:57 +0000 (-0800) Subject: b1466 X-Git-Tag: 20240202.03~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2bfb8e4dc27d5a944d20a56d5436aa75a0dcf9ab;p=perltidy.git b1466 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 5504e62e..ea6d0055 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -11935,6 +11935,96 @@ my @pics = --extended-line-up-parentheses --ignore-side-comment-lengths +==> b1466.in <== +sub new{ + my($self)=$class->SUPER::new( + yyrules=>[ + ['$start',2,undef,], + [ + 'item', + 3, + sub{ + if($_[3]){ + my($k,$v,); + while(($k,$v,)=each(%{$_[3]})){ + if($k eq"email_"){ + if( + defined$groups{$_[1]} + ->{"email_work"}) + { + $k="email_home"; + } + else{ + $k="email_work"; + } + } + + $groups{$_[1]}->{$k}=$v; + } + } + }, + ], + [ + '@1-3', + 0, + sub{parse_value($_[2]->{ENCODING});}, + ], + ['params',0,sub{{}},], + [ + 'params', + 3, + sub{ + my%hash; + for(my$i=0;$i<@{$_[3]};$i+=2){ + push@{$hash{$_[3]->[$i]}},$_[3]->[$i+1]; + } + \%hash; + }, + ], + [ + 'paramlist', + 1, + sub{$_[1]}, + ], + [ + 'paramlist', + 5, + sub{ + unshift(@{$_[1]},@{$_[5]},)if defined$_[5]; + $_[1]; + }, + ], + [ + 'param', + 5, + sub{[uc($_[1]),uc($_[5]),]}, + ], + ['addressparts',1,sub{{"address",$_[1],}},], + [ + 'addressparts', + 3, + sub{{"address",$_[1],"address2",$_[3],}}, + ], + [ + 'addressparts', + 5, + sub{{"address",$_[1],"address2",$_[3],"street",$_[5],}}, + ], + ], + @_, + ); + bless($self,$class,); + +} + +==> b1466.par <== +--indent-columns=5 +--continuation-indentation=7 +--weld-nested-containers +--noadd-whitespace +--extended-continuation-indentation +--extended-line-up-parentheses + ==> b148.in <== # state 1 @yydgoto=( diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index e7ebfbeb..9d8b807d 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -5950,7 +5950,7 @@ use overload "\\$outermost_level", "*", "$O$X$C$O$Y$C\\infopagename$O$Y$C$O$X$C\n", - , + " \\textohtmlinfopage" ); $_=join( @@ -5962,7 +5962,7 @@ use overload "\\$outermost_level", "*", "$O$X$C$O$Y$C\\infopagename$O$Y$C$O$X$C\n", - , + " \\textohtmlinfopage" ); ==> b1284 <== @@ -6501,8 +6501,7 @@ my $parser = ==> b1325 <== WriteMakefile( PREREQ_PM => { - 'Tk' => - '800.025', + 'Tk' =>'800.025', 'Tk::DiffText' => 0, 'Perl::Tidy' => 0 , # comes in the perltidy application @@ -6514,8 +6513,7 @@ WriteMakefile( WriteMakefile( PREREQ_PM => { - 'Tk' => - '800.025', + 'Tk' =>'800.025', 'Tk::DiffText' => 0, 'Perl::Tidy' => 0 , # comes in the perltidy application @@ -8079,6 +8077,87 @@ my @pics = @dir ); +==> b1466 <== +sub new{ + my($self)=$class->SUPER::new( + yyrules=>[ + ['$start',2,undef,], + [ + 'item',3, + sub{ + if($_[3]){ + my($k,$v,); + while(($k,$v,)=each(%{$_[3]})){ + if($k eq"email_"){ + if( + defined$groups{$_[1]} + ->{"email_work"}) + { + $k="email_home"; + } + else{ + $k="email_work"; + } + } + + $groups{$_[1]}->{$k}=$v; + } + } + }, + ], + [ + '@1-3', + 0, + sub{parse_value($_[2]->{ENCODING});}, + ], + ['params',0,sub{{}},], + [ + 'params', + 3, + sub{ + my%hash; + for(my$i=0;$i<@{$_[3]};$i+=2){ + push@{$hash{$_[3]->[$i]}},$_[3]->[$i+1]; + } + \%hash; + }, + ], + [ + 'paramlist', + 1, + sub{$_[1]}, + ], + [ + 'paramlist', + 5, + sub{ + unshift(@{$_[1]},@{$_[5]},)if defined$_[5]; + $_[1]; + }, + ], + [ + 'param', + 5, + sub{[uc($_[1]),uc($_[5]),]}, + ], + ['addressparts',1,sub{{"address",$_[1],}},], + [ + 'addressparts', + 3, + sub{{"address",$_[1],"address2",$_[3],}}, + ], + [ + 'addressparts', + 5, + sub{{"address",$_[1],"address2",$_[3],"street",$_[5],}}, + ], + ], + @_, + ); + bless($self,$class,); + +} + ==> b148 <== # state 1 @yydgoto=( @@ -9714,7 +9793,7 @@ has 'baz' => ( @eigenvalues= eigenvalue( [ - [ 3, 4 ], + [ 3, 4 ], [ 4, -3 ], ] ); diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index c4282370..6ad41bc0 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2212,6 +2212,20 @@ EOM ## ); } + #----------------------------------------------------------- + # The combination -xlp -xci and ci>i can be unstable (b1466) + #----------------------------------------------------------- + if ( $rOpts->{'extended-line-up-parentheses'} + && $rOpts->{'extended-continuation-indentation'} + && $rOpts->{'continuation-indentation'} > $rOpts->{'indent-columns'} + && $rOpts->{'indent-columns'} > 1 ) + { + $rOpts->{'continuation-indentation'} = $rOpts->{'indent-columns'}; + ## This combination is only likely to occur during random testing, so + ## skip the warning. + ##Warn("The combination -xlp -xci -ci>-i can be unstable; reducing ci\n"); + } + return; } ## end sub initialize_line_up_parentheses @@ -12167,8 +12181,11 @@ sub add_trailing_comma { # if so, add a comma if ($match) { - my $want_space_after = $rwhitespace_flags->[$KK] == WS_YES; - $self->store_new_token( ',', ',', $Kp, $want_space_after ); + + # any blank after the comma will be added before the closing paren, + # below + $self->store_new_token( ',', ',', $Kp ); + } return; @@ -12336,8 +12353,8 @@ sub add_interbracket_arrow { return; } - my $want_space_after = $want_right_space{'->'} == WS_YES; - $self->store_new_token( '->', '->', $Kp, $want_space_after ); + $self->store_new_token( '->', '->', $Kp ); + if ( $want_right_space{'->'} == WS_YES ) { $self->store_token() } return; } ## end sub add_interbracket_arrow @@ -12701,16 +12718,15 @@ sub match_trailing_comma_rule { sub store_new_token { - my ( $self, $type, $token, $Kp, $want_space_after ) = @_; + my ( $self, $type, $token, $Kp ) = @_; # Create and insert a completely new token into the output stream + # Caller must add space after this token if necessary # Input parameters: # $type = the token type # $token = the token text # $Kp = index of the previous token in the new list, $rLL_new - # $want_space_after = true if we want a space after the new token - # false if no space # This operation is a little tricky because we are creating a new token and # we have to take care to follow the requested whitespace rules. @@ -12745,9 +12761,7 @@ sub store_new_token { } # Then store a new blank - if ($want_space_after) { - $self->store_token($rcopy); - } + ## $self->store_token($rcopy); } else { @@ -12781,9 +12795,6 @@ sub store_new_token { my $rcopy = copy_token_as_type( $rLL_new->[$Kp], $type, $token ); $self->store_token($rcopy); - if ($want_space_after) { - $self->store_token(); - } } return;