mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
merge3: fix assert in merge of identical deletions
This commit is contained in:
parent
f63dcb4b9b
commit
d03b67430f
6 changed files with 43 additions and 4 deletions
|
@ -16,6 +16,8 @@ addchange(Diff *df, int a, int b, int c, int d)
|
|||
|
||||
if (a > b && c > d)
|
||||
return;
|
||||
if(c > d)
|
||||
d = c;
|
||||
if(df->nchanges%1024 == 0)
|
||||
df->changes = erealloc(df->changes, (df->nchanges+1024)*sizeof(df->changes[0]));
|
||||
ch = &df->changes[df->nchanges++];
|
||||
|
@ -45,7 +47,7 @@ collect(Diff *d)
|
|||
addchange(d, i1 , i0, j1, j0);
|
||||
}
|
||||
if (m == 0)
|
||||
change(d, 1, 0, 1, d->len[1]);
|
||||
addchange(d, 1, 0, 1, d->len[1]);
|
||||
qsort(d->changes, d->nchanges, sizeof(Change), changecmp);
|
||||
}
|
||||
|
||||
|
@ -70,8 +72,8 @@ same(Diff *l, Change *lc, Diff *r, Change *rc)
|
|||
ry = rc->newy;
|
||||
if(ly - lx != ry - rx)
|
||||
return 0;
|
||||
assert(lx <= ly && ly < l->len[1]);
|
||||
assert(rx <= ry && ry < r->len[1]);
|
||||
assert(lx <= ly && ly <= l->len[1]);
|
||||
assert(rx <= ry && ry <= r->len[1]);
|
||||
Bseek(l->input[1], l->ixnew[lx-1], 0);
|
||||
Bseek(r->input[1], r->ixnew[rx-1], 0);
|
||||
for(i = 0; i <= (ly - lx); i++){
|
||||
|
|
10
sys/src/cmd/diff/test/merge-t12.c
Normal file
10
sys/src/cmd/diff/test/merge-t12.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
9
sys/src/cmd/diff/test/merge-t12.expected
Normal file
9
sys/src/cmd/diff/test/merge-t12.expected
Normal file
|
@ -0,0 +1,9 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
10
|
9
sys/src/cmd/diff/test/merge-t12.l
Normal file
9
sys/src/cmd/diff/test/merge-t12.l
Normal file
|
@ -0,0 +1,9 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
10
|
9
sys/src/cmd/diff/test/merge-t12.r
Normal file
9
sys/src/cmd/diff/test/merge-t12.r
Normal file
|
@ -0,0 +1,9 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
10
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/rc
|
||||
|
||||
tests=`{seq 11}
|
||||
tests=`{seq 12}
|
||||
for(t in $tests){
|
||||
echo ../$O.merge3 merge-t$t.l merge-t$t.c merge-t$t.r
|
||||
../$O.merge3 merge-t$t.l merge-t$t.c merge-t$t.r > merge-t$t.out
|
||||
|
|
Loading…
Reference in a new issue