Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Aug 2012 16:43:35 +0000
From:      jhagewood@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r240045 - in soc2012/jhagewood/diff: . diff
Message-ID:  <20120803164335.8DBEA106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhagewood
Date: Fri Aug  3 16:43:34 2012
New Revision: 240045
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240045

Log:

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

Modified: soc2012/jhagewood/diff/diff/diff.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diff.c	Fri Aug  3 15:58:05 2012	(r240044)
+++ soc2012/jhagewood/diff/diff/diff.c	Fri Aug  3 16:43:34 2012	(r240045)
@@ -210,15 +210,13 @@
 	int ch, lastch, gotstdin, prevoptind, newarg;
 	int oargc;
 	
+	filebehave = FILE_NORMAL;
 	/* Check what is the program name of the binary.  In this
 	   way we can have all the funcionalities in one binary
 	   without the need of scripting and using ugly hacks. */
 	pn = getprogname();
 	if (pn[0] == 'z') {
 		filebehave = FILE_GZIP;
-		pn += 1;
-	} else {
-		filebehave = FILE_NORMAL;
 	}
 	
 	oargv = argv;
@@ -700,14 +698,14 @@
 {
 	
 	(void)fprintf(stderr,
-	    "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
+	    "usage: %s [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
 	    "            [-L label] file1 file2\n"
-	    "       diff [-abdilpqTtw] [-I pattern] [-L label] -C number file1 file2\n"
-	    "       diff [-abdilqtw] [-I pattern] -D string file1 file2\n"
-	    "       diff [-abdilpqTtw] [-I pattern] [-L label] -U number file1 file2\n"
-	    "       diff [-abdilNPpqrsTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
+	    "          [-abdilpqTtw] [-I pattern] [-L label] -C number file1 file2\n"
+	    "          [-abdilqtw] [-I pattern] -D string file1 file2\n"
+	    "          [-abdilpqTtw] [-I pattern] [-L label] -U number file1 file2\n"
+	    "          [-abdilNPpqrsTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
 	    "            [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"
-	    "       diff [-v]\n");
+	    "          [-v]\n", getprogname());
 
 	exit(1);
 }

Modified: soc2012/jhagewood/diff/diff/diff.h
==============================================================================
--- soc2012/jhagewood/diff/diff/diff.h	Fri Aug  3 15:58:05 2012	(r240044)
+++ soc2012/jhagewood/diff/diff/diff.h	Fri Aug  3 16:43:34 2012	(r240045)
@@ -102,3 +102,5 @@
 void	diffdir(char *, char *);
 void	print_only(const char *, size_t, const char *);
 void	print_status(int, char *, char *, char *);
+
+FILE *decompressfile(char *, char *);

Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c	Fri Aug  3 15:58:05 2012	(r240044)
+++ soc2012/jhagewood/diff/diff/diffreg.c	Fri Aug  3 16:43:34 2012	(r240045)
@@ -99,7 +99,6 @@
 # define TIMESPEC_NS(timespec) 0
 #endif
 
