[gnu.utils.bug] Diff enhancements

rbj@DSYS.NCSL.NIST.GOV (Root Boy Jim) (08/16/89)

This is not really a bug, but a request for an enhancement. At USENIX,
I talked with Keith Bostic about this and I have good reason to believe
that he will add it. I have sent him the diffs for 4.3 as well.

The problem with diff is that it has no way just to tell you that
source files differ; it insists on telling you what the differences
are. The GNU project has added the -a option to tell diff that all
files are to be treated as text; my -q option tells diff to treat
them all as binary. The message produced is "Source files %s and %s differ",
which may be grep'ed for in the output.

Here are the diffs, and two runs showing the output produced.

========================================================================
*** analyze.c.orig	Fri Feb 24 12:42:16 1989
--- analyze.c	Wed Aug 16 11:13:56 1989
***************
*** 23,28 ****
--- 23,30 ----
  
  #include "diff.h"
  
+ extern int quick;					/*RBJ*/
+ 
  extern int no_discards;
  
  static int *xvec, *yvec;	/* Vectors being compared. */
***************
*** 660,672 ****
       compare the two files as binary.  This can happen
       only when the first chunk is read.  */
  
!   if (binary)
      {
        int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  		     || bcmp (filevec[0].buffer, filevec[1].buffer,
  			      filevec[1].buffered_chars));
        if (differs) 
