X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FPerl%2FTidy%2FLineSource.pm;h=8bf97b91f383c87acfb278a71158053a8513c13c;hb=effbe8e558790d5f5e4eb49a10b2ed020b0eaaee;hp=3306d6b2d4f4f58ba8abe3a923a45cadaa455212;hpb=c514d57dc8088e1f4d3f51857b1155c20085c296;p=perltidy.git diff --git a/lib/Perl/Tidy/LineSource.pm b/lib/Perl/Tidy/LineSource.pm index 3306d6b..8bf97b9 100644 --- a/lib/Perl/Tidy/LineSource.pm +++ b/lib/Perl/Tidy/LineSource.pm @@ -8,7 +8,10 @@ package Perl::Tidy::LineSource; use strict; use warnings; -our $VERSION = '20220613'; +use English qw( -no_match_vars ); +our $VERSION = '20230309'; + +use constant DEVEL_MODE => 0; sub AUTOLOAD { @@ -41,47 +44,23 @@ sub new { my ( $class, @args ) = @_; my %defaults = ( - input_file => undef, - rOpts => undef, - rpending_logfile_message => undef, + input_file => undef, + rOpts => undef, ); my %args = ( %defaults, @args ); - my $input_file = $args{input_file}; - my $rOpts = $args{rOpts}; - my $rpending_logfile_message = $args{rpending_logfile_message}; - - my $input_line_ending; - if ( $rOpts->{'preserve-line-endings'} ) { - $input_line_ending = Perl::Tidy::find_input_line_ending($input_file); - } + my $input_file = $args{input_file}; + my $rOpts = $args{rOpts}; ( my $fh, $input_file ) = Perl::Tidy::streamhandle( $input_file, 'r' ); return unless $fh; - # in order to check output syntax when standard output is used, - # or when it is an object, we have to make a copy of the file - if ( ( $input_file eq '-' || ref $input_file ) && $rOpts->{'check-syntax'} ) - { - - # Turning off syntax check when input output is used. - # The reason is that temporary files cause problems on - # on many systems. - $rOpts->{'check-syntax'} = 0; - - ${$rpending_logfile_message} .= < $fh, - _filename => $input_file, - _input_line_ending => $input_line_ending, - _rinput_buffer => [], - _started => 0, + _fh => $fh, + _filename => $input_file, + _rinput_buffer => [], + _started => 0, }, $class; } @@ -91,7 +70,10 @@ sub close_input_file { # Only close physical files, not STDIN and other objects my $filename = $self->{_filename}; if ( $filename ne '-' && !ref $filename ) { - eval { $self->{_fh}->close() }; + my $ok = eval { $self->{_fh}->close(); 1 }; + if ( !$ok && DEVEL_MODE ) { + Fault("Could not close file handle(): $EVAL_ERROR\n"); + } } return; } @@ -124,4 +106,3 @@ sub get_line { return $line; } 1; -