]> git.donarmstrong.com Git - perltidy.git/commitdiff
adjust -drc for repeated commas across line breaks
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 15 Feb 2024 00:57:09 +0000 (16:57 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 15 Feb 2024 00:57:09 +0000 (16:57 -0800)
bin/perltidy
lib/Perl/Tidy/Formatter.pm

index cc44d3e9edca2a28813adac510a78435463303d7..c6853af99dfe628a62a5e84c1e2edfa6fa4fd84b 100755 (executable)
@@ -3714,15 +3714,10 @@ actions taken when this flag is set are as follows:
 
 =item *
 
-Repeated commas like ',,' on the same line are removed with a warning.
+Repeated commas like ',,' are removed with a warning.
 
 =item *
-Repeated fat commas like '=> =>' on the same line are removed with a warning.
-
-=item *
-
-Repeated commas and fat commas on different lines remain unchanged
-but produce a warning.
+Repeated fat commas like '=> =>' are removed with a warning.
 
 =item *
 
@@ -3731,12 +3726,13 @@ likely an error but only its author would know how to fix it).
 
 =item *
 
-Note that the remaining combination ',=>' (sometimes called a
-'winking fat comma') is ignored by this parameter.
+The remaining combination ',=>' (sometimes called a 'winking fat comma') is
+ignored by this parameter.
 
 =item *
 
-These warnings are only output if the B<-w> flag is set.
+These warnings are only output if the B<--warning-output>, or B<-w>, flag is
+set.
 
 =back
 
index 0b3d93a24087c70af56437fcde2592a1d7a80b0c..7393537d2ea07fd21e7ceca90788e7340d14bcc9 100644 (file)
@@ -11326,19 +11326,16 @@ EOM
                 && $rOpts->{'delete-repeated-commas'} )
             {
 
-                # do not delete a comma repeated on a different line -
-                # this can cause problems, such as promoting a side comment
-                # to a block comment. See test 'mangle4.in'
+                # Do not delete the leading comma of a line with a side
+                # comment. This could promote the side comment to a block
+                # comment.  See test 'mangle4.in'
                 my $lno = 1 + $rLL->[$KK]->[_LINE_INDEX_];
-                if ( $KK == $Kfirst ) {
+                if ( $KK eq $Kfirst && $rLL->[$Klast]->[_TYPE_] eq '#' ) {
                     complain(
-                        "repeated commas across multiple lines, not deleted\n",
-                        $lno
-                    );
+                        "repeated comma before side comment, not deleted\n",
+                        $lno );
                 }
                 else {
-                    # Could note this deletion as a possible future update:
-                    ## $self->note_deleted_comma($input_line_number);
                     complain( "deleted repeated ','\n", $lno );
                     next;
                 }
@@ -11373,13 +11370,13 @@ EOM
                 # Check for repeated '=>'s
                 # Note that ',=>' is useful and called a winking fat comma
 
-                # Do not delete a fat comma repeated on a different line -
-                # this can cause problems, such as promoting a side comment
-                # to a block comment. See test 'mangle4.in'
+                # Do not delete the leading fat comma of a line with a side
+                # comment. This could promote the side comment to a block
+                # comment.  See test 'mangle4.in'
                 my $lno = 1 + $rLL->[$KK]->[_LINE_INDEX_];
-                if ( $KK == $Kfirst ) {
+                if ( $KK eq $Kfirst && $rLL->[$Klast]->[_TYPE_] eq '#' ) {
                     complain(
-                        "-repeated '=>' acriss multiple lines, not deleted\n",
+                        "-repeated '=>' before side comment, not deleted\n",
                         $lno );
                 }
                 else {