Date: Tue, 24 Jul 2012 01:36:48 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r239721 - in soc2012/jhagewood/diff: . diff Message-ID: <20120724013648.EAFD3106564A@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhagewood Date: Tue Jul 24 01:36:48 2012 New Revision: 239721 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239721 Log: Begun zdiff intergration in diff. Modified: soc2012/jhagewood/diff/TODO soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/diff/diff.h soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/diff/pathnames.h soc2012/jhagewood/diff/hagewood-diff.patch Modified: soc2012/jhagewood/diff/TODO ============================================================================== --- soc2012/jhagewood/diff/TODO Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/TODO Tue Jul 24 01:36:48 2012 (r239721) @@ -20,6 +20,8 @@ --help COMPLETE Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and detects if file is binary. Test script COMPLETE +Support for zdiff IN PROGRESS + Notes: Modified: soc2012/jhagewood/diff/diff/diff.c ============================================================================== --- soc2012/jhagewood/diff/diff/diff.c Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diff.c Tue Jul 24 01:36:48 2012 (r239721) @@ -46,6 +46,7 @@ int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag; int sflag, tflag, Tflag, wflag, Toflag, Fromflag; int Bflag, yflag; +int filebehave; int strip_cr, suppress_cl, tabsize = 8; char ignore_file_case = 0; int format, context, status; @@ -204,10 +205,22 @@ main(int argc, char **argv) { char *ep, **oargv, *optfile; + const char *pn; long l; int ch, lastch, gotstdin, prevoptind, newarg; int oargc; + /* 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; oargc = argc; gotstdin = 0; Modified: soc2012/jhagewood/diff/diff/diff.h ============================================================================== --- soc2012/jhagewood/diff/diff/diff.h Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diff.h Tue Jul 24 01:36:48 2012 (r239721) @@ -72,6 +72,12 @@ #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; @@ -81,6 +87,7 @@ 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; Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/diffreg.c Tue Jul 24 01:36:48 2012 (r239721) @@ -84,6 +84,11 @@ #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" @@ -330,8 +335,12 @@ } } else if (strcmp(file1, "-") == 0) f1 = stdin; - else - f1 = fopen(file1, "r"); + else { + if (filebehave == FILE_NORMAL) + f1 = fopen(file1, "r"); + if (filebehave == FILE_GZIP) + f1 = gzopen(file1, "r"); + } } if (f1 == NULL) { warn("%s", file1); @@ -351,8 +360,12 @@ } } else if (strcmp(file2, "-") == 0) f2 = stdin; - else - f2 = fopen(file2, "r"); + else { + if (filebehave == FILE_NORMAL) + f2 = fopen(file2, "r"); + if (filebehave == FILE_GZIP) + f2 = gzopen(file2, "r"); + } } if (f2 == NULL) { warn("%s", file2); @@ -1351,7 +1364,7 @@ static int istextfile(FILE *f) { - int i, check_size; + int i; char ch; if (aflag || f == NULL) Modified: soc2012/jhagewood/diff/diff/pathnames.h ============================================================================== --- soc2012/jhagewood/diff/diff/pathnames.h Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/diff/pathnames.h Tue Jul 24 01:36:48 2012 (r239721) @@ -23,5 +23,4 @@ #include <paths.h> #define _PATH_PR "/usr/bin/pr" -#define _PATH_DIFF "/usr/bin/diff" #define _PATH_SDIFF "/usr/bin/sdiff" Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 23 23:40:13 2012 (r239720) +++ soc2012/jhagewood/diff/hagewood-diff.patch Tue Jul 24 01:36:48 2012 (r239721) @@ -1,6 +1,6 @@ -diff -rupN jhagewood/diff/diff-orig/diff.c jhagewood/diff/diff/diff.c ---- jhagewood/diff/diff-orig/diff.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diff.c 2012-07-16 05:03:03.000000000 -0400 +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 @@ -1,4 +1,4 @@ -/*- +/* @@ -27,7 +27,7 @@ #include <sys/param.h> #include <sys/stat.h> -@@ -45,20 +43,20 @@ __FBSDID("$FreeBSD$"); +@@ -45,20 +43,21 @@ __FBSDID("$FreeBSD$"); #include "diff.h" #include "pathnames.h" @@ -41,6 +41,7 @@ +int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag; +int sflag, tflag, Tflag, wflag, Toflag, Fromflag; +int Bflag, yflag; ++int filebehave; +int strip_cr, suppress_cl, tabsize = 8; +char ignore_file_case = 0; +int format, context, status; @@ -56,7 +57,7 @@ /* Options which exceed manageable alphanumeric assignments */ -@@ -69,107 +67,151 @@ enum +@@ -69,107 +68,163 @@ enum OPT_STRIPCR, OPT_NORMAL, OPT_LEFTC, @@ -261,10 +262,22 @@ - int oargc; - + char *ep, **oargv, *optfile; ++ const char *pn; + long l; + int ch, lastch, gotstdin, prevoptind, newarg; + int oargc; + ++ /* 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; oargc = argc; gotstdin = 0; @@ -272,7 +285,7 @@ lastch = '\0'; prevoptind = 1; -@@ -197,6 +239,7 @@ main(int argc, char **argv) +@@ -197,6 +252,7 @@ main(int argc, char **argv) break; case 'C': case 'c': @@ -280,7 +293,7 @@ format = D_CONTEXT; if (optarg != NULL) { l = strtol(optarg, &ep, 10); -@@ -213,6 +256,9 @@ main(int argc, char **argv) +@@ -213,6 +269,9 @@ main(int argc, char **argv) case 'd': dflag = 1; break; @@ -290,7 +303,7 @@ case 'e': format = D_EDIT; break; -@@ -284,7 +330,7 @@ main(int argc, char **argv) +@@ -284,7 +343,7 @@ main(int argc, char **argv) case 'v': printf("FreeBSD diff 2.8.7\n"); exit(0); @@ -299,7 +312,7 @@ wflag = 1; break; case 'X': -@@ -296,15 +342,48 @@ main(int argc, char **argv) +@@ -296,15 +355,48 @@ main(int argc, char **argv) case 'y': yflag = 1; break; @@ -356,7 +369,7 @@ case OPT_STRIPCR: strip_cr=1; break; -@@ -315,11 +394,10 @@ main(int argc, char **argv) +@@ -315,11 +407,10 @@ main(int argc, char **argv) ignore_file_case = 0; break; case OPT_HELP: @@ -370,7 +383,7 @@ break; default: usage(); -@@ -328,22 +406,22 @@ main(int argc, char **argv) +@@ -328,22 +419,22 @@ main(int argc, char **argv) lastch = ch; newarg = optind != prevoptind; prevoptind = optind; @@ -399,7 +412,7 @@ } /* -@@ -380,7 +458,10 @@ main(int argc, char **argv) +@@ -380,7 +471,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) @@ -411,7 +424,7 @@ diffdir(argv[0], argv[1]); } else { if (S_ISDIR(stb1.st_mode)) { -@@ -393,8 +474,26 @@ main(int argc, char **argv) +@@ -393,8 +487,26 @@ main(int argc, char **argv) if (stat(argv[1], &stb2) < 0) err(2, "%s", argv[1]); } @@ -440,7 +453,7 @@ } exit(status); } -@@ -402,11 +501,10 @@ main(int argc, char **argv) +@@ -402,11 +514,10 @@ main(int argc, char **argv) void * emalloc(size_t n) { @@ -453,7 +466,7 @@ if ((p = malloc(n)) == NULL) errx(2, NULL); return (p); -@@ -415,7 +513,7 @@ emalloc(size_t n) +@@ -415,7 +526,7 @@ emalloc(size_t n) void * erealloc(void *p, size_t n) { @@ -462,7 +475,7 @@ if (n == 0) errx(2, NULL); -@@ -431,13 +529,12 @@ erealloc(void *p, size_t n) +@@ -431,13 +542,12 @@ erealloc(void *p, size_t n) int easprintf(char **ret, const char *fmt, ...) { @@ -478,7 +491,7 @@ if (len < 0 || *ret == NULL) errx(2, NULL); return (len); -@@ -446,20 +543,21 @@ easprintf(char **ret, const char *fmt, . +@@ -446,20 +556,21 @@ easprintf(char **ret, const char *fmt, . char * estrdup(const char *str) { @@ -505,7 +518,7 @@ argsize = 4 + *ave - *av + 1; diffargs = emalloc(argsize); -@@ -475,12 +573,12 @@ set_argstr(char **av, char **ave) +@@ -475,12 +586,12 @@ set_argstr(char **av, char **ave) /* * Read in an excludes file and push each line. */ @@ -522,7 +535,7 @@ if (strcmp(file, "-") == 0) fp = stdin; -@@ -501,7 +599,7 @@ read_excludes_file(char *file) +@@ -501,7 +612,7 @@ read_excludes_file(char *file) /* * Push a pattern onto the excludes list. */ @@ -531,7 +544,7 @@ push_excludes(char *pattern) { struct excludes *entry; -@@ -512,10 +610,10 @@ push_excludes(char *pattern) +@@ -512,10 +623,10 @@ push_excludes(char *pattern) excludes_list = entry; } @@ -544,7 +557,7 @@ if (ignore_pats == NULL) ignore_pats = estrdup(pattern); -@@ -531,6 +629,7 @@ push_ignore_pats(char *pattern) +@@ -531,6 +642,7 @@ push_ignore_pats(char *pattern) void print_only(const char *path, size_t dirlen, const char *entry) { @@ -552,7 +565,7 @@ if (dirlen > 1) dirlen--; printf("Only in %.*s: %s\n", (int)dirlen, path, entry); -@@ -539,52 +638,54 @@ print_only(const char *path, size_t dirl +@@ -539,52 +651,54 @@ print_only(const char *path, size_t dirl void print_status(int val, char *path1, char *path2, char *entry) { @@ -619,16 +632,16 @@ (void)fprintf(stderr, "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n" " [-L label] file1 file2\n" -@@ -595,5 +696,5 @@ usage(void) +@@ -595,5 +709,5 @@ usage(void) " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n" " diff [-v]\n"); - exit(2); + exit(1); } -diff -rupN jhagewood/diff/diff-orig/diff.h jhagewood/diff/diff/diff.h ---- jhagewood/diff/diff-orig/diff.h 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diff.h 2012-07-14 03:47:29.000000000 -0400 +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 . */ @@ -638,7 +651,18 @@ /* * Output flags -@@ -75,9 +77,9 @@ struct excludes { +@@ -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; }; @@ -649,11 +673,13 @@ + 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; -diff -rupN jhagewood/diff/diff-orig/diffdir.c jhagewood/diff/diff/diffdir.c ---- jhagewood/diff/diff-orig/diffdir.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diffdir.c 2012-07-16 05:03:32.000000000 -0400 + 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 @@ -20,13 +20,13 @@ #include <sys/cdefs.h> @@ -760,9 +786,9 @@ strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); if (stat(path1, &stb1) != 0) { -diff -rupN jhagewood/diff/diff-orig/diffreg.c jhagewood/diff/diff/diffreg.c ---- jhagewood/diff/diff-orig/diffreg.c 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/diffreg.c 2012-07-16 05:51:05.000000000 -0400 +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 @@ -62,15 +62,13 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ @@ -783,7 +809,16 @@ #include <sys/param.h> #include <sys/stat.h> -@@ -90,6 +88,14 @@ __FBSDID("$FreeBSD"); +@@ -86,10 +84,23 @@ __FBSDID("$FreeBSD"); + #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" @@ -798,7 +833,7 @@ /* * diff - compare two files. */ -@@ -181,47 +187,47 @@ struct context_vec { +@@ -181,47 +192,47 @@ struct context_vec { }; static FILE *opentemp(const char *); @@ -881,7 +916,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 +300,13 @@ u_char cup2low[256] = { +@@ -294,13 +305,13 @@ u_char cup2low[256] = { int diffreg(char *ofile1, char *ofile2, int flags) { @@ -902,7 +937,7 @@ anychange = 0; lastline = 0; -@@ -310,7 +316,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) @@ -911,7 +946,7 @@ if (flags & D_EMPTY1) f1 = fopen(_PATH_DEVNULL, "r"); -@@ -320,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -320,17 +331,21 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f1), &stb1) < 0) { warn("%s", file1); status |= 2; @@ -920,7 +955,15 @@ } } else if (strcmp(file1, "-") == 0) f1 = stdin; -@@ -330,7 +336,7 @@ diffreg(char *ofile1, char *ofile2, int +- else +- f1 = fopen(file1, "r"); ++ else { ++ if (filebehave == FILE_NORMAL) ++ f1 = fopen(file1, "r"); ++ if (filebehave == FILE_GZIP) ++ f1 = gzopen(file1, "r"); ++ } + } if (f1 == NULL) { warn("%s", file1); status |= 2; @@ -929,7 +972,7 @@ } if (flags & D_EMPTY2) -@@ -341,7 +347,7 @@ diffreg(char *ofile1, char *ofile2, int +@@ -341,34 +356,37 @@ diffreg(char *ofile1, char *ofile2, int fstat(fileno(f2), &stb2) < 0) { warn("%s", file2); status |= 2; @@ -938,7 +981,15 @@ } } else if (strcmp(file2, "-") == 0) f2 = stdin; -@@ -351,24 +357,23 @@ diffreg(char *ofile1, char *ofile2, int +- else +- f2 = fopen(file2, "r"); ++ else { ++ if (filebehave == FILE_NORMAL) ++ f2 = fopen(file2, "r"); ++ if (filebehave == FILE_GZIP) ++ f2 = gzopen(file2, "r"); ++ } + } if (f2 == NULL) { warn("%s", file2); status |= 2; @@ -968,7 +1019,7 @@ } if (lflag) { /* redirect stdout to pr */ -@@ -452,7 +457,11 @@ diffreg(char *ofile1, char *ofile2, int +@@ -452,7 +470,11 @@ diffreg(char *ofile1, char *ofile2, int } waitpid(pid, &wstatus, 0); } @@ -981,7 +1032,7 @@ if (anychange) { status |= 1; if (rval == D_SAME) -@@ -477,8 +486,8 @@ closem: +@@ -477,8 +499,8 @@ closem: static int files_differ(FILE *f1, FILE *f2, int flags) { @@ -992,7 +1043,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 +512,9 @@ files_differ(FILE *f1, FILE *f2, int fla +@@ -503,9 +525,9 @@ files_differ(FILE *f1, FILE *f2, int fla static FILE * opentemp(const char *file) { @@ -1005,7 +1056,7 @@ if (strcmp(file, "-") == 0) ifd = STDIN_FILENO; -@@ -541,7 +550,7 @@ opentemp(const char *file) +@@ -541,7 +563,7 @@ opentemp(const char *file) char * splice(char *dir, char *file) { @@ -1014,7 +1065,7 @@ if ((tail = strrchr(file, '/')) == NULL) tail = file; -@@ -555,8 +564,8 @@ static void +@@ -555,8 +577,8 @@ static void prepare(int i, FILE *fd, off_t filesize) { struct line *p; @@ -1025,7 +1076,7 @@ rewind(fd); -@@ -579,7 +588,7 @@ prepare(int i, FILE *fd, off_t filesize) +@@ -579,7 +601,7 @@ prepare(int i, FILE *fd, off_t filesize) static void prune(void) { @@ -1034,7 +1085,7 @@ for (pref = 0; pref < len[0] && pref < len[1] && file[0][pref + 1].value == file[1][pref + 1].value; -@@ -600,7 +609,7 @@ prune(void) +@@ -600,7 +622,7 @@ prune(void) static void equiv(struct line *a, int n, struct line *b, int m, int *c) { @@ -1043,7 +1094,7 @@ i = j = 1; while (i <= n && j <= m) { -@@ -629,7 +638,7 @@ equiv(struct line *a, int n, struct line +@@ -629,7 +651,7 @@ equiv(struct line *a, int n, struct line static int isqrt(int n) { @@ -1052,7 +1103,7 @@ if (n == 0) return (0); -@@ -647,9 +656,9 @@ isqrt(int n) +@@ -647,9 +669,9 @@ isqrt(int n) static int stone(int *a, int n, int *b, int *c) { @@ -1065,7 +1116,7 @@ const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n)); k = 0; -@@ -705,7 +714,7 @@ newcand(int x, int y, int pred) +@@ -705,7 +727,7 @@ newcand(int x, int y, int pred) static int search(int *c, int k, int y) { @@ -1074,7 +1125,7 @@ if (clist[c[k]].y < y) /* quick look for typical case */ return (k + 1); -@@ -730,7 +739,7 @@ static void +@@ -730,7 +752,7 @@ static void unravel(int p) { struct cand *q; @@ -1083,7 +1134,7 @@ for (i = 0; i <= len[0]; i++) J[i] = i <= pref ? i : -@@ -748,9 +757,10 @@ unravel(int p) +@@ -748,9 +770,10 @@ unravel(int p) static void check(char *file1, FILE *f1, char *file2, FILE *f2) { @@ -1097,7 +1148,7 @@ rewind(f1); rewind(f2); j = 1; -@@ -766,7 +776,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -766,7 +789,7 @@ check(char *file1, FILE *f1, char *file2 ixnew[j] = ctnew += skipline(f2); j++; } @@ -1106,7 +1157,7 @@ for (;;) { c = getc(f1); d = getc(f2); -@@ -781,6 +791,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -781,6 +804,7 @@ check(char *file1, FILE *f1, char *file2 } ctold++; ctnew++; @@ -1114,7 +1165,7 @@ if (bflag && isspace(c) && isspace(d)) { do { if (c == '\n') -@@ -792,6 +803,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -792,6 +816,7 @@ check(char *file1, FILE *f1, char *file2 break; ctnew++; } while (isspace(d = getc(f2))); @@ -1122,7 +1173,7 @@ } else if (wflag) { while (isspace(c) && c != '\n') { c = getc(f1); -@@ -801,31 +813,55 @@ check(char *file1, FILE *f1, char *file2 +@@ -801,31 +826,55 @@ check(char *file1, FILE *f1, char *file2 d = getc(f2); ctnew++; } @@ -1199,7 +1250,7 @@ if (chrtran[c] != chrtran[d]) { jackpot++; J[i] = 0; -@@ -872,7 +908,7 @@ static void +@@ -872,7 +921,7 @@ static void sort(struct line *a, int n) { struct line *ai, *aim, w; @@ -1208,7 +1259,7 @@ if (n == 0) return; -@@ -916,7 +952,7 @@ unsort(struct line *f, int l, int *b) +@@ -916,7 +965,7 @@ unsort(struct line *f, int l, int *b) static int skipline(FILE *f) { @@ -1217,7 +1268,7 @@ for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++) continue; -@@ -926,7 +962,7 @@ skipline(FILE *f) +@@ -926,7 +975,7 @@ skipline(FILE *f) static void output(char *file1, FILE *f1, char *file2, FILE *f2, int flags) { @@ -1226,7 +1277,7 @@ rewind(f1); rewind(f2); -@@ -965,7 +1001,7 @@ output(char *file1, FILE *f1, char *file +@@ -965,7 +1014,7 @@ output(char *file1, FILE *f1, char *file #define c i0 if ((c = getc(f1)) == EOF) return; @@ -1235,7 +1286,7 @@ } #undef c } -@@ -980,6 +1016,7 @@ output(char *file1, FILE *f1, char *file +@@ -980,6 +1029,7 @@ output(char *file1, FILE *f1, char *file static void range(int a, int b, char *separator) { @@ -1243,7 +1294,7 @@ printf("%d", a > b ? b : a); if (a < b) printf("%s%d", separator, b); -@@ -988,6 +1025,7 @@ range(int a, int b, char *separator) +@@ -988,6 +1038,7 @@ range(int a, int b, char *separator) static void uni_range(int a, int b) { @@ -1251,7 +1302,7 @@ if (a < b) printf("%d,%d", a, b - a + 1); else if (a == b) -@@ -999,22 +1037,22 @@ uni_range(int a, int b) +@@ -999,22 +1050,22 @@ uni_range(int a, int b) static char * preadline(int fd, size_t len, off_t off) { @@ -1278,7 +1329,7 @@ ret = regexec(&ignore_re, line, 0, NULL, 0); free(line); -@@ -1032,10 +1070,10 @@ static void +@@ -1032,10 +1083,10 @@ static void change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d, int *pflags) { @@ -1292,7 +1343,7 @@ if (format != D_IFDEF && a > b && c > d) return; if (ignore_pats != NULL) { -@@ -1050,7 +1088,7 @@ restart: +@@ -1050,7 +1101,7 @@ restart: line = preadline(fileno(f1), ixold[i] - ixold[i - 1], ixold[i - 1]); if (!ignoreline(line)) @@ -1301,7 +1352,7 @@ } } if (a > b || c <= d) { /* Changes and inserts. */ -@@ -1058,12 +1096,12 @@ restart: +@@ -1058,12 +1109,12 @@ restart: line = preadline(fileno(f2), ixnew[i] - ixnew[i - 1], ixnew[i - 1]); if (!ignoreline(line)) @@ -1316,7 +1367,7 @@ if (*pflags & D_HEADER) { printf("%s %s %s\n", diffargs, file1, file2); *pflags &= ~D_HEADER; -@@ -1113,15 +1151,15 @@ proceed: +@@ -1113,15 +1164,15 @@ proceed: case D_NORMAL: case D_EDIT: range(a, b, ","); @@ -1336,7 +1387,7 @@ break; case D_NREVERSE: if (a > b) -@@ -1137,7 +1175,7 @@ proceed: +@@ -1137,7 +1188,7 @@ proceed: if (format == D_NORMAL || format == D_IFDEF) { fetch(ixold, a, b, f1, '<', 1); if (a <= b && c <= d && format == D_NORMAL) @@ -1345,7 +1396,7 @@ } i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0); if (i != 0 && format == D_EDIT) { -@@ -1148,14 +1186,14 @@ proceed: +@@ -1148,14 +1199,14 @@ proceed: * it. We have to add a substitute command to change this * back and restart where we left off. */ @@ -1363,7 +1414,7 @@ if (inifdef) { printf("#endif /* %s */\n", ifdefname); inifdef = 0; -@@ -1165,8 +1203,8 @@ proceed: +@@ -1165,8 +1216,8 @@ proceed: static int fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile) { @@ -1374,7 +1425,7 @@ /* * When doing #ifdef's, copy down to current line -@@ -1177,7 +1215,7 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1177,7 +1228,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++) @@ -1383,7 +1434,7 @@ } if (a > b) return (0); -@@ -1197,12 +1235,12 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1197,12 +1248,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') { @@ -1399,7 +1450,7 @@ } col = 0; for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { -@@ -1211,13 +1249,13 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1211,13 +1262,13 @@ fetch(long *f, int a, int b, FILE *lb, i format == D_NREVERSE) warnx("No newline at end of file"); else @@ -1415,7 +1466,7 @@ } while (++col < newcol); } else { if (format == D_EDIT && j == 1 && c == '\n' -@@ -1229,10 +1267,10 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1229,10 +1280,10 @@ fetch(long *f, int a, int b, FILE *lb, i * giving the caller an offset * from which to restart. */ @@ -1428,7 +1479,7 @@ col++; } } -@@ -1246,8 +1284,8 @@ fetch(long *f, int a, int b, FILE *lb, i +@@ -1246,8 +1297,8 @@ fetch(long *f, int a, int b, FILE *lb, i static int readhash(FILE *f) { @@ -1439,7 +1490,7 @@ sum = 1; space = 0; -@@ -1305,20 +1343,28 @@ readhash(FILE *f) +@@ -1305,20 +1356,28 @@ readhash(FILE *f) return (sum == 0 ? 1 : sum); } @@ -1454,7 +1505,7 @@ { - char buf[BUFSIZ]; - int i, cnt; -+ int i, check_size; ++ int i; + char ch; if (aflag || f == NULL) @@ -1475,7 +1526,7 @@ return (1); } -@@ -1327,10 +1373,10 @@ asciifile(FILE *f) +@@ -1327,10 +1386,10 @@ asciifile(FILE *f) static char * match_function(const long *f, int pos, FILE *file) { @@ -1490,7 +1541,7 @@ lastline = pos; while (pos > last) { -@@ -1342,7 +1388,6 @@ match_function(const long *f, int pos, F +@@ -1342,7 +1401,6 @@ match_function(const long *f, int pos, F if (nc > 0) { buf[nc] = '\0'; buf[strcspn(buf, "\n")] = '\0'; @@ -1498,7 +1549,7 @@ if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) -@@ -1373,9 +1418,9 @@ static void +@@ -1373,9 +1431,9 @@ static void dump_context_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1511,7 +1562,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1390,8 +1435,8 @@ dump_context_vec(FILE *f1, FILE *f2) +@@ -1390,8 +1448,8 @@ dump_context_vec(FILE *f1, FILE *f2) if (pflag) { f = match_function(ixold, lowa-1, f1); if (f != NULL) { @@ -1522,7 +1573,7 @@ } } printf("\n*** "); -@@ -1478,9 +1523,9 @@ static void +@@ -1478,9 +1536,9 @@ static void dump_unified_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1535,7 +1586,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1491,19 +1536,19 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1491,19 +1549,19 @@ dump_unified_vec(FILE *f1, FILE *f2) lowc = MAX(1, cvp->c - context); upd = MIN(len[1], context_vec_ptr->d + context); @@ -1561,7 +1612,7 @@ /* * Output changes in "unified" diff format--the old and new lines -@@ -1551,16 +1596,43 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1551,16 +1609,43 @@ dump_unified_vec(FILE *f1, FILE *f2) static void print_header(const char *file1, const char *file2) { @@ -1611,12 +1662,3 @@ + printf("%s %s\t%s\n", format == D_CONTEXT ? "---" : "+++", + file2, buf2); } -diff -rupN jhagewood/diff/diff-orig/pathnames.h jhagewood/diff/diff/pathnames.h ---- jhagewood/diff/diff-orig/pathnames.h 2012-07-14 03:47:28.000000000 -0400 -+++ jhagewood/diff/diff/pathnames.h 2012-07-14 03:47:29.000000000 -0400 -@@ -23,4 +23,5 @@ - #include <paths.h> - - #define _PATH_PR "/usr/bin/pr" -+#define _PATH_DIFF "/usr/bin/diff" - #define _PATH_SDIFF "/usr/bin/sdiff"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120724013648.EAFD3106564A>