From: Steve Hancock Date: Tue, 23 Jun 2020 00:41:11 +0000 (-0700) Subject: minor coding cleanup X-Git-Tag: 20200619.02~17 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6214f9445512b4275248cde8e6200e05c8ed1a6e;p=perltidy.git minor coding cleanup --- 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; }