-#define MAX_INT	2147483647
 #define MAX_CHECK 768	/* 3 kilobytes of chars. */
 
 /*
@@ -306,14 +305,10 @@
 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;
@@ -344,10 +339,7 @@
 			if (filebehave == FILE_NORMAL) 
 				f1 = fopen(file1, "r");
 			if (filebehave == FILE_GZIP) {
-				if (gz1 = gzopen(file1, "r") == Z_NULL)
-					err(1, "Could not open compressed file %s.", file1);
-				gzread(gz1, buf, MAX_INT);
-				f1 = fdopen(buf, "r");
+				f1 = decompressfile(file1, "r");
 			}
 		}
 	}
@@ -373,10 +365,7 @@
 			if (filebehave == FILE_NORMAL) 
 				f2 = fopen(file2, "r");
 			if (filebehave == FILE_GZIP)
-				if(gz2 = gzopen(file2, "r") == Z_NULL)
-					err(1, "Could not open compressed file %s.", file2);
-				gzread(gz2, buf, MAX_INT);
-				f2 = fdopen(buf, "r");
+				f2 = decompressfile(file2, "r");
 		}
 	}
 	if (f2 == NULL) {

Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch	Fri Aug  3 15:58:05 2012	(r240044)
+++ soc2012/jhagewood/diff/hagewood-diff.patch	Fri Aug  3 16:43:34 2012	(r240045)
@@ -12,9 +12,87 @@
 +CFLAGS+=	-std=c99 -Wall -pedantic -lz
  
  .include <bsd.prog.mk>
+diff -rupN diff-orig/decompress.c diff/decompress.c
+--- diff-orig/decompress.c	1969-12-31 19:00:00.000000000 -0500
++++ diff/decompress.c	2012-08-03 04:53:21.000000000 -0400
+@@ -0,0 +1,74 @@
++/*
++ * Copyright (c) 2012 Jesse Hagewood <jhagewood@freebsd.org>
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++#if 0
++#ifndef lint
++static char sccsid[] = "@(#)decompress.c 6/6/93";
++#endif
++#endif /* not lint */
++#include <sys/cdefs.h>
++__FBSDID("$FreeBSD$");
++
++#include <sys/param.h>
++#include <sys/stat.h>
++#include <sys/wait.h>
++
++#include <ctype.h>
++#include <err.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <stddef.h>
++#include <stdint.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <zlib.h>
++
++#ifndef WITHOUT_BZIP2
++#include <bzlib.h>
++#endif
++
++#include "diff.h"
++#include "pathnames.h"
++
++#define MAXBUFSIZE (32 * 1024)
++
++/* Decompresses a gzip file and returns a regular FILE. */
++FILE *
++decompressfile(char *filename, char *mode) {
++
++	FILE *file;
++	char *buf;
++	gzFile comprfile; 
++	
++	if (comprfile = gzopen(filename, mode) == Z_NULL)
++		err(1, "Could not open compressed file %s.", filename);
++	gzread(comprfile, buf, MAXBUFSIZE);
++	file = fdopen(buf, mode);
++	 
++	return file;
++}
 diff -rupN diff-orig/diff.c diff/diff.c
 --- diff-orig/diff.c	2012-07-26 03:11:00.000000000 -0400
-+++ diff/diff.c	2012-07-26 03:11:00.000000000 -0400
++++ diff/diff.c	2012-08-03 04:03:45.000000000 -0400
 @@ -1,4 +1,4 @@
 -/*-
 +/*
@@ -71,7 +149,7 @@
  
  
  /* Options which exceed manageable alphanumeric assignments */ 
-@@ -69,107 +68,163 @@ enum 
+@@ -69,107 +68,161 @@ enum 
    OPT_STRIPCR,
    OPT_NORMAL,
    OPT_LEFTC,
@@ -281,15 +359,13 @@
 +	int ch, lastch, gotstdin, prevoptind, newarg;
 +	int oargc;
 +	
++	filebehave = FILE_NORMAL;
 +	/* Check what is the program name of the binary.  In this
 +	   way we can have all the funcionalities in one binary
 +	   without the need of scripting and using ugly hacks. */
 +	pn = getprogname();
 +	if (pn[0] == 'z') {
 +		filebehave = FILE_GZIP;
-+		pn += 1;
-+	} else {
-+		filebehave = FILE_NORMAL;
 +	}
 +	
  	oargv = argv;
@@ -299,7 +375,7 @@
  
  	lastch = '\0';
  	prevoptind = 1;
-@@ -197,6 +252,7 @@ main(int argc, char **argv)
+@@ -197,6 +250,7 @@ main(int argc, char **argv)
  			break;
  		case 'C':
  		case 'c':
