Subject: | diff3 confused by change in middle of deletion |
Thanks for Algorithm::Merge. I'm finding it extremely useful. However, I've found a situation where it gives very odd output.
I'm using this version of Algorithm::Merge:
$VERSION = '0.05';
$REVISION = (qw$Revision: 1.11 $)[-1];
And this version of Algorithm::Diff:
$VERSION = 1.19_01;
With Perl: This is perl, v5.8.4 built for i386-linux-thread-multi
On Debian testing: Linux sheol.chthonic.net 2.4.25-1-386 #2 Wed Apr 14 19:38:08 EST 2004 i686 GNU/Linux
diff3 seems to get confused when you diff a deletion against a change in the middle of that deletion. Instead of 'c', it gives 'r', and the left change is a misplaced element. Here's a sample:
#!/usr/bin/perl
use Algorithm::Merge qw(diff3);
@a = qw(1 2 3 4 5 6 7);
@b = qw(1 2 6 7);
@c = qw(1 2 3 0 5 6 7);
my @diff = diff3(\@a, \@b, \@c);
foreach $row (@diff) {
print join(" ", map { defined($_) ? $_ : '-' } @$row) . "\n";
}
This code gives:
# yields:
u 1 1 1
u 2 2 2
l 3 - 3
r 4 1 0 <- shouldn't this be 'c 4 - 0'? why the 1?
l 5 - 5
u 6 6 6
u 7 7 7
I can see the argument that the change to get from @a to @c is 4 -> 0, and with @a to @b being -3 -4 -5, that suggests:
l 3 - 3
o 4 - -
r - - 0
l 5 - 5
In any case, the presence of that stray 1 bothers me.