## 2020 10 01.02
+ - Add flag -mfs=n, --maximum-file-size-mb=n. This parameter is provided to
+ avoid causing system problems by accidentally attempting to format an
+ extremely large data file. The default is n=10. The command to increase
+ the limit to 20 MB for example would be -mfs=20. This only applies to
+ files specified by filename on the command line.
+
- Add flag -xci, --extended-continuation-indentation, regarding issue git #28
This flag causes continuation indentation to "extend" deeper into structures.
If you use B<-ci=n> and B<-i=n> with the same value of B<n> you will probably
during program development, when large numbers of files with varying sizes are
processed, because it can reduce virtual memory usage.
+B<--maximum-file-size-mb=n> or B<-mfs=n> specifies the maximum file size in
+megabytes that perltidy will attempt to format. This parameter is provided to
+avoid causing system problems by accidentally attempting to format an extremely
+large data file. Most perl scripts are less than about 2 MB in size. The
+integer B<n> has a default value of 10, so perltidy will skip formatting files
+which have a size greater than 10 MB. The command to increase the limit to 20
+MB for example would be
+
+ perltidy -mfs=20
+
+This only applies to files specified by filename on the command line.
+
B<-DEBUG> will write a file with extension F<.DEBUG> for each input file
showing the tokenization of all lines of code.
next;
}
+ # And avoid formatting extremely large files. Since perltidy reads
+ # files into memory, trying to process an extremely large file
+ # could cause system problems.
+ my $size_in_mb = ( -s $input_file ) / ( 1024 * 1024 );
+ if ( $size_in_mb > $rOpts->{'maximum-file-size-mb'} ) {
+ $size_in_mb = sprintf( "%0.1f", $size_in_mb );
+ Warn(
+"skipping file: $input_file: size $size_in_mb MB exceeds limit $rOpts->{'maximum-file-size-mb'}; use -mfs=i to change\n"
+ );
+ next;
+ }
+
unless ( ( -T $input_file ) || $rOpts->{'force-read-binary'} ) {
Warn(
"skipping file: $input_file: Non-text (override with -f)\n"
$add_option->( 'version', 'v', '' );
$add_option->( 'memoize', 'mem', '!' );
$add_option->( 'file-size-order', 'fso', '!' );
+ $add_option->( 'maximum-file-size-mb', 'mfs', '=i' );
#---------------------------------------------------------------------
maximum-consecutive-blank-lines=1
maximum-fields-per-table=0
maximum-line-length=80
+ maximum-file-size-mb=10
memoize
minimum-space-to-comment=4
nobrace-left-and-indent