]> git.donarmstrong.com Git - perltidy.git/commitdiff
b1466
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 19 Feb 2024 18:08:57 +0000 (10:08 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 19 Feb 2024 18:08:57 +0000 (10:08 -0800)
dev-bin/run_convergence_tests.pl.data
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index 5504e62ead2af910c634b1039cb222797a61e34d..ea6d005511a923250de8d0eb665796b1ef32f51a 100644 (file)
@@ -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=(
index e7ebfbebd18547dcf97de8dc8b16e3ec89f627f8..9d8b807d5f0eb0e05b282c7d1938978064b89917 100644 (file)
@@ -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 ],
   ] );
 
index c428237000e7c680b9059d209561eb22b9cf270c..6ad41bc0d0943d118d5687346698a9d6686d34fa 100644 (file)
@@ -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;