]> git.donarmstrong.com Git - perltidy.git/commitdiff
check for negative -i and -ci
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 2 Nov 2023 01:56:14 +0000 (18:56 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 2 Nov 2023 01:56:14 +0000 (18:56 -0700)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Tokenizer.pm

index 70c6e35d4fc8defb129c35778bd2d4d857619214..a97470e1711913ad3d2e220dd357afb33f279436 100644 (file)
@@ -4554,6 +4554,16 @@ sub check_options {
 EOM
     }
 
+    # do not allow negative --indent-columns
+    if ( $rOpts->{'indent-columns'} < 0 ) {
+        $rOpts->{'indent-columns'} = 0;
+    }
+
+    # negative ci is currently allowed provided that ci+i is not negative
+    if ( $rOpts->{'continuation-indentation'} < -$rOpts->{'indent-columns'} ) {
+        $rOpts->{'continuation-indentation'} = -$rOpts->{'indent-columns'};
+    }
+
     my $sil = $rOpts->{'starting-indentation-level'};
     if ( defined($sil) && $sil < 0 ) {
         Die(<<EOM);
index 03295d16aac94c7b149fd7d368e3360fbe103dee..1d281e656d616e4f334a268fd9bef93a2f74e508 100644 (file)
@@ -1638,7 +1638,10 @@ sub guess_old_indentation_level {
         if ($2) { $spaces += length($2) }
 
         # correct for outdented labels
-        if ( $3 && $rOpts_outdent_labels ) {
+        if (   $3
+            && $rOpts_outdent_labels
+            && $rOpts_continuation_indentation > 0 )
+        {
             $spaces += $rOpts_continuation_indentation;
         }
     }