[comp.os.minix] My recent patch to diff.c

morearty@cory.Berkeley.EDU.UUCP (06/07/87)

It seems that my recent posting with an improvement for diff.c
was not very clear.  Sorry about that.  This is a clarification.

As originally written, after finding a difference between the two
files, diff would go on to think it had found the common point
after finding the FIRST line that was identical in the two files.
So, for example, if file 1 contains:

     main()

     {
          printf("hello, world\n");
     }

and file 2 contains:

     /* a simple program */

     main()

     {
          printf("hello, world\n");
     }

diff would read the first line of each file and think, "Aha, a
difference."  Then it would read the second line of each file
(they are both blank) and think, "Aha, identical lines!  So the
difference is, '1c1'."  But obviously, it would be better if the
difference were given as "1a1,2".  (In the first case, it would
go on to find other differences also.)

This is the purpose of my patch.  Instead of assuming after
reading the second line of each file that it had found lines that
were common to both files, it would instead go on to check lines
three and four.  It would actually find a set of three common
lines when it found

     main()

     {

in both files.  I hope this helps clarify things (as confusing as
my description may be).

--
Mike Morearty
ARPA: morearty@cory.Berkeley.EDU	USENET: ucbvax!cory!morearty