! 	message ("Binary files %s and %s differ\n",
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
--- 662,676 ----
       compare the two files as binary.  This can happen
       only when the first chunk is read.  */
  
!   if (binary || quick)				/*RBJ*/
      {
        int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  		     || bcmp (filevec[0].buffer, filevec[1].buffer,
  			      filevec[1].buffered_chars));
        if (differs) 
! 	message (binary ?
! 		 "Binary files %s and %s differ\n" :
! 		 "Source files %s and %s differ\n",
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
*** diff.c.orig	Wed Apr 26 15:38:27 1989
--- diff.c	Wed Aug 16 11:10:11 1989
***************
*** 24,30 ****
--- 24,33 ----
  #include "regex.h"
  #include "diff.h"
  
+ /* RBJ nonzero for -q */
  
+ int quick;
+ 
  /* Nonzero for -r: if comparing two directories,
     compare their common subdirectories recursively.  */
  
***************
*** 105,111 ****
  
    /* Decode the options.  */
  
!   while ((c = getopt (argc, argv, "0123456789abBcC:defF:hHiI:lnNprsS:tTw"))
  	 != EOF)
      {
        switch (c)
--- 108,114 ----
  
    /* Decode the options.  */
  
!   while ((c = getopt (argc, argv, "0123456789abBcC:defF:hHiI:lnNqprsS:tTw"))
  	 != EOF)
      {
        switch (c)
***************
*** 235,240 ****
--- 238,248 ----
  	  specify_style (OUTPUT_CONTEXT);
  	  function_regexp = "^[_a-zA-Z]";
  	  break;
+ 
+ 	case 'q':	/*RBJ*/
+ 		/* When comparing directorys, no source diffs */
+ 		quick = 1;
+ 		break;
  
  	case 'r':
  	  /* When comparing directories, 
========================================================================

/p/x/gnu/diff.sun [rbj@dsys 44] diff -rc ../diff .
diff -rc ../diff/Makefile ./Makefile
*** ../diff/Makefile	Fri Feb 24 12:40:43 1989
--- ./Makefile	Wed Aug 16 11:01:06 1989
***************
*** 23,29 ****
  # Also, gcc supports -O and -g together.
  CC=gcc -O
  CFLAGS = -g
! INSTALL = install
  
  # On system V, enable these three lines:
  # CFLAGS = -g -DUSG
--- 23,29 ----
  # Also, gcc supports -O and -g together.
  CC=gcc -O
  CFLAGS = -g
! INSTALL = install -c
  
  # On system V, enable these three lines:
  # CFLAGS = -g -DUSG
***************
*** 53,59 ****
  context.o diff.o: regex.h
  
  diff3.o: diff3.c
! 	$(CC) -c $(CFLAGS) -DDIFF_PROGRAM=\"$(bindir)/diff\" diff3.c
  
  clean:
  	rm -f *.o diff diff3 diff.tar diff.tar.Z
--- 53,59 ----
  context.o diff.o: regex.h
  
  diff3.o: diff3.c
! 	$(CC) -c $(CFLAGS) -DDIFF_PROGRAM=\"$(bindir)/gdiff\" diff3.c
  
  clean:
  	rm -f *.o diff diff3 diff.tar diff.tar.Z
***************
*** 60,74 ****
  
  install: install-diff install-diff3
  
! install-diff: $(prefix)$(bindir)/diff
  
! $(prefix)$(bindir)/diff: diff
! 	$(INSTALL) diff $(prefix)$(bindir)/diff
  
! install-diff3: $(prefix)$(bindir)/diff3
  
! $(prefix)$(bindir)/diff3: diff3
! 	$(INSTALL) diff3 $(prefix)$(bindir)/diff3
  
  diff.tar: $(tapefiles)
  	mkdir tmp
--- 60,74 ----
  
  install: install-diff install-diff3
  
! install-diff: $(prefix)$(bindir)/gdiff
  
! $(prefix)$(bindir)/gdiff: diff
! 	$(INSTALL) diff $(prefix)$(bindir)/gdiff
  
! install-diff3: $(prefix)$(bindir)/gdiff3
  
! $(prefix)$(bindir)/gdiff3: diff3
! 	$(INSTALL) diff3 $(prefix)$(bindir)/gdiff3
  
  diff.tar: $(tapefiles)
  	mkdir tmp
Only in .: Makefile.orig
Only in .: Makefile.~1~
Only in .: TAGS
diff -rc ../diff/analyze.c ./analyze.c
*** ../diff/analyze.c	Fri Feb 24 12:42:16 1989
--- ./analyze.c	Wed Aug 16 11:13:56 1989
***************
*** 23,28 ****
--- 23,30 ----
  
  #include "diff.h"
  
+ extern int quick;					/*RBJ*/
+ 
  extern int no_discards;
  
  static int *xvec, *yvec;	/* Vectors being compared. */
***************
*** 660,672 ****
       compare the two files as binary.  This can happen
       only when the first chunk is read.  */
  
!   if (binary)
      {
        int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  		     || bcmp (filevec[0].buffer, filevec[1].buffer,
  			      filevec[1].buffered_chars));
        if (differs) 
! 	message ("Binary files %s and %s differ\n",
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
--- 662,676 ----
       compare the two files as binary.  This can happen
       only when the first chunk is read.  */
  
!   if (binary || quick)				/*RBJ*/
      {
        int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  		     || bcmp (filevec[0].buffer, filevec[1].buffer,
  			      filevec[1].buffered_chars));
        if (differs) 
! 	message (binary ?
! 		 "Binary files %s and %s differ\n" :
! 		 "Source files %s and %s differ\n",
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
Only in .: analyze.c.orig
Only in .: analyze.c.~1~
Only in .: analyze.o
Only in .: context.o
Only in .: diff
diff -rc ../diff/diff.c ./diff.c
*** ../diff/diff.c	Wed Apr 26 15:38:27 1989
--- ./diff.c	Wed Aug 16 11:10:11 1989
***************
*** 24,30 ****
--- 24,33 ----
  #include "regex.h"
  #include "diff.h"
  
+ /* RBJ nonzero for -q */
  
+ int quick;
+ 
  /* Nonzero for -r: if comparing two directories,
     compare their common subdirectories recursively.  */
  
***************
*** 105,111 ****
  
    /* Decode the options.  */
  
!   while ((c = getopt (argc, argv, "0123456789abBcC:defF:hHiI:lnNprsS:tTw"))
  	 != EOF)
      {
        switch (c)
--- 108,114 ----
  
    /* Decode the options.  */
  
!   while ((c = getopt (argc, argv, "0123456789abBcC:defF:hHiI:lnNqprsS:tTw"))
  	 != EOF)
      {
        switch (c)
***************
*** 235,240 ****
--- 238,248 ----
  	  specify_style (OUTPUT_CONTEXT);
  	  function_regexp = "^[_a-zA-Z]";
  	  break;
+ 
+ 	case 'q':	/*RBJ*/
+ 		/* When comparing directorys, no source diffs */
+ 		quick = 1;
+ 		break;
  
  	case 'r':
  	  /* When comparing directories, 
Only in .: diff.c.orig
Only in .: diff.c.~1~
Only in .: diff.o
Only in .: diff3
Only in .: diff3.o
Only in .: diffs
Only in .: dir.o
Only in .: ed.o
Only in .: io.o
Only in .: normal.o
Only in .: regex.o
Only in .: util.o
/p/x/gnu/diff.sun [rbj@dsys 45]diff -rcq ../diff .
Source files ../diff/Makefile and ./Makefile differ
Only in .: Makefile.orig
Only in .: Makefile.~1~
Only in .: TAGS
Source files ../diff/analyze.c and ./analyze.c differ
Only in .: analyze.c.orig
Only in .: analyze.c.~1~
Only in .: analyze.o
Only in .: context.o
Only in .: diff
Source files ../diff/diff.c and ./diff.c differ
Only in .: diff.c.orig
Only in .: diff.c.~1~
Only in .: diff.o
Only in .: diff3
Only in .: diff3.o
Only in .: diffs
Only in .: dir.o
Only in .: ed.o
Only in .: io.o
Only in .: normal.o
Only in .: regex.o
Only in .: util.o
/p/x/gnu/diff.sun [rbj@dsys 46] 

	Root Boy Jim
	Have GNU, Will Travel.