@@ -307,7 +383,7 @@
  			format = D_CONTEXT;
  			if (optarg != NULL) {
  				l = strtol(optarg, &ep, 10);
-@@ -213,6 +269,9 @@ main(int argc, char **argv)
+@@ -213,6 +267,9 @@ main(int argc, char **argv)
  		case 'd':
  			dflag = 1;
  			break;
@@ -317,7 +393,7 @@
  		case 'e':
  			format = D_EDIT;
  			break;
-@@ -284,7 +343,7 @@ main(int argc, char **argv)
+@@ -284,7 +341,7 @@ main(int argc, char **argv)
  		case 'v':
  			printf("FreeBSD diff 2.8.7\n");
  			exit(0);
@@ -326,7 +402,7 @@
  			wflag = 1;
  			break;
  		case 'X':
-@@ -296,15 +355,48 @@ main(int argc, char **argv)
+@@ -296,15 +353,48 @@ main(int argc, char **argv)
  		case 'y':
  			yflag = 1;
  			break;
@@ -383,7 +459,7 @@
  		case OPT_STRIPCR:
  			strip_cr=1;
  			break;
-@@ -315,11 +407,10 @@ main(int argc, char **argv)
+@@ -315,11 +405,10 @@ main(int argc, char **argv)
  			ignore_file_case = 0;
  			break; 
  		case OPT_HELP:
@@ -397,7 +473,7 @@
  			break;
  		default:
  			usage();
-@@ -328,22 +419,22 @@ main(int argc, char **argv)
+@@ -328,22 +417,22 @@ main(int argc, char **argv)
  		lastch = ch;
  		newarg = optind != prevoptind;
  		prevoptind = optind;
@@ -426,7 +502,7 @@
  	}
  
  	/*
-@@ -380,7 +471,10 @@ main(int argc, char **argv)
+@@ -380,7 +469,10 @@ main(int argc, char **argv)
  	set_argstr(oargv, argv);
  	if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
  		if (format == D_IFDEF)
@@ -438,7 +514,7 @@
  		diffdir(argv[0], argv[1]);
  	} else {
  		if (S_ISDIR(stb1.st_mode)) {
-@@ -393,8 +487,26 @@ main(int argc, char **argv)
+@@ -393,8 +485,26 @@ main(int argc, char **argv)
  			if (stat(argv[1], &stb2) < 0)
  				err(2, "%s", argv[1]);
  		}
@@ -467,7 +543,7 @@
  	}
  	exit(status);
  }
-@@ -402,11 +514,10 @@ main(int argc, char **argv)
+@@ -402,11 +512,10 @@ main(int argc, char **argv)
  void *
  emalloc(size_t n)
  {
@@ -480,7 +556,7 @@
  	if ((p = malloc(n)) == NULL)
  		errx(2, NULL);
  	return (p);
-@@ -415,7 +526,7 @@ emalloc(size_t n)
+@@ -415,7 +524,7 @@ emalloc(size_t n)
  void *
  erealloc(void *p, size_t n)
  {
@@ -489,7 +565,7 @@
  
  	if (n == 0)
  		errx(2, NULL);
-@@ -431,13 +542,12 @@ erealloc(void *p, size_t n)
+@@ -431,13 +540,12 @@ erealloc(void *p, size_t n)
  int
  easprintf(char **ret, const char *fmt, ...)
  {
@@ -505,7 +581,7 @@
  	if (len < 0 || *ret == NULL)
  		errx(2, NULL);
  	return (len);
-@@ -446,20 +556,21 @@ easprintf(char **ret, const char *fmt, .
+@@ -446,20 +554,21 @@ easprintf(char **ret, const char *fmt, .
  char *
  estrdup(const char *str)
  {
@@ -532,7 +608,7 @@
  
  	argsize = 4 + *ave - *av + 1;
  	diffargs = emalloc(argsize);
-@@ -475,12 +586,12 @@ set_argstr(char **av, char **ave)
+@@ -475,12 +584,12 @@ set_argstr(char **av, char **ave)
  /*
   * Read in an excludes file and push each line.
   */
@@ -549,7 +625,7 @@
  
  	if (strcmp(file, "-") == 0)
  		fp = stdin;
-@@ -501,7 +612,7 @@ read_excludes_file(char *file)
+@@ -501,7 +610,7 @@ read_excludes_file(char *file)
  /*
   * Push a pattern onto the excludes list.
   */
@@ -558,7 +634,7 @@
  push_excludes(char *pattern)
  {
  	struct excludes	*entry;
-@@ -512,10 +623,10 @@ push_excludes(char *pattern)
+@@ -512,10 +621,10 @@ push_excludes(char *pattern)
  	excludes_list = entry;
  }
  
