Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2012 16:12:02 +0000
From:      jhagewood@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r239767 - in soc2012/jhagewood/diff: . diff
Message-ID:  <20120725161202.67F81106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhagewood
Date: Wed Jul 25 16:12:02 2012
New Revision: 239767
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239767

Log:
  Added gz file opening to diff

Modified:
  soc2012/jhagewood/diff/diff/Makefile
  soc2012/jhagewood/diff/diff/diffreg.c
  soc2012/jhagewood/diff/hagewood-diff.patch

Modified: soc2012/jhagewood/diff/diff/Makefile
==============================================================================
--- soc2012/jhagewood/diff/diff/Makefile	Wed Jul 25 16:10:20 2012	(r239766)
+++ soc2012/jhagewood/diff/diff/Makefile	Wed Jul 25 16:12:02 2012	(r239767)
@@ -3,7 +3,7 @@
 
 DEBUG_FLAGS+= -g
 
-PROG=	diff
+PROG=	diff xdiff
 SRCS=	diff.c diffdir.c diffreg.c
 CFLAGS+=	-std=c99 -Wall -pedantic
 

Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c	Wed Jul 25 16:10:20 2012	(r239766)
+++ soc2012/jhagewood/diff/diff/diffreg.c	Wed Jul 25 16:12:02 2012	(r239767)
@@ -78,6 +78,7 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -305,10 +306,14 @@
 int
 diffreg(char *ofile1, char *ofile2, int flags)
 {
+	char *buf;
 	char *file1 = ofile1;
 	char *file2 = ofile2;
 	FILE *f1 = NULL;
 	FILE *f2 = NULL;
+	gzFile *gz1 = NULL;
+	gzFile *gz2 = NULL;
+	int bytesread;
 	int	rval = D_SAME;
 	int	i, ostdout = -1;
 	pid_t pid = -1;
@@ -338,8 +343,11 @@
 		else {
 			if (filebehave == FILE_NORMAL) 
 				f1 = fopen(file1, "r");
-			if (filebehave == FILE_GZIP)
-				f1 = gzopen(file1, "r");
+			if (filebehave == FILE_GZIP) {
+				gz1 = gzopen(file1, "r");
+				gzread(gz1, buf, MAX_INT);
+				f1 = fdopen(buf, "r");
+			}
 		}
 	}
 	if (f1 == NULL) {
@@ -364,7 +372,9 @@
 			if (filebehave == FILE_NORMAL) 
 				f2 = fopen(file2, "r");
 			if (filebehave == FILE_GZIP)
-				f2 = gzopen(file2, "r");
+				gz2 = gzopen(file2, "r");
+				gzread(gz2, buf, MAX_INT);
+				f2 = fdopen(buf, "r");
 		}
 	}
 	if (f2 == NULL) {

Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch	Wed Jul 25 16:10:20 2012	(r239766)
+++ soc2012/jhagewood/diff/hagewood-diff.patch	Wed Jul 25 16:12:02 2012	(r239767)
@@ -1,6 +1,6 @@
 diff -rupN diff-orig/diff.c diff/diff.c
---- diff-orig/diff.c	2012-07-23 02:07:00.000000000 -0400
-+++ diff/diff.c	2012-07-23 21:17:49.000000000 -0400
+--- diff-orig/diff.c	2012-07-25 11:37:23.299991134 -0400
++++ diff/diff.c	2012-07-25 11:37:23.727991128 -0400
 @@ -1,4 +1,4 @@
 -/*-
 +/*
@@ -57,7 +57,7 @@
  
  
  /* Options which exceed manageable alphanumeric assignments */ 
-@@ -69,107 +68,163 @@ enum 
+@@ -69,107 +68,163 @@ enum
    OPT_STRIPCR,
    OPT_NORMAL,
    OPT_LEFTC,
@@ -639,47 +639,9 @@
 -	exit(2);
 +	exit(1);
  }
