]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 226411: make DiffStrings handle fields with duplicate values
authorbugreport%peshkin.net <>
Thu, 13 May 2004 06:57:31 +0000 (06:57 +0000)
committerbugreport%peshkin.net <>
Thu, 13 May 2004 06:57:31 +0000 (06:57 +0000)
patch by jouni
r=joel,myk
a=justdave

globals.pl

index 055584f7ef6d2cc24c743c6ec369531a101f351d..7439940c350b1fc22f40de2374b901ff13d70f77 100644 (file)
@@ -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);
 }