cdiff 1.1 patch #4

Larry Wall lwall at jpl-devvax.JPL.NASA.GOV
Sat Jan 7 06:37:36 AEST 1989


System: cdiff version 1.1
Patch #: 4
Priority: LOW
Subject: now passes diff switches through
Subject: handles directories better
Subject: now quotes filenames passed to subshell
From: Amos Shapir and Francois Pinard

Description:
	cdiff didn't pass diff switches through.  Now it does.

	Now one or the other of the filenames can be a directory
	holding a different version by the same name.

	The filenames passed to diff are now quoted to prevent interpretation
	of shell metacharacters (in particular, #).

Fix:	From rn, say "| patch -p -N -d DIR", where DIR is your cdiff source
	directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
	If you don't have the patch program, apply the following by hand,
	or get patch (version 2.0, latest patchlevel).

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel.h file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	If you are missing previous patches they can be obtained from me:

	Larry Wall
	lwall at jpl-devvax.jpl.nasa.gov

	If you send a mail message of the following form it will greatly speed
	processing:

	Subject: Command
	@SH mailpatch PATH cdiff 1.1 LIST
		   ^ note the c

	where PATH is a return path FROM ME TO YOU either in Internet notation,
	or in bang notation from some well-known host, and LIST is the number
	of one or more patches you need, separated by spaces, commas, and/or
	hyphens.  Saying 35- says everything from 35 to the end.


	You can also get the patches via anonymous FTP from
	jpl-devvax.jpl.nasa.gov.

Index: patchlevel.h
Prereq: 3
1c1
< #define PATCHLEVEL 3
---
> #define PATCHLEVEL 4

Index: cdiff.c
Prereq: 1.1.1.3
*** cdiff.c.old	Fri Jan  6 12:31:52 1989
--- cdiff.c	Fri Jan  6 12:31:53 1989
***************
*** 1,10 ****
! static char rcsid[] = "$Header: cdiff.c,v 1.1.1.3 88/08/04 16:08:18 lwall Exp $";
  
  /* cdiff - turns a regular diff into a new-style context diff
   *
   * Usage: cdiff file1 file2
   *
   * $Log:	cdiff.c,v $
   * Revision 1.1.1.3  88/08/04  16:08:18  lwall
   * patch3: include <stat.h> => <sys/stat.h>
   * 
--- 1,15 ----
! static char rcsid[] = "$Header: cdiff.c,v 1.1.1.4 89/01/06 12:31:41 lwall Locked $";
  
  /* cdiff - turns a regular diff into a new-style context diff
   *
   * Usage: cdiff file1 file2
   *
   * $Log:	cdiff.c,v $
+  * Revision 1.1.1.4  89/01/06  12:31:41  lwall
+  * patch4: now passes diff switches through
+  * patch4: handles directories better
+  * patch4: now quotes filenames passed to subshell
+  * 
   * Revision 1.1.1.3  88/08/04  16:08:18  lwall
   * patch3: include <stat.h> => <sys/stat.h>
   * 
***************
*** 25,31 ****
  #include <sys/stat.h>
  #include <ctype.h>
  
! char buf[512];
  
  FILE *inputfp, *oldfp, *newfp;
  
--- 30,36 ----
  #include <sys/stat.h>
  #include <ctype.h>
  
! char buf[512] = "diff ";
  
  FILE *inputfp, *oldfp, *newfp;
  
***************
*** 77,82 ****
--- 82,89 ----
  	}
  	if (argv[0][1] == 'c')
  	    context = atoi(argv[0]+2);
+ 	else
+ 	    sprintf(buf+strlen(buf), "%s ", argv[0]);
      }
  
      if (argc != 2) {
***************
*** 87,113 ****
      old = argv[0];
      new = argv[1];
  
!     sprintf(buf,"diff %s %s", old, new);
      inputfp = popen(buf, "r");
      if (!inputfp) {
! 	fprintf(stderr, "Can't execute diff %s %s\n", old, new);
  	exit(1);
      }
  
      oldfp = fopen(old,"r");
      if (!oldfp) {
  	fprintf(stderr, "Can't open %s\n", old);
  	exit(1);
      }
      newfp = fopen(new,"r");
      if (!newfp) {
  	fprintf(stderr, "Can't open %s\n", new);
  	exit(1);
      }
- 
-     fstat(fileno(oldfp),&statbuf);
-     printf("*** %s\t%s", old, ctime(&statbuf.st_mtime));
-     fstat(fileno(newfp),&statbuf);
      printf("--- %s\t%s", new, ctime(&statbuf.st_mtime));
  
      preoldend = -1000;
--- 94,130 ----
      old = argv[0];
      new = argv[1];
  
!     sprintf(buf+strlen(buf), "'%s' '%s'", old, new);
      inputfp = popen(buf, "r");
      if (!inputfp) {
! 	fprintf(stderr, "Can't execute %s\n", buf);
  	exit(1);
      }
  
+     stat(old,&statbuf);
+     if((statbuf.st_mode&S_IFMT) == S_IFDIR) {
+ 	sprintf(buf, "%s/%s", old, new);
+ 	old = buf;
+ 	stat(old,&statbuf);
+     }
      oldfp = fopen(old,"r");
      if (!oldfp) {
  	fprintf(stderr, "Can't open %s\n", old);
  	exit(1);
      }
+     printf("*** %s\t%s", old, ctime(&statbuf.st_mtime));
+ 
+     stat(new,&statbuf);
+     if((statbuf.st_mode&S_IFMT) == S_IFDIR) {
+ 	sprintf(buf, "%s/%s", new, old);
+ 	new = buf;
+ 	stat(new,&statbuf);
+     }
      newfp = fopen(new,"r");
      if (!newfp) {
  	fprintf(stderr, "Can't open %s\n", new);
  	exit(1);
      }
      printf("--- %s\t%s", new, ctime(&statbuf.st_mtime));
  
      preoldend = -1000;



More information about the Comp.sources.bugs mailing list