socsvn commit: r239915 - in soc2012/jhagewood: diff diff/diff sdiff
sdiff/sdiff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Mon Jul 30 13:20:45 UTC 2012
Author: jhagewood
Date: Mon Jul 30 13:20:42 2012
New Revision: 239915
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239915
Log:
Modified:
soc2012/jhagewood/diff/diff/diffreg.c
soc2012/jhagewood/diff/hagewood-diff.patch
soc2012/jhagewood/sdiff/hagewood-sdiff.patch
soc2012/jhagewood/sdiff/sdiff/sdiff.c
Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 30 12:25:20 2012 (r239914)
+++ soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 30 13:20:42 2012 (r239915)
@@ -344,8 +344,9 @@
if (filebehave == FILE_NORMAL)
f1 = fopen(file1, "r");
if (filebehave == FILE_GZIP) {
- gz1 = gzdopen(file1, "r");
- gzdread(gz1, buf, MAX_INT);
+ 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");
}
}
@@ -372,8 +373,9 @@
if (filebehave == FILE_NORMAL)
f2 = fopen(file2, "r");
if (filebehave == FILE_GZIP)
- gz2 = gzdopen(file2, "r");
- gzdread(gz2, buf, MAX_INT);
+ 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");
}
}
Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 30 12:25:20 2012 (r239914)
+++ soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 30 13:20:42 2012 (r239915)
@@ -1,6 +1,18 @@
+diff -rupN diff-orig/Makefile diff/Makefile
+--- diff-orig/Makefile 2012-07-26 03:11:00.000000000 -0400
++++ diff/Makefile 2012-07-26 03:11:00.000000000 -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
+
diff -rupN diff-orig/diff.c diff/diff.c
---- diff-orig/diff.c 2012-07-25 11:37:23.299991134 -0400
-+++ diff/diff.c 2012-07-25 11:37:23.727991128 -0400
+--- diff-orig/diff.c 2012-07-26 03:11:00.000000000 -0400
++++ diff/diff.c 2012-07-26 03:11:00.000000000 -0400
@@ -1,4 +1,4 @@
-/*-
+/*
@@ -57,7 +69,7 @@
/* Options which exceed manageable alphanumeric assignments */
-@@ -69,107 +68,163 @@ enum
+@@ -69,107 +68,163 @@ enum
OPT_STRIPCR,
OPT_NORMAL,
OPT_LEFTC,
@@ -639,9 +651,47 @@
- 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
+@@ -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-25 11:37:23.299991134 -0400
-+++ diff/diffdir.c 2012-07-25 11:37:23.726991126 -0400
+--- diff-orig/diffdir.c 2012-07-26 03:11:00.000000000 -0400
++++ diff/diffdir.c 2012-07-26 03:11:00.000000000 -0400
@@ -20,13 +20,13 @@
#include <sys/cdefs.h>
@@ -748,47 +798,9 @@
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-25 11:37:23.298991134 -0400
-+++ diff/diffreg.c 2012-07-25 12:07:51.966957049 -0400
+--- diff-orig/diffreg.c 2012-07-26 03:11:00.000000000 -0400
++++ diff/diffreg.c 2012-07-30 13:11:25.000000000 -0400
@@ -62,15 +62,13 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
@@ -809,14 +821,7 @@
#include <sys/param.h>
#include <sys/stat.h>
-@@ -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>
+@@ -86,10 +84,24 @@ __FBSDID("$FreeBSD");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -835,6 +840,7 @@
+# define TIMESPEC_NS(timespec) 0
+#endif
+
++#define MAX_INT 2147483647
+#define MAX_CHECK 768 /* 3 kilobytes of chars. */
+
/*
@@ -948,7 +954,7 @@
anychange = 0;
lastline = 0;
-@@ -310,7 +326,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)
@@ -957,7 +963,7 @@
if (flags & D_EMPTY1)
f1 = fopen(_PATH_DEVNULL, "r");
-@@ -320,17 +336,24 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -320,17 +336,25 @@ diffreg(char *ofile1, char *ofile2, int
fstat(fileno(f1), &stb1) < 0) {
warn("%s", file1);
status |= 2;
@@ -972,7 +978,8 @@
+ if (filebehave == FILE_NORMAL)
+ f1 = fopen(file1, "r");
+ if (filebehave == FILE_GZIP) {
-+ gz1 = gzopen(file1, "r");
++ 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");
+ }
@@ -986,7 +993,7 @@
}
if (flags & D_EMPTY2)
-@@ -341,34 +364,39 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -341,34 +365,40 @@ diffreg(char *ofile1, char *ofile2, int
fstat(fileno(f2), &stb2) < 0) {
warn("%s", file2);
status |= 2;
@@ -1001,7 +1008,8 @@
+ if (filebehave == FILE_NORMAL)
+ f2 = fopen(file2, "r");
+ if (filebehave == FILE_GZIP)
-+ gz2 = gzopen(file2, "r");
++ 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");
+ }
@@ -1035,7 +1043,7 @@
}
if (lflag) {
/* redirect stdout to pr */
-@@ -452,7 +480,11 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -452,7 +482,11 @@ diffreg(char *ofile1, char *ofile2, int
}
waitpid(pid, &wstatus, 0);
}
@@ -1048,7 +1056,7 @@
if (anychange) {
status |= 1;
if (rval == D_SAME)
-@@ -477,8 +509,8 @@ closem:
+@@ -477,8 +511,8 @@ closem:
static int
files_differ(FILE *f1, FILE *f2, int flags)
{
@@ -1059,7 +1067,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 +535,9 @@ files_differ(FILE *f1, FILE *f2, int fla
+@@ -503,9 +537,9 @@ files_differ(FILE *f1, FILE *f2, int fla
static FILE *
opentemp(const char *file)
{
@@ -1072,7 +1080,7 @@
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
-@@ -541,7 +573,7 @@ opentemp(const char *file)
+@@ -541,7 +575,7 @@ opentemp(const char *file)
char *
splice(char *dir, char *file)
{
@@ -1081,7 +1089,7 @@
if ((tail = strrchr(file, '/')) == NULL)
tail = file;
-@@ -555,8 +587,8 @@ static void
+@@ -555,8 +589,8 @@ static void
prepare(int i, FILE *fd, off_t filesize)
{
struct line *p;
@@ -1092,7 +1100,7 @@
rewind(fd);
-@@ -579,7 +611,7 @@ prepare(int i, FILE *fd, off_t filesize)
+@@ -579,7 +613,7 @@ prepare(int i, FILE *fd, off_t filesize)
static void
prune(void)
{
@@ -1101,7 +1109,7 @@
for (pref = 0; pref < len[0] && pref < len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
-@@ -600,7 +632,7 @@ prune(void)
+@@ -600,7 +634,7 @@ prune(void)
static void
equiv(struct line *a, int n, struct line *b, int m, int *c)
{
@@ -1110,7 +1118,7 @@
i = j = 1;
while (i <= n && j <= m) {
-@@ -629,7 +661,7 @@ equiv(struct line *a, int n, struct line
+@@ -629,7 +663,7 @@ equiv(struct line *a, int n, struct line
static int
isqrt(int n)
{
@@ -1119,7 +1127,7 @@
if (n == 0)
return (0);
-@@ -647,9 +679,9 @@ isqrt(int n)
+@@ -647,9 +681,9 @@ isqrt(int n)
static int
stone(int *a, int n, int *b, int *c)
{
@@ -1132,7 +1140,7 @@
const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
k = 0;
-@@ -705,7 +737,7 @@ newcand(int x, int y, int pred)
+@@ -705,7 +739,7 @@ newcand(int x, int y, int pred)
static int
search(int *c, int k, int y)
{
@@ -1141,7 +1149,7 @@
if (clist[c[k]].y < y) /* quick look for typical case */
return (k + 1);
-@@ -730,7 +762,7 @@ static void
+@@ -730,7 +764,7 @@ static void
unravel(int p)
{
struct cand *q;
@@ -1150,7 +1158,7 @@
for (i = 0; i <= len[0]; i++)
J[i] = i <= pref ? i :
-@@ -748,9 +780,10 @@ unravel(int p)
+@@ -748,9 +782,10 @@ unravel(int p)
static void
check(char *file1, FILE *f1, char *file2, FILE *f2)
{
@@ -1164,7 +1172,7 @@
rewind(f1);
rewind(f2);
j = 1;
-@@ -766,7 +799,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -766,7 +801,7 @@ check(char *file1, FILE *f1, char *file2
ixnew[j] = ctnew += skipline(f2);
j++;
}
@@ -1173,7 +1181,7 @@
for (;;) {
c = getc(f1);
d = getc(f2);
-@@ -781,6 +814,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -781,6 +816,7 @@ check(char *file1, FILE *f1, char *file2
}
ctold++;
ctnew++;
@@ -1181,7 +1189,7 @@
if (bflag && isspace(c) && isspace(d)) {
do {
if (c == '\n')
-@@ -792,6 +826,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -792,6 +828,7 @@ check(char *file1, FILE *f1, char *file2
break;
ctnew++;
} while (isspace(d = getc(f2)));
@@ -1189,7 +1197,7 @@
} else if (wflag) {
while (isspace(c) && c != '\n') {
c = getc(f1);
-@@ -801,31 +836,55 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +838,55 @@ check(char *file1, FILE *f1, char *file2
d = getc(f2);
ctnew++;
}
@@ -1266,7 +1274,7 @@
if (chrtran[c] != chrtran[d]) {
jackpot++;
J[i] = 0;
-@@ -872,7 +931,7 @@ static void
+@@ -872,7 +933,7 @@ static void
sort(struct line *a, int n)
{
struct line *ai, *aim, w;
@@ -1275,7 +1283,7 @@
if (n == 0)
return;
-@@ -916,7 +975,7 @@ unsort(struct line *f, int l, int *b)
+@@ -916,7 +977,7 @@ unsort(struct line *f, int l, int *b)
static int
skipline(FILE *f)
{
@@ -1284,7 +1292,7 @@
for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
continue;
-@@ -926,7 +985,7 @@ skipline(FILE *f)
+@@ -926,7 +987,7 @@ skipline(FILE *f)
static void
output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
{
@@ -1293,7 +1301,7 @@
rewind(f1);
rewind(f2);
-@@ -965,7 +1024,7 @@ output(char *file1, FILE *f1, char *file
+@@ -965,7 +1026,7 @@ output(char *file1, FILE *f1, char *file
#define c i0
if ((c = getc(f1)) == EOF)
return;
@@ -1302,7 +1310,7 @@
}
#undef c
}
-@@ -980,6 +1039,7 @@ output(char *file1, FILE *f1, char *file
+@@ -980,6 +1041,7 @@ output(char *file1, FILE *f1, char *file
static void
range(int a, int b, char *separator)
{
@@ -1310,7 +1318,7 @@
printf("%d", a > b ? b : a);
if (a < b)
printf("%s%d", separator, b);
-@@ -988,6 +1048,7 @@ range(int a, int b, char *separator)
+@@ -988,6 +1050,7 @@ range(int a, int b, char *separator)
static void
uni_range(int a, int b)
{
@@ -1318,7 +1326,7 @@
if (a < b)
printf("%d,%d", a, b - a + 1);
else if (a == b)
-@@ -999,22 +1060,22 @@ uni_range(int a, int b)
+@@ -999,22 +1062,22 @@ uni_range(int a, int b)
static char *
preadline(int fd, size_t len, off_t off)
{
@@ -1345,7 +1353,7 @@
ret = regexec(&ignore_re, line, 0, NULL, 0);
free(line);
-@@ -1032,10 +1093,10 @@ static void
+@@ -1032,10 +1095,10 @@ static void
change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
int *pflags)
{
@@ -1359,7 +1367,7 @@
if (format != D_IFDEF && a > b && c > d)
return;
if (ignore_pats != NULL) {
-@@ -1050,7 +1111,7 @@ restart:
+@@ -1050,7 +1113,7 @@ restart:
line = preadline(fileno(f1),
ixold[i] - ixold[i - 1], ixold[i - 1]);
if (!ignoreline(line))
@@ -1368,7 +1376,7 @@
}
}
if (a > b || c <= d) { /* Changes and inserts. */
-@@ -1058,12 +1119,12 @@ restart:
+@@ -1058,12 +1121,12 @@ restart:
line = preadline(fileno(f2),
ixnew[i] - ixnew[i - 1], ixnew[i - 1]);
if (!ignoreline(line))
@@ -1383,7 +1391,7 @@
if (*pflags & D_HEADER) {
printf("%s %s %s\n", diffargs, file1, file2);
*pflags &= ~D_HEADER;
-@@ -1113,15 +1174,15 @@ proceed:
+@@ -1113,15 +1176,15 @@ proceed:
case D_NORMAL:
case D_EDIT:
range(a, b, ",");
@@ -1403,7 +1411,7 @@
break;
case D_NREVERSE:
if (a > b)
-@@ -1137,7 +1198,7 @@ proceed:
+@@ -1137,7 +1200,7 @@ proceed:
if (format == D_NORMAL || format == D_IFDEF) {
fetch(ixold, a, b, f1, '<', 1);
if (a <= b && c <= d && format == D_NORMAL)
@@ -1412,7 +1420,7 @@
}
i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
if (i != 0 && format == D_EDIT) {
-@@ -1148,14 +1209,14 @@ proceed:
+@@ -1148,14 +1211,14 @@ proceed:
* it. We have to add a substitute command to change this
* back and restart where we left off.
*/
@@ -1430,7 +1438,7 @@
if (inifdef) {
printf("#endif /* %s */\n", ifdefname);
inifdef = 0;
-@@ -1165,8 +1226,8 @@ proceed:
+@@ -1165,8 +1228,8 @@ proceed:
static int
fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
{
@@ -1441,7 +1449,7 @@
/*
* When doing #ifdef's, copy down to current line
-@@ -1177,7 +1238,7 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1177,7 +1240,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++)
@@ -1450,7 +1458,7 @@
}
if (a > b)
return (0);
-@@ -1197,12 +1258,12 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1197,12 +1260,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') {
@@ -1466,7 +1474,7 @@
}
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
-@@ -1211,13 +1272,13 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1211,13 +1274,13 @@ fetch(long *f, int a, int b, FILE *lb, i
format == D_NREVERSE)
warnx("No newline at end of file");
else
@@ -1482,7 +1490,7 @@
} while (++col < newcol);
} else {
if (format == D_EDIT && j == 1 && c == '\n'
-@@ -1229,10 +1290,10 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1229,10 +1292,10 @@ fetch(long *f, int a, int b, FILE *lb, i
* giving the caller an offset
* from which to restart.
*/
@@ -1495,7 +1503,7 @@
col++;
}
}
-@@ -1246,8 +1307,8 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1246,8 +1309,8 @@ fetch(long *f, int a, int b, FILE *lb, i
static int
readhash(FILE *f)
{
@@ -1506,7 +1514,7 @@
sum = 1;
space = 0;
-@@ -1305,20 +1366,28 @@ readhash(FILE *f)
+@@ -1305,20 +1368,28 @@ readhash(FILE *f)
return (sum == 0 ? 1 : sum);
}
@@ -1542,7 +1550,7 @@
return (1);
}
-@@ -1327,10 +1396,10 @@ asciifile(FILE *f)
+@@ -1327,10 +1398,10 @@ asciifile(FILE *f)
static char *
match_function(const long *f, int pos, FILE *file)
{
@@ -1557,7 +1565,7 @@
lastline = pos;
while (pos > last) {
-@@ -1342,7 +1411,6 @@ match_function(const long *f, int pos, F
+@@ -1342,7 +1413,6 @@ match_function(const long *f, int pos, F
if (nc > 0) {
buf[nc] = '\0';
buf[strcspn(buf, "\n")] = '\0';
@@ -1565,7 +1573,7 @@
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
if (begins_with(buf, "private:")) {
if (!state)
-@@ -1373,9 +1441,9 @@ static void
+@@ -1373,9 +1443,9 @@ static void
dump_context_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1578,7 +1586,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1390,8 +1458,8 @@ dump_context_vec(FILE *f1, FILE *f2)
+@@ -1390,8 +1460,8 @@ dump_context_vec(FILE *f1, FILE *f2)
if (pflag) {
f = match_function(ixold, lowa-1, f1);
if (f != NULL) {
@@ -1589,7 +1597,7 @@
}
}
printf("\n*** ");
-@@ -1478,9 +1546,9 @@ static void
+@@ -1478,9 +1548,9 @@ static void
dump_unified_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1602,7 +1610,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1491,19 +1559,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1491,19 +1561,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
lowc = MAX(1, cvp->c - context);
upd = MIN(len[1], context_vec_ptr->d + context);
@@ -1628,7 +1636,7 @@
/*
* Output changes in "unified" diff format--the old and new lines
-@@ -1551,16 +1619,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1551,16 +1621,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
static void
print_header(const char *file1, const char *file2)
{
@@ -1678,15 +1686,3 @@
+ 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
-
Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch
==============================================================================
--- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 30 12:25:20 2012 (r239914)
+++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 30 13:20:42 2012 (r239915)
@@ -173,7 +173,7 @@
+
diff -rupN sdiff-orig/sdiff.c sdiff/sdiff.c
--- sdiff-orig/sdiff.c 2012-07-26 03:11:02.000000000 -0400
-+++ sdiff/sdiff.c 2012-07-30 12:54:48.000000000 -0400
++++ sdiff/sdiff.c 2012-07-30 13:14:21.000000000 -0400
@@ -5,6 +5,14 @@
* Public domain.
*/
@@ -531,16 +531,21 @@
execvp(diffprog, diffargv);
err(2, "could not execute diff: %s", diffprog);
break;
-@@ -406,6 +436,16 @@ main(int argc, char **argv)
+@@ -406,6 +436,21 @@ main(int argc, char **argv)
if ((file2 = fopen(filename2, "r")) == NULL)
err(2, "could not open %s", filename2);
+ if (!istextfile(file1) || !istextfile(file2)) {
++ /* Close open files and pipe, delete temps */
+ fclose(file1);
+ fclose(file2);
+ fclose(diffpipe);
-+ unlink(tmp1);
-+ unlink(tmp2);
++ if (tmp1)
++ if (unlink(tmp1))
++ warn("Error deleting %s.", tmp1);
++ if (tmp2)
++ if (unlink(tmp2))
++ warn("Error deleting %s.", tmp2);
+ free(tmp1);
+ free(tmp2);
+ binexec(diffprog, filename1, filename2);
@@ -548,7 +553,26 @@
/* Line numbers start at one. */
file1ln = file2ln = 1;
-@@ -452,6 +492,39 @@ main(int argc, char **argv)
+@@ -417,15 +462,15 @@ main(int argc, char **argv)
+ /* Wait for diff to exit. */
+ if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status) ||
+ WEXITSTATUS(status) >= 2)
+- err(2, "diff exited abnormally");
++ err(2, "diff exited abnormally.");
+
+ /* Delete and free unneeded temporary files. */
+ if (tmp1)
+ if (unlink(tmp1))
+- warn("error deleting %s", tmp1);
++ warn("Error deleting %s.", tmp1);
+ if (tmp2)
+ if (unlink(tmp2))
+- warn("error deleting %s", tmp2);
++ warn("Error deleting %s.", tmp2);
+ free(tmp1);
+ free(tmp2);
+ filename1 = filename2 = tmp1 = tmp2 = NULL;
+@@ -452,6 +497,40 @@ main(int argc, char **argv)
return (WEXITSTATUS(status));
}
@@ -559,7 +583,8 @@
+ char *args[] = {diffprog, f1, f2, (char *) 0};
+
+ execv(diffprog, args);
-+ printf("Could not execute diff process.\n");
++ /* If execv() fails, this program's execution will continue. */
++ sprintf(stderr, "Could not execute diff process.\n");
+ exit(1);
+}
+/*
@@ -588,7 +613,7 @@
/*
* Prints an individual column (left or right), taking into account
* that tabs are variable-width. Takes a string, the current column
-@@ -461,6 +534,7 @@ main(int argc, char **argv)
+@@ -461,6 +540,7 @@ main(int argc, char **argv)
static void
printcol(const char *s, size_t *col, const size_t col_max)
{
@@ -596,7 +621,7 @@
for (; *s && *col < col_max; ++s) {
size_t new_col;
-@@ -484,11 +558,9 @@ printcol(const char *s, size_t *col, con
+@@ -484,11 +564,9 @@ printcol(const char *s, size_t *col, con
return;
*col = new_col;
break;
@@ -608,7 +633,7 @@
putchar(*s);
}
}
-@@ -512,56 +584,47 @@ prompt(const char *s1, const char *s2)
+@@ -512,56 +590,47 @@ prompt(const char *s1, const char *s2)
/* Skip leading whitespace. */
for (p = cmd; isspace(*p); ++p)
;
@@ -674,7 +699,7 @@
free(cmd);
return;
}
-@@ -570,7 +633,7 @@ PROMPT:
+@@ -570,7 +639,7 @@ PROMPT:
* If there was no error, we received an EOF from stdin, so we
* should quit.
*/
@@ -683,7 +708,7 @@
fclose(outfp);
exit(0);
}
-@@ -678,7 +741,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
+@@ -678,7 +747,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
/* A range is specified for file1. */
if (c == ',') {
@@ -691,7 +716,7 @@
q = p;
/* Go to character after file2end. */
while (isdigit(*p))
-@@ -690,7 +752,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
+@@ -690,7 +758,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
errx(2, "file1 end is %s: %s", errstr, line);
if (file1start > file1end)
errx(2, "invalid line range in file1: %s", line);
@@ -699,7 +724,7 @@
} else
file1end = file1start;
-@@ -809,17 +870,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
+@@ -809,17 +876,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI
printa(file2, file2end);
n = file2end - file2start + 1;
break;
@@ -717,7 +742,7 @@
default:
errx(2, "invalid diff command: %c: %s", cmd, line);
}
-@@ -854,6 +912,7 @@ enqueue(char *left, char div, char *righ
+@@ -854,6 +918,7 @@ enqueue(char *left, char div, char *righ
static void
freediff(struct diffline *diffp)
{
@@ -725,7 +750,7 @@
free(diffp->left);
free(diffp->right);
free(diffp);
-@@ -876,7 +935,6 @@ astrcat(char **s, const char *append)
+@@ -876,7 +941,6 @@ astrcat(char **s, const char *append)
static const char *oldstr = NULL;
char *newstr;
@@ -733,7 +758,7 @@
/*
* First string is NULL, so just copy append.
*/
-@@ -1002,7 +1060,6 @@ printa(FILE *file, size_t line2)
+@@ -1002,7 +1066,6 @@ printa(FILE *file, size_t line2)
errx(2, "append ended early");
enqueue(NULL, '>', line);
}
@@ -741,7 +766,7 @@
processq();
}
-@@ -1103,24 +1160,36 @@ printd(FILE *file1, size_t file1end)
+@@ -1103,24 +1166,36 @@ printd(FILE *file1, size_t file1end)
static void
int_usage(void)
{
Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c
==============================================================================
--- soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 30 12:25:20 2012 (r239914)
+++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 30 13:20:42 2012 (r239915)
@@ -437,11 +437,16 @@
err(2, "could not open %s", filename2);
if (!istextfile(file1) || !istextfile(file2)) {
+ /* Close open files and pipe, delete temps */
fclose(file1);
fclose(file2);
fclose(diffpipe);
- unlink(tmp1);
- unlink(tmp2);
+ if (tmp1)
+ if (unlink(tmp1))
+ warn("Error deleting %s.", tmp1);
+ if (tmp2)
+ if (unlink(tmp2))
+ warn("Error deleting %s.", tmp2);
free(tmp1);
free(tmp2);
binexec(diffprog, filename1, filename2);
@@ -457,15 +462,15 @@
/* Wait for diff to exit. */
if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status) ||
WEXITSTATUS(status) >= 2)
- err(2, "diff exited abnormally");
+ err(2, "diff exited abnormally.");
/* Delete and free unneeded temporary files. */
if (tmp1)
if (unlink(tmp1))
- warn("error deleting %s", tmp1);
+ warn("Error deleting %s.", tmp1);
if (tmp2)
if (unlink(tmp2))
- warn("error deleting %s", tmp2);
+ warn("Error deleting %s.", tmp2);
free(tmp1);
free(tmp2);
filename1 = filename2 = tmp1 = tmp2 = NULL;
@@ -499,7 +504,8 @@
char *args[] = {diffprog, f1, f2, (char *) 0};
execv(diffprog, args);
- printf("Could not execute diff process.\n");
+ /* If execv() fails, this program's execution will continue. */
+ sprintf(stderr, "Could not execute diff process.\n");
exit(1);
}
/*
More information about the svn-soc-all
mailing list