🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1545

GNU diff3 1.4 botches multiple contributions to an overlapping diff

#1545
From: Paul Eggert
Date: Fri, 07 Apr 1989 22:04
115 lines
2534 bytes
If more than one input difference from the same pair of files contributes to
the same overlapping difference, diff3 version 1.4 reports a high line number
by mapping from the first input difference, but it should be mapping from the
last input difference.  As a result, diff3 does not output all the lines that
it should.  Here is an example.  Suppose we have the following files.

	File 'a' contains:
	a
	b
	c
	d


	File 'b' contains:
	1
	2
	3
	4
	5
	6
	d

	File 'c' contains:
	X
	b
	Y
	c
	d

Then 'diff3 a b c' should output:

	====
	1:1,3c
	  a
	  b
	  c
	2:1,6c
	  1
	  2
	  3
	  4
	  5
	  6
	3:1,4c
	  X
	  b
	  Y
	  c

Instead, it outputs:

	====
	1:1,3c
	  a
	  b
	  c
	2:1,6c
	  1
	  2
	  3
	  4
	  5
	  6
	3:1,3c
	  X
	  b
	  Y

The last line of output is missing, and the last 1,3c should be a 1,4c.
Here is a fix.

===================================================================
RCS file: RCS/diff3.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** /tmp/,RCSt1001211	Fri Apr  7 14:38:53 1989
--- /tmp/,RCSt2001211	Fri Apr  7 14:38:54 1989
***************
*** 673,679 ****
    if (using[0])
      {
        low1 = D_LOW_MAPLINE (using[0], FILE0, FILE1, lowc);
!       high1 = D_HIGH_MAPLINE (using[0], FILE0, FILE1, highc); 
      }
    else
      {
--- 673,679 ----
    if (using[0])
      {
        low1 = D_LOW_MAPLINE (using[0], FILE0, FILE1, lowc);
!       high1 = D_HIGH_MAPLINE (last_using[0], FILE0, FILE1, highc); 
      }
    else
      {
***************
*** 688,694 ****
    if (using[1])
      {
        low2 = D_LOW_MAPLINE (using[1], FILE0, FILE1, lowc);
!       high2 = D_HIGH_MAPLINE (using[1], FILE0, FILE1, highc); 
      }
    else
      {
--- 688,694 ----
    if (using[1])
      {
        low2 = D_LOW_MAPLINE (using[1], FILE0, FILE1, lowc);
!       high2 = D_HIGH_MAPLINE (last_using[1], FILE0, FILE1, highc); 
      }
    else
      {


-- Paul Eggert, Twin Sun, Inc.  <uunet!twinsun!eggert>
Technical Details
Message-ID: <8904072204.AA01409@stand.twinsun.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!WHEATIES.AI.MIT.EDU!twinsun!stand!eggert

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!WHEATIES.AI.MIT.EDU!twinsun!stand!eggert
From: twinsun!stand!eggert@WHEATIES.AI.MIT.EDU (Paul Eggert)
Newsgroups: gnu.utils.bug
Subject: GNU diff3 1.4 botches multiple contributions to an overlapping diff
Message-ID: <8904072204.AA01409@stand.twinsun.com>
Date: 7 Apr 89 22:04:07 GMT
Sender: news@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 115