"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Perl/Tidy/FileWriter.pm" between
Perl-Tidy-20210402.tar.gz and Perl-Tidy-20210717.tar.gz

About: Perltidy is a Perl script indenter and reformatter (beautifier).

FileWriter.pm  (Perl-Tidy-20210402):FileWriter.pm  (Perl-Tidy-20210717)
##################################################################### #####################################################################
# #
# the Perl::Tidy::FileWriter class writes the output file # the Perl::Tidy::FileWriter class writes the output file
# #
##################################################################### #####################################################################
package Perl::Tidy::FileWriter; package Perl::Tidy::FileWriter;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '20210402'; our $VERSION = '20210717';
use constant DEVEL_MODE => 0; use constant DEVEL_MODE => 0;
sub AUTOLOAD { sub AUTOLOAD {
# Catch any undefined sub calls so that we are sure to get # Catch any undefined sub calls so that we are sure to get
# some diagnostic information. This sub should never be called # some diagnostic information. This sub should never be called
# except for a programming error. # except for a programming error.
our $AUTOLOAD; our $AUTOLOAD;
return if ( $AUTOLOAD =~ /\bDESTROY$/ ); return if ( $AUTOLOAD =~ /\bDESTROY$/ );
skipping to change at line 50 skipping to change at line 50
my $input_stream_name = ""; my $input_stream_name = "";
# Maximum number of little messages; probably need not be changed. # Maximum number of little messages; probably need not be changed.
my $MAX_NAG_MESSAGES = 6; my $MAX_NAG_MESSAGES = 6;
BEGIN { BEGIN {
# Array index names for variables # Array index names for variables
my $i = 0; my $i = 0;
use constant { use constant {
_line_sink_object_ => $i++, _line_sink_object_ => $i++,
_logger_object_ => $i++, _logger_object_ => $i++,
_rOpts_ => $i++, _rOpts_ => $i++,
_output_line_number_ => $i++, _output_line_number_ => $i++,
_consecutive_blank_lines_ => $i++, _consecutive_blank_lines_ => $i++,
_consecutive_nonblank_lines_ => $i++, _consecutive_nonblank_lines_ => $i++,
_first_line_length_error_ => $i++, _consecutive_new_blank_lines_ => $i++,
_max_line_length_error_ => $i++, _first_line_length_error_ => $i++,
_last_line_length_error_ => $i++, _max_line_length_error_ => $i++,
_first_line_length_error_at_ => $i++, _last_line_length_error_ => $i++,
_max_line_length_error_at_ => $i++, _first_line_length_error_at_ => $i++,
_last_line_length_error_at_ => $i++, _max_line_length_error_at_ => $i++,
_line_length_error_count_ => $i++, _last_line_length_error_at_ => $i++,
_max_output_line_length_ => $i++, _line_length_error_count_ => $i++,
_max_output_line_length_at_ => $i++, _max_output_line_length_ => $i++,
_rK_checklist_ => $i++, _max_output_line_length_at_ => $i++,
_K_arrival_order_matches_ => $i++, _rK_checklist_ => $i++,
_K_sequence_error_msg_ => $i++, _K_arrival_order_matches_ => $i++,
_K_last_arrival_ => $i++, _K_sequence_error_msg_ => $i++,
_K_last_arrival_ => $i++,
}; };
} }
sub warning { sub warning {
my ( $self, $msg ) = @_; my ( $self, $msg ) = @_;
my $logger_object = $self->[_logger_object_]; my $logger_object = $self->[_logger_object_];
if ($logger_object) { $logger_object->warning($msg); } if ($logger_object) { $logger_object->warning($msg); }
return; return;
} }
skipping to change at line 92 skipping to change at line 93
if ($logger_object) { if ($logger_object) {
$logger_object->write_logfile_entry($msg); $logger_object->write_logfile_entry($msg);
} }
return; return;
} }
sub new { sub new {
my ( $class, $line_sink_object, $rOpts, $logger_object ) = @_; my ( $class, $line_sink_object, $rOpts, $logger_object ) = @_;
my $self = []; my $self = [];
$self->[_line_sink_object_] = $line_sink_object; $self->[_line_sink_object_] = $line_sink_object;
$self->[_logger_object_] = $logger_object; $self->[_logger_object_] = $logger_object;
$self->[_rOpts_] = $rOpts; $self->[_rOpts_] = $rOpts;
$self->[_output_line_number_] = 1; $self->[_output_line_number_] = 1;
$self->[_consecutive_blank_lines_] = 0; $self->[_consecutive_blank_lines_] = 0;
$self->[_consecutive_nonblank_lines_] = 0; $self->[_consecutive_nonblank_lines_] = 0;
$self->[_first_line_length_error_] = 0; $self->[_consecutive_new_blank_lines_] = 0;
$self->[_max_line_length_error_] = 0; $self->[_first_line_length_error_] = 0;
$self->[_last_line_length_error_] = 0; $self->[_max_line_length_error_] = 0;
$self->[_first_line_length_error_at_] = 0; $self->[_last_line_length_error_] = 0;
$self->[_max_line_length_error_at_] = 0; $self->[_first_line_length_error_at_] = 0;
$self->[_last_line_length_error_at_] = 0; $self->[_max_line_length_error_at_] = 0;
$self->[_line_length_error_count_] = 0; $self->[_last_line_length_error_at_] = 0;
$self->[_max_output_line_length_] = 0; $self->[_line_length_error_count_] = 0;
$self->[_max_output_line_length_at_] = 0; $self->[_max_output_line_length_] = 0;
$self->[_rK_checklist_] = []; $self->[_max_output_line_length_at_] = 0;
$self->[_K_arrival_order_matches_] = 0; $self->[_rK_checklist_] = [];
$self->[_K_sequence_error_msg_] = ""; $self->[_K_arrival_order_matches_] = 0;
$self->[_K_last_arrival_] = -1; $self->[_K_sequence_error_msg_] = "";
$self->[_K_last_arrival_] = -1;
# save input stream name for local error messages # save input stream name for local error messages
$input_stream_name = ""; $input_stream_name = "";
if ($logger_object) { if ($logger_object) {
$input_stream_name = $logger_object->get_input_stream_name(); $input_stream_name = $logger_object->get_input_stream_name();
} }
bless $self, $class; bless $self, $class;
return $self; return $self;
} }
skipping to change at line 166 skipping to change at line 168
sub decrement_output_line_number { sub decrement_output_line_number {
$_[0]->[_output_line_number_]--; $_[0]->[_output_line_number_]--;
return; return;
} }
sub get_consecutive_nonblank_lines { sub get_consecutive_nonblank_lines {
return $_[0]->[_consecutive_nonblank_lines_]; return $_[0]->[_consecutive_nonblank_lines_];
} }
sub get_consecutive_blank_lines {
return $_[0]->[_consecutive_blank_lines_];
}
sub reset_consecutive_blank_lines { sub reset_consecutive_blank_lines {
$_[0]->[_consecutive_blank_lines_] = 0; $_[0]->[_consecutive_blank_lines_] = 0;
return; return;
} }
sub want_blank_line { sub want_blank_line {
my $self = shift; my $self = shift;
unless ( $self->[_consecutive_blank_lines_] ) { unless ( $self->[_consecutive_blank_lines_] ) {
$self->write_blank_code_line(); $self->write_blank_code_line();
} }
skipping to change at line 202 skipping to change at line 208
} }
sub write_blank_code_line { sub write_blank_code_line {
my $self = shift; my $self = shift;
my $forced = shift; my $forced = shift;
my $rOpts = $self->[_rOpts_]; my $rOpts = $self->[_rOpts_];
return return
if (!$forced if (!$forced
&& $self->[_consecutive_blank_lines_] >= && $self->[_consecutive_blank_lines_] >=
$rOpts->{'maximum-consecutive-blank-lines'} ); $rOpts->{'maximum-consecutive-blank-lines'} );
$self->[_consecutive_blank_lines_]++;
$self->[_consecutive_nonblank_lines_] = 0; $self->[_consecutive_nonblank_lines_] = 0;
# Balance old blanks against new (forced) blanks instead of writing them.
# This fixes case b1073.
if ( !$forced && $self->[_consecutive_new_blank_lines_] > 0 ) {
$self->[_consecutive_new_blank_lines_]--;
return;
}
$self->write_line("\n"); $self->write_line("\n");
$self->[_consecutive_blank_lines_]++;
$self->[_consecutive_new_blank_lines_]++ if ($forced);
return; return;
} }
sub write_code_line { sub write_code_line {
my ( $self, $str, $K ) = @_; my ( $self, $str, $K ) = @_;
$self->[_consecutive_blank_lines_] = 0; $self->[_consecutive_blank_lines_] = 0;
$self->[_consecutive_new_blank_lines_] = 0;
$self->[_consecutive_nonblank_lines_]++; $self->[_consecutive_nonblank_lines_]++;
$self->write_line($str); $self->write_line($str);
#---------------------------- #----------------------------
# Convergence and error check # Convergence and error check
#---------------------------- #----------------------------
if ( defined($K) ) { if ( defined($K) ) {
# Convergence check: we are checking if all defined K values arrive in # Convergence check: we are checking if all defined K values arrive in
# the order which was defined by the caller. Quit checking if any # the order which was defined by the caller. Quit checking if any
 End of changes. 8 change blocks. 
41 lines changed or deleted 59 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)