Commit b1317e9f authored by bugreport%peshkin.net's avatar bugreport%peshkin.net

Bug 226411: make DiffStrings handle fields with duplicate values

patch by jouni r=joel,myk a=justdave
parent 4f7b9f55
......@@ -1404,20 +1404,20 @@ sub DiffStrings {
my @old = split(" ", $oldstr);
my @new = split(" ", $newstr);
my (@remove, @add) = ();
# Find values that were removed
foreach my $value (@old) {
push (@remove, $value) if !grep($_ eq $value, @new);
}
# Find values that were added
foreach my $value (@new) {
push (@add, $value) if !grep($_ eq $value, @old);
# For each pair of (old, new) entries:
# If they're equal, set them to empty. When done, @old contains entries
# that were removed; @new contains ones that got added.
foreach my $oldv (@old) {
foreach my $newv (@new) {
next if ($newv eq '');
if ($oldv eq $newv) {
$newv = $oldv = '';
}
}
}
my $removed = join (", ", @remove);
my $added = join (", ", @add);
my $removed = join (", ", grep { $_ ne '' } @old);
my $added = join (", ", grep { $_ ne '' } @new);
return ($removed, $added);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment