> Hmm, something still does not seem right. For example, try
> diff -e on the contents below (some other tests attached):
> 
> A
> B
> C
> 
> vs.
> 
> W
> X
> .
> Y
> Z
> 
> [...]
> 
> About the changes below, is something like this the idea behind it?
> The first change command has already removed lines [a,b] and replaced them
> with lines [c, c + i]. So for the rest of the lines in [c + i + 1, d], we
> need to make sure that they are appended after the line that follows the
> inserted '.'
> 
> Can't we set b = a + i - 1 and a = b + 1 to make sure that the rest
> of the 'to' file is appended after the proper line?

Yes, that's a good solution and it fixes the issue with the example
above. Updated diff below.

While testing your suggestion with the example I run into a bug with
ed-style diff handling in patch(1), resulting in incorrect output
(fix in the works). Applying the generated diff with ed(1) works fine,
though.

natano


Index: diffreg.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diffreg.c,v
retrieving revision 1.90
diff -u -p -r1.90 diffreg.c
--- diffreg.c   26 Oct 2015 12:52:27 -0000      1.90
+++ diffreg.c   21 Feb 2016 16:01:43 -0000
@@ -1075,8 +1075,9 @@ proceed:
                 * back and restart where we left off.
                 */
                diff_output(".\n");
-               diff_output("%ds/.//\n", a);
-               a += i;
+               diff_output("%ds/.//\n", a + i - 1);
+               b = a + i - 1;
+               a = b + 1;
                c += i;
                goto restart;
        }

Reply via email to