]> git.donarmstrong.com Git - perltidy.git/commitdiff
set -maxue default=off; interferes with extended syntaxes like RPerl
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 4 Nov 2020 01:22:27 +0000 (17:22 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 4 Nov 2020 01:22:27 +0000 (17:22 -0800)
CHANGES.md
bin/perltidy
lib/Perl/Tidy.pm
lib/Perl/Tidy/Tokenizer.pm

index db09ba6515d6950504c907882815908c5d98f788..d9c1de07e336e6fa789937d499d277dcb682f947 100644 (file)
       the limit to 20 MB for example would be  -mfs=20.  This only applies to
       files specified by filename on the command line.
 
-    - Skip formatting if too many indentation level errors.  This is controlled
-      with -maxle=n, --maximum-level-errors=n.  This means that if the ending 
-      indentation differs from the starting indentation by more than
+    - Skip formatting if there are too many indentation level errors.  This is 
+      controlled with -maxle=n, --maximum-level-errors=n.  This means that if 
+      the ending indentation differs from the starting indentation by more than
       n levels, the file will be output verbatim. The default is n=1. 
       To skip this check, set n=0.
 
-    - Skip formatting if too many 'unexpected' tokenization errors.  This is controlled
-      with -maxue=n, --maximum-unexpected-errors=n.  This means that if the 
-      number of times the tokenizer found unexpected tokens is greater than n,
-      the file will be output verbatim. The intention is to avoid formatting
-      non-perl scripts. The default is n=3.  To skip this check, set n=0.
-      It is possible that some extended syntaxes will require setting
-      -maxue=0.  It would be better to try to work out a patch to perltidy to handle 
-      such cases.
-
     - Add flag -xci, --extended-continuation-indentation, regarding issue git #28
       This flag causes continuation indentation to "extend" deeper into structures.
       Since this is a fairly new flag, the default is -nxci to avoid disturbing 
index 88c9d5edfe480aecf551832033b939ed9a6a358a..6df3a91a592f36316e1f391a5c8470ccd63fc2f3 100755 (executable)
@@ -3947,7 +3947,9 @@ B<--maximum-level-errors=n> or B<-maxle=n> specifies the maximum number of
 indentation level errors are allowed before perltidy skips formatting and just
 outputs a file verbatim.  The default is n=1.  This means that if the final indentation 
 of a script differs from the starting indentation by more than 1 levels, the file 
-will be output verbatim.  To skip this check completely, set n=0.
+will be output verbatim.  To avoid formatting if there are any indentation
+level errors use -maxle=0. To skip this check set n equal to a large number, 
+such as n=100.
 
 For example, the following script has level error of 3 and will be output verbatim
 
@@ -3955,22 +3957,19 @@ For example, the following script has level error of 3 and will be output verbat
     {{{
 
 
-    perltidy -maxle=0
+    perltidy -maxle=100
     {
         {
             {
 
 B<--maximum-unexpected-errors=n> or B<-maxue=n> specifies the maximum number of
 unexpected tokenization errors are allowed before formatting is skipped and a
-script is output verbatim.  The intention of this flag is to avoid accidentally
-formatting something like an html file, for example.  The default is n=3.  This
-means that if the number of times the tokenizer found unexpected tokens is
-greater than 3, the file will be output verbatim.  To skip this check
-completely, set n=0.
-
-It is possible that some extended syntaxes will require setting -maxue=0.  It
-would be better to try to work out a patch to perltidy to handle such cases
-cleanly so that the tokenizer is not left in an uncertain state.
+script is output verbatim.  This is off by default but can be turned on to
+avoid accidentally formatting something like an html file, for example.  If the
+number of times the tokenizer found unexpected tokens is greater than the
+parameter n, the file will be output verbatim.  To skip this check completely,
+set n equal to a large number or set n=0.  The default is n=0 (skip this check)
+to avoid causing problems with scripts using extended syntaxes. 
 
 B<-DEBUG>  will write a file with extension F<.DEBUG> for each input file 
 showing the tokenization of all lines of code.
index df0b9e4d49b46eedef06c9a278078b23ade020cb..05cc78b2bdc3b934e757a6747f19e903d9ac8b02 100644 (file)
@@ -2531,7 +2531,7 @@ sub generate_options {
       maximum-line-length=80
       maximum-file-size-mb=10
       maximum-level-errors=1
-      maximum-unexpected-errors=3
+      maximum-unexpected-errors=0
       memoize
       minimum-space-to-comment=4
       nobrace-left-and-indent
index 08fb4e698a0fd2bab32c8fed0f49b58042285086..281312ba58280c80c2173b8acd1bba749c4bb614 100644 (file)
@@ -467,7 +467,7 @@ sub report_tokenization_errors {
     my $maxle = $self->[_rOpts_maximum_level_errors_];
     my $maxue = $self->[_rOpts_maximum_unexpected_errors_];
     $maxle = 1 unless defined($maxle);
-    $maxue = 3 unless defined($maxue);
+    $maxue = 0 unless defined($maxue);
 
     my $level = get_indentation_level();
     if ( $level != $tokenizer_self->[_starting_level_] ) {
@@ -478,7 +478,7 @@ sub report_tokenization_errors {
         # Set severe error flag if the level error is greater than 1.
         # The formatter can function for any level error but it is probably
         # best not to attempt formatting for a high level error.
-        if ( $maxle > 0 && $level_diff > $maxle ) {
+        if ( $level_diff > $maxle ) {
             $severe_error = 1;
             warning(<<EOM);
 Formatting will be skipped because level error '$level_diff' exceeds -maxle=$maxle; use -maxle=0 to force formatting
@@ -571,7 +571,9 @@ EOM
     # Multiple "unexpected" type tokenization errors usually indicate parsing
     # non-perl scripts, or that something is seriously wrong, so we should
     # avoid formatting them.  This can happen for example if we run perltidy on
-    # a shell script or an html file.
+    # a shell script or an html file.  But unfortunately this check can
+    # interfere with some extended syntaxes, such as RPerl, so it has to be off
+    # by default.
     my $ue_count = $tokenizer_self->[_unexpected_error_count_];
     if ( $maxue > 0 && $ue_count > $maxue ) {
         warning(<<EOM);