perltidy -maxfs=20
-This only applies to files specified by filename on the command line.
+This length test is applied to named files before they are read into memory.
+It is applied to files arriving from standard input after they are read into
+memory. It is not applied to character strings arriving by a call to the
+Perl::Tidy module.
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
# zero length, but keep going
}
+ # Check size of strings arriving from the standard input. These
+ # could not be checked until now.
+ if ( $input_file eq '-' ) {
+ my $size_in_mb =
+ length( ${$rinput_string} ) / ( CONST_1024 * CONST_1024 );
+ my $maximum_file_size_mb = $rOpts->{'maximum-file-size-mb'};
+ if ( $size_in_mb > $maximum_file_size_mb ) {
+ $size_in_mb = sprintf( "%0.1f", $size_in_mb );
+ Warn(
+"skipping file: <stdin>: size $size_in_mb MB exceeds limit $maximum_file_size_mb; use -maxfs=i to change\n"
+ );
+ return;
+ }
+ }
+
$rinput_string = $self->set_line_separator($rinput_string);
my $encoding_in = EMPTY_STRING;
# files into memory, trying to process an extremely large file
# could cause system problems.
my $size_in_mb = ( -s $input_file ) / ( CONST_1024 * CONST_1024 );
- if ( $size_in_mb > $rOpts->{'maximum-file-size-mb'} ) {
+ my $maximum_file_size_mb = $rOpts->{'maximum-file-size-mb'};
+ if ( $size_in_mb > $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"
+"skipping file: $input_file: size $size_in_mb MB exceeds limit $maximum_file_size_mb; use -maxfs=i to change\n"
);
next;
}