-diff -rupN diff-orig/diff.h diff/diff.h
---- diff-orig/diff.h	2012-07-23 02:07:00.000000000 -0400
-+++ diff/diff.h	2012-07-23 21:13:42.000000000 -0400
-@@ -48,6 +48,8 @@
- #define	D_NREVERSE	5	/* Reverse ed script with numbered
- 				   lines and no trailing . */
- #define	D_BRIEF		6	/* Say if the files differ */
-+#define D_GF		7	/* Group format */
-+#define	D_LF		8	/* Line format */
- 
- /*
-  * Output flags
-@@ -70,15 +72,22 @@
- #define	D_SKIPPED1	8	/* path1 was a special file */
- #define	D_SKIPPED2	9	/* path2 was a special file */
- 
-+/*
-+ * File input types
-+ */
-+#define FILE_NORMAL	0
-+#define FILE_GZIP	1
-+
- struct excludes {
- 	char		*pattern;
- 	struct excludes	*next;
- };
- 
--extern int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
--		 sflag, tflag, Tflag, wflag;
--extern int	 Bflag, strip_cr, tabsize;
-+extern int	 aflag, bflag, cflag, dflag, Eflag, Fromflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
-+		 sflag, tflag, Tflag, Toflag, wflag;
-+extern int	 Bflag, strip_cr, suppress_cl, tabsize;
- extern int	 format, context, status;
-+extern int	 filebehave;
- extern char	 ignore_file_case;
- extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
- extern struct	 stat stb1, stb2;
 diff -rupN diff-orig/diffdir.c diff/diffdir.c
---- diff-orig/diffdir.c	2012-07-23 02:07:00.000000000 -0400
-+++ diff/diffdir.c	2012-07-23 02:07:00.000000000 -0400
+--- diff-orig/diffdir.c	2012-07-25 11:37:23.299991134 -0400
++++ diff/diffdir.c	2012-07-25 11:37:23.726991126 -0400
 @@ -20,13 +20,13 @@
  
  #include <sys/cdefs.h>
