From: Steve Hancock Date: Wed, 4 Nov 2020 01:22:27 +0000 (-0800) Subject: set -maxue default=off; interferes with extended syntaxes like RPerl X-Git-Tag: 20201001.03~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=023399f805edda2210a56786adb7bce71baadb01;p=perltidy.git set -maxue default=off; interferes with extended syntaxes like RPerl --- diff --git a/CHANGES.md b/CHANGES.md index db09ba65..d9c1de07 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,21 +12,12 @@ 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 diff --git a/bin/perltidy b/bin/perltidy index 88c9d5ed..6df3a91a 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -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. diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index df0b9e4d..05cc78b2 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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 diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 08fb4e69..281312ba 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -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(<[_unexpected_error_count_]; if ( $maxue > 0 && $ue_count > $maxue ) { warning(<