🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1695

Re: Need RCS variant of diff3

#1695
From: trinkle
Date: Wed, 10 Jan 1990 13:07
180 lines
5121 bytes
     The GNU diff3 works for ci and co, but does not work for rcsmerge
(which uses the merge script).  I have included a different version of
merge for the GNU diff3 and a patch to GNU diff3 to make it return the
number of overlaps as it's exit status.  Please let me know if this
works for you.  If I get enough positive feedback on the GNU
diff/merge stuff, I will encourage GNU to modify diff3 or add an
option that will cause it to return the number of overlaps.

     The diff/diff3 source used to be distributed with RCS, but it was
discontinued because it was a violation of licenses.

Daniel Trinkle			trinkle@cs.purdue.edu
Dept. of Computer Sciences	{backbone}!purdue!trinkle
Purdue University		317-494-7844
West Lafayette, IN 47907

============================== merge.sh ==============================


PATH=/bin:/usr/bin
DIFF=/usr/new/bin/diff
DIFF3="/usr/new/bin/diff3 -C"
p=w
case $1 in
-p)
	p='1,$p'
	shift
esac

case $# in
0|1|2)
	echo >&2 "merge: usage: merge [-p] file1 file2 file3"
	exit 1
esac

case $p in
w)
	if test ! -w $1
	then
		echo >&2 "$1 not writeable"
		exit 1
	fi
esac

trap 's=$?; rm -f /tmp/d3a$$ /tmp/d3b$$; exit $s' 0
trap exit 1 2 3 13 15
umask 077

{
	$DIFF3 -E $1 $2 $3
	case $? in
	0) ;;
	1) echo >&2 merge: warning: 1 overlap during merge.;;
	*) echo >&2 merge: warning: $? overlaps during merge.
	esac
	echo 'g/^>>>>>>> '$3'$/s//>>>>>>> '$5'/'
	echo $p
} | ed - $1
============================== diff3.c.patch ==============================
*** diff3.c.old	Tue Dec 19 14:50:53 1989
--- diff3.c	Tue Dec 19 14:49:44 1989
***************
*** 192,198 ****
  struct diff_block *process_diff ();
  struct diff3_block *make_3way_diff ();
  void output_diff3 ();
! void output_diff3_edscript ();
  void usage ();
  
  struct diff3_block *using_to_diff3_block ();
--- 192,198 ----
  struct diff_block *process_diff ();
  struct diff3_block *make_3way_diff ();
  void output_diff3 ();
! int output_diff3_edscript ();
  void usage ();
  
  struct diff3_block *using_to_diff3_block ();
***************
*** 229,234 ****
--- 229,235 ----
    int mapping [3];
    int shiftmap;
    int incompat;
+   int overlap_count;
    struct diff_block *thread1, *thread2;
    struct diff3_block *diff;
  
***************
*** 308,319 ****
      }
    diff = make_3way_diff (thread1, thread2);
    if (edscript)
!     output_diff3_edscript (stdout, diff, mapping, argv[optind],
  			   argv[optind + 1], argv[optind + 2]);
    else
      output_diff3 (stdout, diff, mapping);
  
!   exit (0);
  }
        
  /*
--- 309,323 ----
      }
    diff = make_3way_diff (thread1, thread2);
    if (edscript)
!     overlap_count = output_diff3_edscript (stdout, diff, mapping, argv[optind],
  			   argv[optind + 1], argv[optind + 2]);
    else
      output_diff3 (stdout, diff, mapping);
  
!   if (edscript)
!     exit(overlap_count);
!   else
!     exit (0);
  }
        
  /*
***************
*** 1287,1296 ****
   * on which it works.  Thus file0, file1, and file2 are the filenames
   * passed on the command line.
   *
   * See options.h for documentation on the global variables which this
   * routine pays attention to.
   */
! void
  output_diff3_edscript (outputfile, diff, mapping, file0, file1, file2)
       FILE *outputfile;
       struct diff3_block *diff;
--- 1291,1302 ----
   * on which it works.  Thus file0, file1, and file2 are the filenames
   * passed on the command line.
   *
+  * Returns the number of overlaps.
+  *
   * See options.h for documentation on the global variables which this
   * routine pays attention to.
   */
! int
  output_diff3_edscript (outputfile, diff, mapping, file0, file1, file2)
       FILE *outputfile;
       struct diff3_block *diff;
***************
*** 1300,1309 ****
--- 1306,1317 ----
    int rev_mapping[3];
    int i;
    int leading_dot;
+   int overlap_count;
    struct diff3_block *newblock, *thisblock;
    char *cp;
  
    leading_dot = 0;
+   overlap_count = 0;
  
    for (i = 0; i < 3; i++)
      rev_mapping [mapping [i]] = i;
***************
*** 1348,1353 ****
--- 1356,1362 ----
  	      putc ('\n', outputfile);
  	    }
  	  fprintf (outputfile, ">>>>>>> %s\n.\n", file2);
+ 	  overlap_count++;
  
  	  /* Add in code to take care of leading dots, if necessary. */
  	  if (leading_dot)
***************
*** 1421,1426 ****
--- 1430,1436 ----
  	}
      }
    if (finalwrite) fprintf (outputfile, "w\nq\n");
+   return(overlap_count);
  }
  
  /*
======================================================================
Technical Details
Message-ID: <9001101307.AA18323@bors.cs.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!CS.PURDUE.EDU!trinkle
References: <9001101021.AA02717@uunet.uu.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!CS.PURDUE.EDU!trinkle
From: trinkle@CS.PURDUE.EDU
Newsgroups: gnu.utils.bug
Subject: Re: Need RCS variant of diff3
Message-ID: <9001101307.AA18323@bors.cs.purdue.edu>
Date: 10 Jan 90 13:07:46 GMT
References: <9001101021.AA02717@uunet.uu.net>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 180