From 6214f9445512b4275248cde8e6200e05c8ed1a6e Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 22 Jun 2020 17:41:11 -0700 Subject: [PATCH] minor coding cleanup --- lib/Perl/Tidy.pm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index c788488f..53bef2f3 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -1717,23 +1717,23 @@ sub line_diff { # have same common characters so non-null characters indicate character # differences. my ( $s1, $s2 ) = @_; - my $mask = $s1 ^ $s2; my $diff_marker = ""; my $pos = -1; my $pos1 = $pos; - my $count = 0; - my $len1 = length($s1); - my $len2 = length($s2); - - while ( $mask =~ /[^\0]/g ) { - $count++; - my $pos_last = $pos; - $pos = $-[0]; - if ( $count == 1 ) { $pos1 = $pos; } - $diff_marker .= ' ' x ( $pos - $pos_last - 1 ) . '^'; - - # we could continue to mark all differences, but there is no point - last; + if ( defined($s1) && defined($s2) ) { + my $count = 0; + my $mask = $s1 ^ $s2; + + while ( $mask =~ /[^\0]/g ) { + $count++; + my $pos_last = $pos; + $pos = $-[0]; + if ( $count == 1 ) { $pos1 = $pos; } + $diff_marker .= ' ' x ( $pos - $pos_last - 1 ) . '^'; + + # we could continue to mark all differences, but there is no point + last; + } } return wantarray ? ( $diff_marker, $pos1 ) : $diff_marker; } -- 2.39.5