From: Steve Hancock Date: Sun, 21 Jun 2020 14:25:20 +0000 (-0700) Subject: fixed an undefined variable in --assert-tidy warning message X-Git-Tag: 20200619.02~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e7856b0afe600e0fc591d1258d7f07c7bb1d52b7;p=perltidy.git fixed an undefined variable in --assert-tidy warning message --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 0d840985..f71de433 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -1469,8 +1469,10 @@ EOM $is_encoded_data ); $logger_object->warning(<interrupt_logfile(); + $logger_object->warning( $diff_msg . "\n" ); + $logger_object->resume_logfile(); } } if ( $rOpts->{'assert-untidy'} ) { @@ -1711,34 +1713,44 @@ sub compare_string_buffers { my $leni = length($bufi); my $leno = length($bufo); my $msg = - "Input file length is $leni chars, output file length is $leno chars\n"; + "Input file length is $leni chars\nOutput file length is $leno chars\n"; return $msg unless $leni && $leno; my ( $fhi, $fnamei ) = streamhandle( \$bufi, 'r', $is_encoded_data ); my ( $fho, $fnameo ) = streamhandle( \$bufo, 'r', $is_encoded_data ); return $msg unless ( $fho && $fhi ); # for safety, shouldn't happen - my ( $linei, $lineo ); - my ( $counti, $counto ) = ( 0, 0 ); + my ( $linei, $lineo ); + my ( $counti, $counto ) = ( 0, 0 ); + my ( $last_nonblank_line, $last_nonblank_count ) = ( "", 0 ); while (1) { - my $last_common_line = $linei; + if ($linei) { + $last_nonblank_line = $linei; + $last_nonblank_count = $counti; + } $linei = $fhi->getline(); $lineo = $fho->getline(); # compare chomp'ed lines + if ( defined($linei) ) { $counti++; chomp $linei } if ( defined($lineo) ) { $counto++; chomp $lineo } # see if one or both ended before a difference - last unless ( $counti == $counto ); + last unless ( defined($linei) && defined($lineo) ); if ( $linei ne $lineo ) { + + my ( $trimi, $trimo ) = ( $linei, $lineo ); + $trimi =~ s/\s+$//; + $trimo =~ s/\s+$//; + my $reason = + ( $trimi eq $trimo ) ? " (trailing whitespace difference)" : ""; $msg .= < $counto ) { $msg .= <