@@ -786,9 +748,47 @@
  
  	strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1);
  	if (stat(path1, &stb1) != 0) {
+diff -rupN diff-orig/diff.h diff/diff.h
+--- diff-orig/diff.h	2012-07-25 11:37:23.300991134 -0400
++++ diff/diff.h	2012-07-25 11:37:23.728991128 -0400
+@@ -48,6 +48,8 @@
+ #define	D_NREVERSE	5	/* Reverse ed script with numbered
+ 				   lines and no trailing . */
+ #define	D_BRIEF		6	/* Say if the files differ */
++#define D_GF		7	/* Group format */
++#define	D_LF		8	/* Line format */
+ 
+ /*
+  * Output flags
+@@ -70,15 +72,22 @@
+ #define	D_SKIPPED1	8	/* path1 was a special file */
+ #define	D_SKIPPED2	9	/* path2 was a special file */
+ 
++/*
++ * File input types
++ */
++#define FILE_NORMAL	0
++#define FILE_GZIP	1
++
+ struct excludes {
+ 	char		*pattern;
+ 	struct excludes	*next;
+ };
+ 
+-extern int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
+-		 sflag, tflag, Tflag, wflag;
+-extern int	 Bflag, strip_cr, tabsize;
++extern int	 aflag, bflag, cflag, dflag, Eflag, Fromflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
++		 sflag, tflag, Tflag, Toflag, wflag;
++extern int	 Bflag, strip_cr, suppress_cl, tabsize;
+ extern int	 format, context, status;
++extern int	 filebehave;
+ extern char	 ignore_file_case;
+ extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
+ extern struct	 stat stb1, stb2;
 diff -rupN diff-orig/diffreg.c diff/diffreg.c
---- diff-orig/diffreg.c	2012-07-23 02:07:00.000000000 -0400
-+++ diff/diffreg.c	2012-07-23 21:32:34.000000000 -0400
+--- diff-orig/diffreg.c	2012-07-25 11:37:23.298991134 -0400
++++ diff/diffreg.c	2012-07-25 12:07:51.966957049 -0400
 @@ -62,15 +62,13 @@
   *	@(#)diffreg.c   8.1 (Berkeley) 6/6/93
   */
@@ -809,7 +809,14 @@
  
  #include <sys/param.h>
  #include <sys/stat.h>
-@@ -86,10 +84,23 @@ __FBSDID("$FreeBSD");
+@@ -80,16 +78,30 @@ __FBSDID("$FreeBSD");
+ #include <err.h>
+ #include <errno.h>
+ #include <fcntl.h>
++#include <limits.h>
+ #include <stddef.h>
+ #include <stdint.h>
+ #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
@@ -833,7 +840,7 @@
  /*
   * diff - compare two files.
   */
-@@ -181,47 +192,47 @@ struct context_vec {
+@@ -181,47 +193,47 @@ struct context_vec {
  };
  
  static FILE	*opentemp(const char *);
@@ -916,7 +923,7 @@
  static struct line *sfile[2];	/* shortened by pruning common prefix/suffix */
  static u_char *chrtran;		/* translation table for case-folding */
  static struct context_vec *context_vec_start;
-@@ -294,13 +305,13 @@ u_char cup2low[256] = {
+@@ -294,13 +306,17 @@ u_char cup2low[256] = {
  int
  diffreg(char *ofile1, char *ofile2, int flags)
  {
@@ -927,17 +934,21 @@
 -	int	 rval = D_SAME;
 -	int	 i, ostdout = -1;
 -	pid_t	 pid = -1;
++	char *buf;
 +	char *file1 = ofile1;
 +	char *file2 = ofile2;
 +	FILE *f1 = NULL;
 +	FILE *f2 = NULL;
++	gzFile *gz1 = NULL;
++	gzFile *gz2 = NULL;
++	int bytesread;
 +	int	rval = D_SAME;
 +	int	i, ostdout = -1;
 +	pid_t pid = -1;
  
  	anychange = 0;
  	lastline = 0;
-@@ -310,7 +321,7 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -310,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int
  	if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))
  		return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);
  	if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0)
@@ -946,7 +957,7 @@
  
  	if (flags & D_EMPTY1)
  		f1 = fopen(_PATH_DEVNULL, "r");
-@@ -320,17 +331,21 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -320,17 +336,24 @@ diffreg(char *ofile1, char *ofile2, int
  			    fstat(fileno(f1), &stb1) < 0) {
  				warn("%s", file1);
  				status |= 2;
@@ -960,8 +971,11 @@
 +		else {
 +			if (filebehave == FILE_NORMAL) 
 +				f1 = fopen(file1, "r");
-+			if (filebehave == FILE_GZIP)
-+				f1 = gzopen(file1, "r");
++			if (filebehave == FILE_GZIP) {
++				gz1 = gzopen(file1, "r");
++				gzread(gz1, buf, MAX_INT);
++				f1 = fdopen(buf, "r");
++			}
 +		}
  	}
  	if (f1 == NULL) {
@@ -972,7 +986,7 @@
  	}
  
  	if (flags & D_EMPTY2)
-@@ -341,34 +356,37 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -341,34 +364,39 @@ diffreg(char *ofile1, char *ofile2, int
  			    fstat(fileno(f2), &stb2) < 0) {
  				warn("%s", file2);
  				status |= 2;
@@ -987,7 +1001,9 @@
 +			if (filebehave == FILE_NORMAL) 
 +				f2 = fopen(file2, "r");
 +			if (filebehave == FILE_GZIP)
-+				f2 = gzopen(file2, "r");
++				gz2 = gzopen(file2, "r");
++				gzread(gz2, buf, MAX_INT);
++				f2 = fdopen(buf, "r");
 +		}
  	}
  	if (f2 == NULL) {
@@ -1019,7 +1035,7 @@
  	}
  	if (lflag) {
  		/* redirect stdout to pr */
-@@ -452,7 +470,11 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -452,7 +480,11 @@ diffreg(char *ofile1, char *ofile2, int
  		}
  		waitpid(pid, &wstatus, 0);
  	}
@@ -1032,7 +1048,7 @@
  	if (anychange) {
  		status |= 1;
  		if (rval == D_SAME)
-@@ -477,8 +499,8 @@ closem:
+@@ -477,8 +509,8 @@ closem:
  static int
  files_differ(FILE *f1, FILE *f2, int flags)
  {
@@ -1043,7 +1059,7 @@
  
  	if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size ||
  	    (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT))
-@@ -503,9 +525,9 @@ files_differ(FILE *f1, FILE *f2, int fla
+@@ -503,9 +535,9 @@ files_differ(FILE *f1, FILE *f2, int fla
  static FILE *
  opentemp(const char *file)
  {
@@ -1056,7 +1072,7 @@
  
  	if (strcmp(file, "-") == 0)
  		ifd = STDIN_FILENO;
-@@ -541,7 +563,7 @@ opentemp(const char *file)
+@@ -541,7 +573,7 @@ opentemp(const char *file)
  char *
  splice(char *dir, char *file)
  {
@@ -1065,7 +1081,7 @@
  
  	if ((tail = strrchr(file, '/')) == NULL)
  		tail = file;
-@@ -555,8 +577,8 @@ static void
+@@ -555,8 +587,8 @@ static void
  prepare(int i, FILE *fd, off_t filesize)
  {
  	struct line	*p;
@@ -1076,7 +1092,7 @@
  
  	rewind(fd);
  
-@@ -579,7 +601,7 @@ prepare(int i, FILE *fd, off_t filesize)
+@@ -579,7 +611,7 @@ prepare(int i, FILE *fd, off_t filesize)
  static void
  prune(void)
  {
@@ -1085,7 +1101,7 @@
  
  	for (pref = 0; pref < len[0] && pref < len[1] &&
  	    file[0][pref + 1].value == file[1][pref + 1].value;
-@@ -600,7 +622,7 @@ prune(void)
+@@ -600,7 +632,7 @@ prune(void)
  static void
  equiv(struct line *a, int n, struct line *b, int m, int *c)
  {
@@ -1094,7 +1110,7 @@
  
  	i = j = 1;
  	while (i <= n && j <= m) {
-@@ -629,7 +651,7 @@ equiv(struct line *a, int n, struct line
+@@ -629,7 +661,7 @@ equiv(struct line *a, int n, struct line
  static int
  isqrt(int n)
  {
@@ -1103,7 +1119,7 @@
  
  	if (n == 0)
  		return (0);
-@@ -647,9 +669,9 @@ isqrt(int n)
+@@ -647,9 +679,9 @@ isqrt(int n)
  static int
  stone(int *a, int n, int *b, int *c)
  {
@@ -1116,7 +1132,7 @@
  	const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
  
  	k = 0;
-@@ -705,7 +727,7 @@ newcand(int x, int y, int pred)
+@@ -705,7 +737,7 @@ newcand(int x, int y, int pred)
  static int
  search(int *c, int k, int y)
  {
@@ -1125,7 +1141,7 @@
  
  	if (clist[c[k]].y < y)	/* quick look for typical case */
  		return (k + 1);
-@@ -730,7 +752,7 @@ static void
+@@ -730,7 +762,7 @@ static void
  unravel(int p)
  {
  	struct cand	*q;
@@ -1134,7 +1150,7 @@
  
  	for (i = 0; i <= len[0]; i++)
  		J[i] = i <= pref ? i :
-@@ -748,9 +770,10 @@ unravel(int p)
+@@ -748,9 +780,10 @@ unravel(int p)
  static void
  check(char *file1, FILE *f1, char *file2, FILE *f2)
  {
@@ -1148,7 +1164,7 @@
  	rewind(f1);
  	rewind(f2);
  	j = 1;
-@@ -766,7 +789,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -766,7 +799,7 @@ check(char *file1, FILE *f1, char *file2
  			ixnew[j] = ctnew += skipline(f2);
  			j++;
  		}
@@ -1157,7 +1173,7 @@
  			for (;;) {
  				c = getc(f1);
  				d = getc(f2);
-@@ -781,6 +804,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -781,6 +814,7 @@ check(char *file1, FILE *f1, char *file2
  				}
  				ctold++;
  				ctnew++;
@@ -1165,7 +1181,7 @@
  				if (bflag && isspace(c) && isspace(d)) {
  					do {
  						if (c == '\n')
-@@ -792,6 +816,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -792,6 +826,7 @@ check(char *file1, FILE *f1, char *file2
  							break;
  						ctnew++;
  					} while (isspace(d = getc(f2)));
@@ -1173,7 +1189,7 @@
  				} else if (wflag) {
  					while (isspace(c) && c != '\n') {
  						c = getc(f1);
-@@ -801,31 +826,55 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +836,55 @@ check(char *file1, FILE *f1, char *file2
  						d = getc(f2);
  						ctnew++;
  					}
@@ -1250,7 +1266,7 @@
  				if (chrtran[c] != chrtran[d]) {
  					jackpot++;
  					J[i] = 0;
-@@ -872,7 +921,7 @@ static void
+@@ -872,7 +931,7 @@ static void
  sort(struct line *a, int n)
  {
  	struct line	*ai, *aim, w;
@@ -1259,7 +1275,7 @@
  
  	if (n == 0)
  		return;
-@@ -916,7 +965,7 @@ unsort(struct line *f, int l, int *b)
+@@ -916,7 +975,7 @@ unsort(struct line *f, int l, int *b)
  static int
  skipline(FILE *f)
  {
@@ -1268,7 +1284,7 @@
  
  	for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
  		continue;
-@@ -926,7 +975,7 @@ skipline(FILE *f)
+@@ -926,7 +985,7 @@ skipline(FILE *f)
  static void
  output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
  {
@@ -1277,7 +1293,7 @@
  
  	rewind(f1);
  	rewind(f2);
-@@ -965,7 +1014,7 @@ output(char *file1, FILE *f1, char *file
+@@ -965,7 +1024,7 @@ output(char *file1, FILE *f1, char *file
  #define	c i0
  			if ((c = getc(f1)) == EOF)
  				return;
@@ -1286,7 +1302,7 @@
  		}
  #undef c
  	}
-@@ -980,6 +1029,7 @@ output(char *file1, FILE *f1, char *file
+@@ -980,6 +1039,7 @@ output(char *file1, FILE *f1, char *file
  static void
  range(int a, int b, char *separator)
  {
@@ -1294,7 +1310,7 @@
  	printf("%d", a > b ? b : a);
  	if (a < b)
  		printf("%s%d", separator, b);
-@@ -988,6 +1038,7 @@ range(int a, int b, char *separator)
+@@ -988,6 +1048,7 @@ range(int a, int b, char *separator)
  static void
  uni_range(int a, int b)
  {
@@ -1302,7 +1318,7 @@
  	if (a < b)
  		printf("%d,%d", a, b - a + 1);
  	else if (a == b)
-@@ -999,22 +1050,22 @@ uni_range(int a, int b)
+@@ -999,22 +1060,22 @@ uni_range(int a, int b)
  static char *
  preadline(int fd, size_t len, off_t off)
  {
@@ -1329,7 +1345,7 @@
  
  	ret = regexec(&ignore_re, line, 0, NULL, 0);
  	free(line);
-@@ -1032,10 +1083,10 @@ static void
+@@ -1032,10 +1093,10 @@ static void
  change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
      int *pflags)
  {
@@ -1343,7 +1359,7 @@
  	if (format != D_IFDEF && a > b && c > d)
  		return;
  	if (ignore_pats != NULL) {
-@@ -1050,7 +1101,7 @@ restart:
+@@ -1050,7 +1111,7 @@ restart:
  				line = preadline(fileno(f1),
  				    ixold[i] - ixold[i - 1], ixold[i - 1]);
  				if (!ignoreline(line))
@@ -1352,7 +1368,7 @@
  			}
  		}
  		if (a > b || c <= d) {	/* Changes and inserts. */
-@@ -1058,12 +1109,12 @@ restart:
+@@ -1058,12 +1119,12 @@ restart:
  				line = preadline(fileno(f2),
  				    ixnew[i] - ixnew[i - 1], ixnew[i - 1]);
  				if (!ignoreline(line))
@@ -1367,7 +1383,7 @@
  	if (*pflags & D_HEADER) {
  		printf("%s %s %s\n", diffargs, file1, file2);
  		*pflags &= ~D_HEADER;
-@@ -1113,15 +1164,15 @@ proceed:
+@@ -1113,15 +1174,15 @@ proceed:
  	case D_NORMAL:
  	case D_EDIT:
  		range(a, b, ",");
@@ -1387,7 +1403,7 @@
  		break;
  	case D_NREVERSE:
  		if (a > b)
-@@ -1137,7 +1188,7 @@ proceed:
+@@ -1137,7 +1198,7 @@ proceed:
  	if (format == D_NORMAL || format == D_IFDEF) {
  		fetch(ixold, a, b, f1, '<', 1);
  		if (a <= b && c <= d && format == D_NORMAL)
@@ -1396,7 +1412,7 @@
  	}
  	i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
  	if (i != 0 && format == D_EDIT) {
-@@ -1148,14 +1199,14 @@ proceed:
+@@ -1148,14 +1209,14 @@ proceed:
  		 * it.  We have to add a substitute command to change this
  		 * back and restart where we left off.
  		 */
@@ -1414,7 +1430,7 @@
  	if (inifdef) {
  		printf("#endif /* %s */\n", ifdefname);
  		inifdef = 0;
-@@ -1165,8 +1216,8 @@ proceed:
+@@ -1165,8 +1226,8 @@ proceed:
  static int
  fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
  {
@@ -1425,7 +1441,7 @@
  
  	/*
  	 * When doing #ifdef's, copy down to current line
-@@ -1177,7 +1228,7 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1177,7 +1238,7 @@ fetch(long *f, int a, int b, FILE *lb, i
  		/* print through if append (a>b), else to (nb: 0 vs 1 orig) */
  		nc = f[a > b ? b : a - 1] - curpos;
  		for (i = 0; i < nc; i++)
@@ -1434,7 +1450,7 @@
  	}
  	if (a > b)
  		return (0);
-@@ -1197,12 +1248,12 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1197,12 +1258,12 @@ fetch(long *f, int a, int b, FILE *lb, i
  		fseek(lb, f[i - 1], SEEK_SET);
  		nc = f[i] - f[i - 1];
  		if (format != D_IFDEF && ch != '\0') {
@@ -1450,7 +1466,7 @@
  		}
  		col = 0;
  		for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
-@@ -1211,13 +1262,13 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1211,13 +1272,13 @@ fetch(long *f, int a, int b, FILE *lb, i
  				    format == D_NREVERSE)
  					warnx("No newline at end of file");
  				else
@@ -1466,7 +1482,7 @@
  				} while (++col < newcol);
  			} else {
  				if (format == D_EDIT && j == 1 && c == '\n'
-@@ -1229,10 +1280,10 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1229,10 +1290,10 @@ fetch(long *f, int a, int b, FILE *lb, i
  					 * giving the caller an offset
  					 * from which to restart.
  					 */
@@ -1479,7 +1495,7 @@
  				col++;
  			}
  		}
-@@ -1246,8 +1297,8 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1246,8 +1307,8 @@ fetch(long *f, int a, int b, FILE *lb, i
  static int
  readhash(FILE *f)
  {
@@ -1490,7 +1506,7 @@
  
  	sum = 1;
  	space = 0;
-@@ -1305,20 +1356,28 @@ readhash(FILE *f)
+@@ -1305,20 +1366,28 @@ readhash(FILE *f)
  	return (sum == 0 ? 1 : sum);
  }
  
@@ -1526,7 +1542,7 @@
  	return (1);
  }
  
-@@ -1327,10 +1386,10 @@ asciifile(FILE *f)
+@@ -1327,10 +1396,10 @@ asciifile(FILE *f)
  static char *
  match_function(const long *f, int pos, FILE *file)
  {
@@ -1541,7 +1557,7 @@
  
  	lastline = pos;
  	while (pos > last) {
-@@ -1342,7 +1401,6 @@ match_function(const long *f, int pos, F
+@@ -1342,7 +1411,6 @@ match_function(const long *f, int pos, F
  		if (nc > 0) {
  			buf[nc] = '\0';
  			buf[strcspn(buf, "\n")] = '\0';
@@ -1549,7 +1565,7 @@
  			if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
  				if (begins_with(buf, "private:")) {
  					if (!state)
-@@ -1373,9 +1431,9 @@ static void
+@@ -1373,9 +1441,9 @@ static void
  dump_context_vec(FILE *f1, FILE *f2)
  {
  	struct context_vec *cvp = context_vec_start;
@@ -1562,7 +1578,7 @@
  
  	if (context_vec_start > context_vec_ptr)
  		return;
-@@ -1390,8 +1448,8 @@ dump_context_vec(FILE *f1, FILE *f2)
+@@ -1390,8 +1458,8 @@ dump_context_vec(FILE *f1, FILE *f2)
  	if (pflag) {
  		f = match_function(ixold, lowa-1, f1);
  		if (f != NULL) {
@@ -1573,7 +1589,7 @@
  		}
  	}
  	printf("\n*** ");
-@@ -1478,9 +1536,9 @@ static void
+@@ -1478,9 +1546,9 @@ static void
  dump_unified_vec(FILE *f1, FILE *f2)
  {
  	struct context_vec *cvp = context_vec_start;
@@ -1586,7 +1602,7 @@
  
  	if (context_vec_start > context_vec_ptr)
  		return;
-@@ -1491,19 +1549,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1491,19 +1559,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
  	lowc = MAX(1, cvp->c - context);
  	upd = MIN(len[1], context_vec_ptr->d + context);
  
@@ -1612,7 +1628,7 @@
  
  	/*
  	 * Output changes in "unified" diff format--the old and new lines
-@@ -1551,16 +1609,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1551,16 +1619,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
  static void
  print_header(const char *file1, const char *file2)
  {
@@ -1662,3 +1678,15 @@
 +		printf("%s %s\t%s\n", format == D_CONTEXT ? "---" : "+++",
 +			file2, buf2);	
  }
+diff -rupN diff-orig/Makefile diff/Makefile
+--- diff-orig/Makefile	2012-07-25 11:37:23.300991134 -0400
++++ diff/Makefile	2012-07-25 11:40:31.643987623 -0400
+@@ -3,7 +3,7 @@
+ 
+ DEBUG_FLAGS+= -g
+ 
+-PROG=	diff
++PROG=	diff xdiff
+ SRCS=	diff.c diffdir.c diffreg.c
+ CFLAGS+=	-std=c99 -Wall -pedantic
+ 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120725161202.67F81106566B>