]> git.donarmstrong.com Git - perltidy.git/commitdiff
turn off --asert-tidy and --assert-untidy if format not 'tidy'
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 2 Sep 2020 23:26:30 +0000 (16:26 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 2 Sep 2020 23:26:30 +0000 (16:26 -0700)
lib/Perl/Tidy.pm

index 9c30a8ad4977687e8f47aff521ef1d685356fcc2..81fa3cd57b546f795b3a89fbae2aa4f306161126 100644 (file)
@@ -718,6 +718,18 @@ EOM
         }
     }
 
+    # Turn off assert-tidy and assert-untidy unless we are tidying files
+    if ( $rOpts->{'format'} ne 'tidy' ) {
+        if ( $rOpts->{'assert-tidy'} ) {
+            $rOpts->{'assert-tidy'} = 0;
+            Warn("ignoring --assert-tidy, --format is not 'tidy'\n");
+        }
+        if ( $rOpts->{'assert-untidy'} ) {
+            $rOpts->{'assert-untidy'} = 0;
+            Warn("ignoring --assert-untidy, --format is not 'tidy'\n");
+        }
+    }
+
     Perl::Tidy::Formatter::check_options($rOpts);
     Perl::Tidy::Tokenizer::check_options($rOpts);
     if ( $rOpts->{'format'} eq 'html' ) {
@@ -1744,7 +1756,7 @@ sub compare_string_buffers {
     my ( $bufi, $bufo, $is_encoded_data ) = @_;
 
     my $leni = length($bufi);
-    my $leno = length($bufo);
+    my $leno = defined($bufo) ? length($bufo) : 0;
     my $msg =
       "Input  file length is $leni chars\nOutput file length is $leno chars\n";
     return $msg unless $leni && $leno;