3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

Show "No difference." when code is the same in cc diff

This commit is contained in:
Pragmatic Software 2013-08-24 15:01:31 +00:00
parent cb74a9be1e
commit 4adedc2a90
2 changed files with 11 additions and 7 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 424, BUILD_REVISION => 425,
BUILD_DATE => "2013-08-23", BUILD_DATE => "2013-08-24",
}; };
1; 1;

View File

@ -186,11 +186,15 @@ if($code =~ m/^\s*diff\s*$/i) {
} else { } else {
use Text::WordDiff; use Text::WordDiff;
my $diff = word_diff \$last_code[1], \$last_code[0], { STYLE => 'MARKUP' }; my $diff = word_diff \$last_code[1], \$last_code[0], { STYLE => 'MARKUP' };
if($diff !~ /(?:<del>|<ins>)/) {
$diff = "No difference.";
} else {
$diff =~ s/<del>([^\s]+)(\s+)<\/del>/<del>$1<\/del>$2/g; $diff =~ s/<del>([^\s]+)(\s+)<\/del>/<del>$1<\/del>$2/g;
$diff =~ s/<ins>([^\s]+)(\s+)<\/ins>/<ins>$1<\/ins>$2/g; $diff =~ s/<ins>([^\s]+)(\s+)<\/ins>/<ins>$1<\/ins>$2/g;
$diff =~ s/<del>((?:(?!<del>).)*)<\/del>\s*<ins>((?:(?!<ins>).)*)<\/ins>/<replaced `$1` with `$2`>/g; $diff =~ s/<del>((?:(?!<del>).)*)<\/del>\s*<ins>((?:(?!<ins>).)*)<\/ins>/<[replaced `$1` with `$2`]>/g;
$diff =~ s/<del>(.*?)<\/del>/<removed `$1`>/g; $diff =~ s/<del>(.*?)<\/del>/<[removed `$1`]>/g;
$diff =~ s/<ins>(.*?)<\/ins>/<inserted `$1`>/g; $diff =~ s/<ins>(.*?)<\/ins>/<[inserted `$1`]>/g;
}
print "$nick: $diff\n"; print "$nick: $diff\n";
} }