]> git.donarmstrong.com Git - perltidy.git/commitdiff
updates for git #159
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 10 Aug 2024 16:01:13 +0000 (09:01 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 10 Aug 2024 16:01:13 +0000 (09:01 -0700)
bin/perltidy
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/git159.def [new file with mode: 0644]
t/snippets/expect/git159.git159 [new file with mode: 0644]
t/snippets/git159.in [new file with mode: 0644]
t/snippets/git159.par [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets30.t

index 44f7cc6c5c50905473404cab3452e14d6ef95418..4ea7cba9aaf8df18364644d3a5cba428dfc26aa4 100755 (executable)
@@ -2657,13 +2657,17 @@ the default settings B<-bll='*'> and B<-blxl='sort map grep eval asub'>
 mean all blocks except B<sort map grep eval> and anonymous sub blocks.
 
 Note that the lists B<-bll=s> and B<-blxl=s> control the behavior of the
-B<-bl> flag but have no effect unless the B<-bl> flag is set.
+B<-bl> flag but have no effect unless the B<-bl> flag is set. These
+two lists provide complete control for this flag, but two shortcut
+flags are available and described in the next sections.
 
 =item B<-sbl>,    B<--opening-sub-brace-on-new-line>
 
-The flag B<-sbl> provides a shortcut way to turn on B<-bl> just for named
-subs.  The same effect can be achieved by turning on B<-bl>
-with the block list set as B<-bll='sub'>.
+The flag B<-sbl> provides a shortcut way to turn on B<-bl> just for named subs.
+The same effect can be achieved by turning on B<-bl> with the block list set as
+B<-bll='sub'>.  To avoid conflicts, it is recommended to either use the more
+general list method described above to control B<-bl>, or this shortcut method,
+but not both.
 
 For example,
 
@@ -2681,12 +2685,17 @@ produces this result:
     }
  }
 
-This flag is negated with B<-nsbl>, which is the default.
+This negative version of this flag, B<-nsbl>, turns off B<-bl> for
+named subs.  The same effect can be achieved with the exclusion
+list method, B<-blxl=sub>.
 
 =item B<-asbl>,    B<--opening-anonymous-sub-brace-on-new-line>
 
-The flag B<-asbl> is like the B<-sbl> flag except that it applies
-to anonymous sub's instead of named subs. For example
+The flag B<-asbl> is like the B<-sbl> flag except that it applies to anonymous
+sub's instead of named subs.  The same effect can be achieved by turning on
+B<-bl> with the block list set to include B<-bll='asub'>.
+
+For example
 
  perltidy -asbl
 
@@ -2702,7 +2711,8 @@ produces this result:
      }
  };
 
-This flag is negated with B<-nasbl>, and the default is B<-nasbl>.
+This negative version of this flag, B<-nasbl>, turns off B<-bl> for
+anonymous subs.
 
 =item B<-bli>,    B<--brace-left-and-indent>
 
index 3be3fc8387eeb1728d0c37151ab8283c3ba95bc6..0cea196c73648a47c7db8179e35b98f7bbb25399 100644 (file)
@@ -5860,10 +5860,14 @@ sub make_bl_pattern {
 
     # for -bl, a list with '*' turns on -sbl and -asbl
     if ( $bl_pattern =~ /\.\*/ ) {
-        $rOpts->{'opening-sub-brace-on-new-line'} ||=
-          $rOpts->{'opening-brace-on-new-line'};
-        $rOpts->{'opening-anonymous-sub-brace-on-new-line'} ||=
-          $rOpts->{'opening-anonymous-brace-on-new-line'};
+        if ( !defined( $rOpts->{'opening-sub-brace-on-new-line'} ) ) {
+            $rOpts->{'opening-sub-brace-on-new-line'} =
+              $rOpts->{'opening-brace-on-new-line'};
+        }
+        if ( !defined( $rOpts->{'opening-anonymous-sub-brace-on-new-line'} ) ) {
+            $rOpts->{'opening-anonymous-sub-brace-on-new-line'} =
+              $rOpts->{'opening-anonymous-brace-on-new-line'};
+        }
     }
 
     if ( defined( $rOpts->{'brace-left-exclusion-list'} )
diff --git a/t/snippets/expect/git159.def b/t/snippets/expect/git159.def
new file mode 100644 (file)
index 0000000..e1dbbea
--- /dev/null
@@ -0,0 +1,6 @@
+sub example {
+    my $ex = 0;
+    if ($ex) {
+        print "yay\n";
+    }
+}
diff --git a/t/snippets/expect/git159.git159 b/t/snippets/expect/git159.git159
new file mode 100644 (file)
index 0000000..2440049
--- /dev/null
@@ -0,0 +1,7 @@
+sub example {
+    my $ex = 0;
+    if ($ex)
+    {
+        print "yay\n";
+    }
+}
diff --git a/t/snippets/git159.in b/t/snippets/git159.in
new file mode 100644 (file)
index 0000000..2440049
--- /dev/null
@@ -0,0 +1,7 @@
+sub example {
+    my $ex = 0;
+    if ($ex)
+    {
+        print "yay\n";
+    }
+}
diff --git a/t/snippets/git159.par b/t/snippets/git159.par
new file mode 100644 (file)
index 0000000..bd7dfff
--- /dev/null
@@ -0,0 +1 @@
+-bl -nsbl
index 2636797b06f75b305d031c8da16e75a79d964414..958b8746e4d7463245d3d610cd1be7774faed455 100644 (file)
 ../snippets30.t        dltc.dltc1
 ../snippets30.t        dltc.dltc2
 ../snippets30.t        logical_xor.def
+../snippets30.t        csc.csc3
 ../snippets4.t gnu1.gnu
 ../snippets4.t gnu2.def
 ../snippets4.t gnu2.gnu
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets30.t        csc.csc3
+../snippets30.t        git159.def
+../snippets30.t        git159.git159
index ea2307ce1725c25fba9a3f018c405facde528de6..81d9452686f1673eaf76b71b985ce9b5715b6b49 100644 (file)
@@ -13,6 +13,8 @@
 #10 dltc.dltc2
 #11 logical_xor.def
 #12 csc.csc3
+#13 git159.def
+#14 git159.git159
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -43,6 +45,7 @@ BEGIN {
 ---unknown-future-option
 ---wtc=h
 ----------
+        'git159' => "-bl -nsbl",
     };
 
     ############################
@@ -109,6 +112,16 @@ $self->make_grammar(
             );
 ----------
 
+        'git159' => <<'----------',
+sub example {
+    my $ex = 0;
+    if ($ex)
+    {
+        print "yay\n";
+    }
+}
+----------
+
         'logical_xor' => <<'----------',
 $x^^$y and say "One of x or y is true, but not both";
 ----------
@@ -288,6 +301,33 @@ $x ^^ $y and say "One of x or y is true, but not both";
         }; ## end $message = sub
 #12...........
         },
+
+        'git159.def' => {
+            source => "git159",
+            params => "def",
+            expect => <<'#13...........',
+sub example {
+    my $ex = 0;
+    if ($ex) {
+        print "yay\n";
+    }
+}
+#13...........
+        },
+
+        'git159.git159' => {
+            source => "git159",
+            params => "git159",
+            expect => <<'#14...........',
+sub example {
+    my $ex = 0;
+    if ($ex)
+    {
+        print "yay\n";
+    }
+}
+#14...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};