@@ -571,7 +647,7 @@
  
  	if (ignore_pats == NULL)
  		ignore_pats = estrdup(pattern);
-@@ -531,6 +642,7 @@ push_ignore_pats(char *pattern)
+@@ -531,6 +640,7 @@ push_ignore_pats(char *pattern)
  void
  print_only(const char *path, size_t dirlen, const char *entry)
  {
@@ -579,7 +655,7 @@
  	if (dirlen > 1)
  		dirlen--;
  	printf("Only in %.*s: %s\n", (int)dirlen, path, entry);
-@@ -539,52 +651,54 @@ print_only(const char *path, size_t dirl
+@@ -539,61 +649,63 @@ print_only(const char *path, size_t dirl
  void
  print_status(int val, char *path1, char *path2, char *entry)
  {
@@ -644,18 +720,27 @@
  {
 +	
  	(void)fprintf(stderr,
- 	    "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
+-	    "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
++	    "usage: %s [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
  	    "            [-L label] file1 file2\n"
-@@ -595,5 +709,5 @@ usage(void)
+-	    "       diff [-abdilpqTtw] [-I pattern] [-L label] -C number file1 file2\n"
+-	    "       diff [-abdilqtw] [-I pattern] -D string file1 file2\n"
+-	    "       diff [-abdilpqTtw] [-I pattern] [-L label] -U number file1 file2\n"
+-	    "       diff [-abdilNPpqrsTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
++	    "          [-abdilpqTtw] [-I pattern] [-L label] -C number file1 file2\n"
++	    "          [-abdilqtw] [-I pattern] -D string file1 file2\n"
++	    "          [-abdilpqTtw] [-I pattern] [-L label] -U number file1 file2\n"
++	    "          [-abdilNPpqrsTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
  	    "            [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"
- 	    "       diff [-v]\n");
+-	    "       diff [-v]\n");
++	    "          [-v]\n", getprogname());
  
 -	exit(2);
 +	exit(1);
  }
 diff -rupN diff-orig/diff.h diff/diff.h
 --- diff-orig/diff.h	2012-07-26 03:11:00.000000000 -0400
-+++ diff/diff.h	2012-07-26 03:11:00.000000000 -0400
++++ diff/diff.h	2012-08-03 04:51:29.000000000 -0400
 @@ -48,6 +48,8 @@
  #define	D_NREVERSE	5	/* Reverse ed script with numbered
  				   lines and no trailing . */
@@ -691,6 +776,12 @@
  extern char	 ignore_file_case;
  extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
  extern struct	 stat stb1, stb2;
+@@ -93,3 +102,5 @@ void	*erealloc(void *, size_t);
+ void	diffdir(char *, char *);
+ void	print_only(const char *, size_t, const char *);
+ void	print_status(int, char *, char *, char *);
++
++FILE *decompressfile(char *, char *);
 diff -rupN diff-orig/diffdir.c diff/diffdir.c
 --- diff-orig/diffdir.c	2012-07-26 03:11:00.000000000 -0400
 +++ diff/diffdir.c	2012-07-26 03:11:00.000000000 -0400
@@ -802,7 +893,7 @@
  	if (stat(path1, &stb1) != 0) {
 diff -rupN diff-orig/diffreg.c diff/diffreg.c
 --- diff-orig/diffreg.c	2012-07-26 03:11:00.000000000 -0400
-+++ diff/diffreg.c	2012-07-31 19:11:25.000000000 -0400
++++ diff/diffreg.c	2012-08-03 05:01:28.000000000 -0400
 @@ -62,15 +62,13 @@
   *	@(#)diffreg.c   8.1 (Berkeley) 6/6/93
   */
@@ -823,7 +914,7 @@
  
  #include <sys/param.h>
  #include <sys/stat.h>
-@@ -86,10 +84,24 @@ __FBSDID("$FreeBSD");
+@@ -86,10 +84,23 @@ __FBSDID("$FreeBSD");
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
@@ -842,13 +933,12 @@
 +# define TIMESPEC_NS(timespec) 0
 +#endif
 +
-+#define MAX_INT	2147483647
 +#define MAX_CHECK 768	/* 3 kilobytes of chars. */
 +
  /*
   * diff - compare two files.
   */
-@@ -181,47 +193,47 @@ struct context_vec {
+@@ -181,47 +192,47 @@ struct context_vec {
  };
  
  static FILE	*opentemp(const char *);
@@ -931,7 +1021,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 +306,17 @@ u_char cup2low[256] = {
+@@ -294,13 +305,13 @@ u_char cup2low[256] = {
  int
  diffreg(char *ofile1, char *ofile2, int flags)
  {
@@ -942,21 +1032,17 @@
 -	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 +326,7 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -310,7 +321,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)
@@ -965,7 +1051,7 @@
  
  	if (flags & D_EMPTY1)
  		f1 = fopen(_PATH_DEVNULL, "r");
-@@ -320,17 +336,25 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -320,17 +331,22 @@ diffreg(char *ofile1, char *ofile2, int 
  			    fstat(fileno(f1), &stb1) < 0) {
  				warn("%s", file1);
  				status |= 2;
@@ -980,10 +1066,7 @@
 +			if (filebehave == FILE_NORMAL) 
 +				f1 = fopen(file1, "r");
 +			if (filebehave == FILE_GZIP) {
-+				if (gz1 = gzopen(file1, "r") == Z_NULL)
-+					err(1, "Could not open compressed file %s.", file1);
-+				gzread(gz1, buf, MAX_INT);
-+				f1 = fdopen(buf, "r");
++				f1 = decompressfile(file1, "r");
 +			}
 +		}
  	}
@@ -995,7 +1078,7 @@
  	}
  
  	if (flags & D_EMPTY2)
-@@ -341,34 +365,40 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -341,34 +357,37 @@ diffreg(char *ofile1, char *ofile2, int 
  			    fstat(fileno(f2), &stb2) < 0) {
  				warn("%s", file2);
  				status |= 2;
@@ -1010,10 +1093,7 @@
 +			if (filebehave == FILE_NORMAL) 
 +				f2 = fopen(file2, "r");
 +			if (filebehave == FILE_GZIP)
-+				if(gz2 = gzopen(file2, "r") == Z_NULL)
-+					err(1, "Could not open compressed file %s.", file2);
-+				gzread(gz2, buf, MAX_INT);
-+				f2 = fdopen(buf, "r");
++				f2 = decompressfile(file2, "r");
 +		}
  	}
  	if (f2 == NULL) {
@@ -1045,7 +1125,7 @@
  	}
  	if (lflag) {
  		/* redirect stdout to pr */
-@@ -452,7 +482,11 @@ diffreg(char *ofile1, char *ofile2, int 
+@@ -452,7 +471,11 @@ diffreg(char *ofile1, char *ofile2, int 
  		}
  		waitpid(pid, &wstatus, 0);
  	}
@@ -1058,7 +1138,7 @@
  	if (anychange) {
  		status |= 1;
  		if (rval == D_SAME)
-@@ -477,8 +511,8 @@ closem:
+@@ -477,8 +500,8 @@ closem:
  static int
  files_differ(FILE *f1, FILE *f2, int flags)
  {
@@ -1069,7 +1149,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 +537,9 @@ files_differ(FILE *f1, FILE *f2, int fla
+@@ -503,9 +526,9 @@ files_differ(FILE *f1, FILE *f2, int fla
  static FILE *
  opentemp(const char *file)
  {
@@ -1082,7 +1162,7 @@
  
  	if (strcmp(file, "-") == 0)
  		ifd = STDIN_FILENO;
-@@ -541,7 +575,7 @@ opentemp(const char *file)
+@@ -541,7 +564,7 @@ opentemp(const char *file)
  char *
  splice(char *dir, char *file)
  {
@@ -1091,7 +1171,7 @@
  
  	if ((tail = strrchr(file, '/')) == NULL)
  		tail = file;
-@@ -555,8 +589,8 @@ static void
+@@ -555,8 +578,8 @@ static void
  prepare(int i, FILE *fd, off_t filesize)
  {
  	struct line	*p;
@@ -1102,7 +1182,7 @@
  
  	rewind(fd);
  
-@@ -579,7 +613,7 @@ prepare(int i, FILE *fd, off_t filesize)
+@@ -579,7 +602,7 @@ prepare(int i, FILE *fd, off_t filesize)
  static void
  prune(void)
  {
@@ -1111,7 +1191,7 @@
  
  	for (pref = 0; pref < len[0] && pref < len[1] &&
  	    file[0][pref + 1].value == file[1][pref + 1].value;
-@@ -600,7 +634,7 @@ prune(void)
+@@ -600,7 +623,7 @@ prune(void)
  static void
  equiv(struct line *a, int n, struct line *b, int m, int *c)
  {
@@ -1120,7 +1200,7 @@
  
  	i = j = 1;
  	while (i <= n && j <= m) {
-@@ -629,7 +663,7 @@ equiv(struct line *a, int n, struct line
+@@ -629,7 +652,7 @@ equiv(struct line *a, int n, struct line
  static int
  isqrt(int n)
  {
@@ -1129,7 +1209,7 @@
  
  	if (n == 0)
  		return (0);
-@@ -647,9 +681,9 @@ isqrt(int n)
+@@ -647,9 +670,9 @@ isqrt(int n)
  static int
  stone(int *a, int n, int *b, int *c)
  {
@@ -1142,7 +1222,7 @@
  	const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
  
  	k = 0;
-@@ -705,7 +739,7 @@ newcand(int x, int y, int pred)
+@@ -705,7 +728,7 @@ newcand(int x, int y, int pred)
  static int
  search(int *c, int k, int y)
  {
@@ -1151,7 +1231,7 @@
  
  	if (clist[c[k]].y < y)	/* quick look for typical case */
  		return (k + 1);
-@@ -730,7 +764,7 @@ static void
+@@ -730,7 +753,7 @@ static void
  unravel(int p)
  {
  	struct cand	*q;
@@ -1160,7 +1240,7 @@
  
  	for (i = 0; i <= len[0]; i++)
  		J[i] = i <= pref ? i :
-@@ -748,9 +782,10 @@ unravel(int p)
+@@ -748,9 +771,10 @@ unravel(int p)
  static void
  check(char *file1, FILE *f1, char *file2, FILE *f2)
  {
@@ -1174,7 +1254,7 @@
  	rewind(f1);
  	rewind(f2);
  	j = 1;
-@@ -766,7 +801,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -766,7 +790,7 @@ check(char *file1, FILE *f1, char *file2
  			ixnew[j] = ctnew += skipline(f2);
  			j++;
  		}
@@ -1183,7 +1263,7 @@
  			for (;;) {
  				c = getc(f1);
  				d = getc(f2);
-@@ -781,6 +816,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -781,6 +805,7 @@ check(char *file1, FILE *f1, char *file2
  				}
  				ctold++;
  				ctnew++;
@@ -1191,7 +1271,7 @@
  				if (bflag && isspace(c) && isspace(d)) {
  					do {
  						if (c == '\n')
-@@ -792,6 +828,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -792,6 +817,7 @@ check(char *file1, FILE *f1, char *file2
  							break;
  						ctnew++;
  					} while (isspace(d = getc(f2)));
@@ -1199,7 +1279,7 @@
  				} else if (wflag) {
  					while (isspace(c) && c != '\n') {
  						c = getc(f1);
-@@ -801,31 +838,55 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +827,55 @@ check(char *file1, FILE *f1, char *file2
  						d = getc(f2);
  						ctnew++;
  					}
@@ -1276,7 +1356,7 @@
  				if (chrtran[c] != chrtran[d]) {
  					jackpot++;
  					J[i] = 0;
-@@ -872,7 +933,7 @@ static void
+@@ -872,7 +922,7 @@ static void
  sort(struct line *a, int n)
  {
  	struct line	*ai, *aim, w;
@@ -1285,7 +1365,7 @@
  
  	if (n == 0)
  		return;
-@@ -916,7 +977,7 @@ unsort(struct line *f, int l, int *b)
+@@ -916,7 +966,7 @@ unsort(struct line *f, int l, int *b)
  static int
  skipline(FILE *f)
  {
@@ -1294,7 +1374,7 @@
  
  	for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
  		continue;
-@@ -926,7 +987,7 @@ skipline(FILE *f)
+@@ -926,7 +976,7 @@ skipline(FILE *f)
  static void
  output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
  {
@@ -1303,7 +1383,7 @@
  
  	rewind(f1);
  	rewind(f2);
-@@ -965,7 +1026,7 @@ output(char *file1, FILE *f1, char *file
+@@ -965,7 +1015,7 @@ output(char *file1, FILE *f1, char *file
  #define	c i0
  			if ((c = getc(f1)) == EOF)
  				return;
@@ -1312,7 +1392,7 @@
  		}
  #undef c
  	}
-@@ -980,6 +1041,7 @@ output(char *file1, FILE *f1, char *file
+@@ -980,6 +1030,7 @@ output(char *file1, FILE *f1, char *file
  static void
  range(int a, int b, char *separator)
  {
@@ -1320,7 +1400,7 @@
  	printf("%d", a > b ? b : a);
  	if (a < b)
  		printf("%s%d", separator, b);
-@@ -988,6 +1050,7 @@ range(int a, int b, char *separator)
+@@ -988,6 +1039,7 @@ range(int a, int b, char *separator)
  static void
  uni_range(int a, int b)
  {
@@ -1328,7 +1408,7 @@
  	if (a < b)
  		printf("%d,%d", a, b - a + 1);
  	else if (a == b)
-@@ -999,22 +1062,22 @@ uni_range(int a, int b)
+@@ -999,22 +1051,22 @@ uni_range(int a, int b)
  static char *
  preadline(int fd, size_t len, off_t off)
  {
@@ -1355,7 +1435,7 @@
  
  	ret = regexec(&ignore_re, line, 0, NULL, 0);
  	free(line);
-@@ -1032,10 +1095,10 @@ static void
+@@ -1032,10 +1084,10 @@ static void
  change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
      int *pflags)
  {
@@ -1369,7 +1449,7 @@
  	if (format != D_IFDEF && a > b && c > d)
  		return;
  	if (ignore_pats != NULL) {
-@@ -1050,7 +1113,7 @@ restart:
+@@ -1050,7 +1102,7 @@ restart:
  				line = preadline(fileno(f1),
  				    ixold[i] - ixold[i - 1], ixold[i - 1]);
  				if (!ignoreline(line))
@@ -1378,7 +1458,7 @@
  			}
  		}
  		if (a > b || c <= d) {	/* Changes and inserts. */
-@@ -1058,12 +1121,12 @@ restart:
+@@ -1058,12 +1110,12 @@ restart:
  				line = preadline(fileno(f2),
  				    ixnew[i] - ixnew[i - 1], ixnew[i - 1]);
  				if (!ignoreline(line))
@@ -1393,7 +1473,7 @@
  	if (*pflags & D_HEADER) {
  		printf("%s %s %s\n", diffargs, file1, file2);
  		*pflags &= ~D_HEADER;
-@@ -1113,15 +1176,15 @@ proceed:
+@@ -1113,15 +1165,15 @@ proceed:
  	case D_NORMAL:
  	case D_EDIT:
  		range(a, b, ",");
@@ -1413,7 +1493,7 @@
  		break;
  	case D_NREVERSE:
  		if (a > b)
-@@ -1137,7 +1200,7 @@ proceed:
+@@ -1137,7 +1189,7 @@ proceed:
  	if (format == D_NORMAL || format == D_IFDEF) {
  		fetch(ixold, a, b, f1, '<', 1);
  		if (a <= b && c <= d && format == D_NORMAL)
@@ -1422,7 +1502,7 @@
  	}
  	i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
  	if (i != 0 && format == D_EDIT) {
-@@ -1148,14 +1211,14 @@ proceed:
+@@ -1148,14 +1200,14 @@ proceed:
  		 * it.  We have to add a substitute command to change this
  		 * back and restart where we left off.
  		 */
@@ -1440,7 +1520,7 @@
  	if (inifdef) {
  		printf("#endif /* %s */\n", ifdefname);
  		inifdef = 0;
-@@ -1165,8 +1228,8 @@ proceed:
+@@ -1165,8 +1217,8 @@ proceed:
  static int
  fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
  {
@@ -1451,7 +1531,7 @@
  
  	/*
  	 * When doing #ifdef's, copy down to current line
-@@ -1177,7 +1240,7 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1177,7 +1229,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++)
@@ -1460,7 +1540,7 @@
  	}
  	if (a > b)
  		return (0);
-@@ -1197,12 +1260,12 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1197,12 +1249,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') {
@@ -1476,7 +1556,7 @@
  		}
  		col = 0;
  		for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
-@@ -1211,13 +1274,13 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1211,13 +1263,13 @@ fetch(long *f, int a, int b, FILE *lb, i
  				    format == D_NREVERSE)
  					warnx("No newline at end of file");
  				else
@@ -1492,7 +1572,7 @@
  				} while (++col < newcol);
  			} else {
  				if (format == D_EDIT && j == 1 && c == '\n'
-@@ -1229,10 +1292,10 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1229,10 +1281,10 @@ fetch(long *f, int a, int b, FILE *lb, i
  					 * giving the caller an offset
  					 * from which to restart.
  					 */
@@ -1505,7 +1585,7 @@
  				col++;
  			}
  		}
-@@ -1246,8 +1309,8 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1246,8 +1298,8 @@ fetch(long *f, int a, int b, FILE *lb, i
  static int
  readhash(FILE *f)
  {
@@ -1516,7 +1596,7 @@
  
  	sum = 1;
  	space = 0;
-@@ -1305,20 +1368,28 @@ readhash(FILE *f)
+@@ -1305,20 +1357,28 @@ readhash(FILE *f)
  	return (sum == 0 ? 1 : sum);
  }
  
@@ -1552,7 +1632,7 @@
  	return (1);
  }
  
-@@ -1327,10 +1398,10 @@ asciifile(FILE *f)
+@@ -1327,10 +1387,10 @@ asciifile(FILE *f)
  static char *
  match_function(const long *f, int pos, FILE *file)
  {
@@ -1567,7 +1647,7 @@
  
  	lastline = pos;
  	while (pos > last) {
-@@ -1342,7 +1413,6 @@ match_function(const long *f, int pos, F
+@@ -1342,7 +1402,6 @@ match_function(const long *f, int pos, F
  		if (nc > 0) {
  			buf[nc] = '\0';
  			buf[strcspn(buf, "\n")] = '\0';
@@ -1575,7 +1655,7 @@
  			if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
  				if (begins_with(buf, "private:")) {
  					if (!state)
-@@ -1373,9 +1443,9 @@ static void
+@@ -1373,9 +1432,9 @@ static void
  dump_context_vec(FILE *f1, FILE *f2)
  {
  	struct context_vec *cvp = context_vec_start;
@@ -1588,7 +1668,7 @@
  
  	if (context_vec_start > context_vec_ptr)
  		return;
-@@ -1390,8 +1460,8 @@ dump_context_vec(FILE *f1, FILE *f2)
+@@ -1390,8 +1449,8 @@ dump_context_vec(FILE *f1, FILE *f2)
  	if (pflag) {
  		f = match_function(ixold, lowa-1, f1);
  		if (f != NULL) {
@@ -1599,7 +1679,7 @@
  		}
  	}
  	printf("\n*** ");
-@@ -1478,9 +1548,9 @@ static void
+@@ -1478,9 +1537,9 @@ static void
  dump_unified_vec(FILE *f1, FILE *f2)
  {
  	struct context_vec *cvp = context_vec_start;
@@ -1612,7 +1692,7 @@
  
  	if (context_vec_start > context_vec_ptr)
  		return;
-@@ -1491,19 +1561,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1491,19 +1550,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
  	lowc = MAX(1, cvp->c - context);
  	upd = MIN(len[1], context_vec_ptr->d + context);
  
@@ -1638,7 +1718,7 @@
  
  	/*
  	 * Output changes in "unified" diff format--the old and new lines
-@@ -1551,16 +1621,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1551,16 +1610,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
  static void
  print_header(const char *file1, const char *file2)
  {



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