Commit 959d2da9 authored by Bernhard Link's avatar Bernhard Link

and fix another logic error..

parent a908c090
...@@ -423,8 +423,11 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi ...@@ -423,8 +423,11 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi
a->oldlinecount += p->oldlinecount - p->newlinecount; a->oldlinecount += p->oldlinecount - p->newlinecount;
lineofs += p->oldlinecount - p->newlinecount; lineofs += p->oldlinecount - p->newlinecount;
p = modification_freehead(p); p = modification_freehead(p);
/* we cannot finalize a here, as it might still if( a->oldlinecount == 0 && a->newlinecount == 0 ) {
* eat more p (in full or partial)... */ /* a exactly cancels p */
a = modification_freehead(a);
}
/* otherwise a is not yet finished, it might modify more */
continue; continue;
} }
/* otherwise something overlaps, things get complicated here: */ /* otherwise something overlaps, things get complicated here: */
...@@ -462,14 +465,22 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi ...@@ -462,14 +465,22 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi
/* finalize *a with less lines deleted:*/ /* finalize *a with less lines deleted:*/
a->oldlinestart += lineofs; a->oldlinestart += lineofs;
a->oldlinecount -= removedlines; a->oldlinecount -= removedlines;
move_queue(&last, &result, &a); if( a->oldlinecount == 0 && a->newlinecount == 0 ) {
/* a only removed something and this was hereby
* removed from p */
a = modification_freehead(a);
} else
move_queue(&last, &result, &a);
/* and reduce the number of lines of *p */ /* and reduce the number of lines of *p */
assert( removedlines < p->newlinecount );
modification_stripstartlines(p, removedlines); modification_stripstartlines(p, removedlines);
/* p->newlinecount got smaller, so less will be deleted later */ /* p->newlinecount got smaller, so less will be deleted later */
lineofs -= removedlines; lineofs -= removedlines;
if( last != NULL ) {
assert( p->oldlinestart >= last->oldlinestart + last->oldlinecount); assert( p->oldlinestart >= last->oldlinestart + last->oldlinecount);
if( a != NULL ) if( a != NULL )
assert( lineofs + a->oldlinestart >= last->oldlinestart + last->oldlinecount); assert( lineofs + a->oldlinestart >= last->oldlinestart + last->oldlinecount);
}
/* note that a->oldlinestart+a->oldlinecount+1 /* note that a->oldlinestart+a->oldlinecount+1
* == p->oldlinestart */ * == p->oldlinestart */
continue; continue;
...@@ -495,6 +506,7 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi ...@@ -495,6 +506,7 @@ retvalue combine_patches(struct modification **result_p, /*@only@*/struct modifi
* that later numbers fit */ * that later numbers fit */
n->next = NULL; n->next = NULL;
n->oldlinecount = 0; n->oldlinecount = 0;
assert( removedlines < n->newlinecount );
modification_stripendlines(n, removedlines); modification_stripendlines(n, removedlines);
lineofs += n->oldlinecount - n->newlinecount; lineofs += n->oldlinecount - n->newlinecount;
assert( lineofs+a->oldlinestart <= p->oldlinestart); assert( lineofs+a->oldlinestart <= p->oldlinestart);
......
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