socsvn commit: r238602 - in soc2012/jhagewood/diff: . diff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Fri Jun 29 19:29:24 UTC 2012
Author: jhagewood
Date: Fri Jun 29 19:29:20 2012
New Revision: 238602
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238602
Log:
Modified:
soc2012/jhagewood/diff/diff/diffreg.c
soc2012/jhagewood/diff/hagewood-diff.patch
Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c Fri Jun 29 18:49:14 2012 (r238601)
+++ soc2012/jhagewood/diff/diff/diffreg.c Fri Jun 29 19:29:20 2012 (r238602)
@@ -94,6 +94,7 @@
# define TIMESPEC_NS(timespec) 0
#endif
+#define MAX_CHECK 768
/*
* diff - compare two files.
*/
@@ -1345,20 +1346,25 @@
}
/*
- * Checks if an open file is a text file.
+ * Checks if an open file is a text file. Looks at the first 3 kilobytes
+ * to see if there is a null character. If so, assumes that the files is
+ * binary.
*/
static int
istextfile(FILE *f)
{
char buf[BUFSIZ];
- int cnt;
+ int cnt, check_size;
if (aflag || f == NULL)
return (1);
rewind(f);
fread(buf, 1, BUFSIZ, f);
- if (cnt = memchr(buf, '\0', BUFSIZ) != NULL) {
- printf("%d\n", cnt);
+ if (BUFSIZ >= MAX_CHECK)
+ check_size = MAX_CHECK;
+ else
+ check_size = BUFSIZ;
+ if (memchr(buf, '\0', check_size) != NULL) {
return (0);
}
return (1);
Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch Fri Jun 29 18:49:14 2012 (r238601)
+++ soc2012/jhagewood/diff/hagewood-diff.patch Fri Jun 29 19:29:20 2012 (r238602)
@@ -674,7 +674,7 @@
extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
diff -rupN jhagewood/diff/diff-orig/diffreg.c jhagewood/diff/diff/diffreg.c
--- jhagewood/diff/diff-orig/diffreg.c 2012-06-28 18:13:23.286983517 -0400
-+++ jhagewood/diff/diff/diffreg.c 2012-06-28 18:13:23.374983516 -0400
++++ jhagewood/diff/diff/diffreg.c 2012-06-29 15:23:03.842992142 -0400
@@ -62,15 +62,13 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
@@ -695,7 +695,7 @@
#include <sys/param.h>
#include <sys/stat.h>
-@@ -90,6 +88,12 @@ __FBSDID("$FreeBSD");
+@@ -90,6 +88,13 @@ __FBSDID("$FreeBSD");
#include "diff.h"
#include "pathnames.h"
@@ -705,10 +705,11 @@
+# define TIMESPEC_NS(timespec) 0
+#endif
+
++#define MAX_CHECK 768
/*
* diff - compare two files.
*/
-@@ -196,7 +200,7 @@ static void change(char *, FILE *, char
+@@ -196,7 +201,7 @@ static void change(char *, FILE *, char
static void sort(struct line *, int);
static void print_header(const char *, const char *);
static int ignoreline(char *);
@@ -717,7 +718,7 @@
static int fetch(long *, int, int, FILE *, int, int);
static int newcand(int, int, int);
static int search(int *, int, int);
-@@ -294,13 +298,13 @@ u_char cup2low[256] = {
+@@ -294,13 +299,13 @@ u_char cup2low[256] = {
int
diffreg(char *ofile1, char *ofile2, int flags)
{
@@ -738,7 +739,7 @@
anychange = 0;
lastline = 0;
-@@ -353,7 +357,6 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -353,7 +358,6 @@ diffreg(char *ofile1, char *ofile2, int
status |= 2;
goto closem;
}
@@ -746,7 +747,7 @@
switch (files_differ(f1, f2, flags)) {
case 0:
goto closem;
-@@ -365,7 +368,7 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -365,7 +369,7 @@ diffreg(char *ofile1, char *ofile2, int
goto closem;
}
@@ -755,7 +756,7 @@
rval = D_BINARY;
status |= 1;
goto closem;
-@@ -477,8 +480,8 @@ closem:
+@@ -477,8 +481,8 @@ closem:
static int
files_differ(FILE *f1, FILE *f2, int flags)
{
@@ -766,7 +767,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 +506,9 @@ files_differ(FILE *f1, FILE *f2, int fla
+@@ -503,9 +507,9 @@ files_differ(FILE *f1, FILE *f2, int fla
static FILE *
opentemp(const char *file)
{
@@ -779,7 +780,7 @@
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
-@@ -541,7 +544,7 @@ opentemp(const char *file)
+@@ -541,7 +545,7 @@ opentemp(const char *file)
char *
splice(char *dir, char *file)
{
@@ -788,7 +789,7 @@
if ((tail = strrchr(file, '/')) == NULL)
tail = file;
-@@ -555,8 +558,8 @@ static void
+@@ -555,8 +559,8 @@ static void
prepare(int i, FILE *fd, off_t filesize)
{
struct line *p;
@@ -799,7 +800,7 @@
rewind(fd);
-@@ -579,7 +582,7 @@ prepare(int i, FILE *fd, off_t filesize)
+@@ -579,7 +583,7 @@ prepare(int i, FILE *fd, off_t filesize)
static void
prune(void)
{
@@ -808,7 +809,7 @@
for (pref = 0; pref < len[0] && pref < len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
-@@ -600,7 +603,7 @@ prune(void)
+@@ -600,7 +604,7 @@ prune(void)
static void
equiv(struct line *a, int n, struct line *b, int m, int *c)
{
@@ -817,7 +818,7 @@
i = j = 1;
while (i <= n && j <= m) {
-@@ -629,7 +632,7 @@ equiv(struct line *a, int n, struct line
+@@ -629,7 +633,7 @@ equiv(struct line *a, int n, struct line
static int
isqrt(int n)
{
@@ -826,7 +827,7 @@
if (n == 0)
return (0);
-@@ -647,9 +650,9 @@ isqrt(int n)
+@@ -647,9 +651,9 @@ isqrt(int n)
static int
stone(int *a, int n, int *b, int *c)
{
@@ -839,7 +840,7 @@
const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
k = 0;
-@@ -705,7 +708,7 @@ newcand(int x, int y, int pred)
+@@ -705,7 +709,7 @@ newcand(int x, int y, int pred)
static int
search(int *c, int k, int y)
{
@@ -848,7 +849,7 @@
if (clist[c[k]].y < y) /* quick look for typical case */
return (k + 1);
-@@ -730,7 +733,7 @@ static void
+@@ -730,7 +734,7 @@ static void
unravel(int p)
{
struct cand *q;
@@ -857,7 +858,7 @@
for (i = 0; i <= len[0]; i++)
J[i] = i <= pref ? i :
-@@ -748,9 +751,10 @@ unravel(int p)
+@@ -748,9 +752,10 @@ unravel(int p)
static void
check(char *file1, FILE *f1, char *file2, FILE *f2)
{
@@ -871,7 +872,7 @@
rewind(f1);
rewind(f2);
j = 1;
-@@ -766,7 +770,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -766,7 +771,7 @@ check(char *file1, FILE *f1, char *file2
ixnew[j] = ctnew += skipline(f2);
j++;
}
@@ -880,7 +881,7 @@
for (;;) {
c = getc(f1);
d = getc(f2);
-@@ -781,6 +785,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -781,6 +786,7 @@ check(char *file1, FILE *f1, char *file2
}
ctold++;
ctnew++;
@@ -888,7 +889,7 @@
if (bflag && isspace(c) && isspace(d)) {
do {
if (c == '\n')
-@@ -792,6 +797,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -792,6 +798,7 @@ check(char *file1, FILE *f1, char *file2
break;
ctnew++;
} while (isspace(d = getc(f2)));
@@ -896,7 +897,7 @@
} else if (wflag) {
while (isspace(c) && c != '\n') {
c = getc(f1);
-@@ -801,31 +807,62 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +808,62 @@ check(char *file1, FILE *f1, char *file2
d = getc(f2);
ctnew++;
}
@@ -974,7 +975,7 @@
if (chrtran[c] != chrtran[d]) {
jackpot++;
J[i] = 0;
-@@ -872,7 +909,7 @@ static void
+@@ -872,7 +910,7 @@ static void
sort(struct line *a, int n)
{
struct line *ai, *aim, w;
@@ -983,7 +984,7 @@
if (n == 0)
return;
-@@ -916,7 +953,7 @@ unsort(struct line *f, int l, int *b)
+@@ -916,7 +954,7 @@ unsort(struct line *f, int l, int *b)
static int
skipline(FILE *f)
{
@@ -992,7 +993,7 @@
for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
continue;
-@@ -926,7 +963,7 @@ skipline(FILE *f)
+@@ -926,7 +964,7 @@ skipline(FILE *f)
static void
output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
{
@@ -1001,7 +1002,7 @@
rewind(f1);
rewind(f2);
-@@ -965,7 +1002,7 @@ output(char *file1, FILE *f1, char *file
+@@ -965,7 +1003,7 @@ output(char *file1, FILE *f1, char *file
#define c i0
if ((c = getc(f1)) == EOF)
return;
@@ -1010,7 +1011,7 @@
}
#undef c
}
-@@ -980,6 +1017,7 @@ output(char *file1, FILE *f1, char *file
+@@ -980,6 +1018,7 @@ output(char *file1, FILE *f1, char *file
static void
range(int a, int b, char *separator)
{
@@ -1018,7 +1019,7 @@
printf("%d", a > b ? b : a);
if (a < b)
printf("%s%d", separator, b);
-@@ -988,6 +1026,7 @@ range(int a, int b, char *separator)
+@@ -988,6 +1027,7 @@ range(int a, int b, char *separator)
static void
uni_range(int a, int b)
{
@@ -1026,7 +1027,7 @@
if (a < b)
printf("%d,%d", a, b - a + 1);
else if (a == b)
-@@ -999,22 +1038,22 @@ uni_range(int a, int b)
+@@ -999,22 +1039,22 @@ uni_range(int a, int b)
static char *
preadline(int fd, size_t len, off_t off)
{
@@ -1053,7 +1054,7 @@
ret = regexec(&ignore_re, line, 0, NULL, 0);
free(line);
-@@ -1032,8 +1071,8 @@ static void
+@@ -1032,8 +1072,8 @@ static void
change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
int *pflags)
{
@@ -1064,7 +1065,7 @@
restart:
if (format != D_IFDEF && a > b && c > d)
-@@ -1113,15 +1152,15 @@ proceed:
+@@ -1113,15 +1153,15 @@ proceed:
case D_NORMAL:
case D_EDIT:
range(a, b, ",");
@@ -1084,7 +1085,7 @@
break;
case D_NREVERSE:
if (a > b)
-@@ -1137,7 +1176,7 @@ proceed:
+@@ -1137,7 +1177,7 @@ proceed:
if (format == D_NORMAL || format == D_IFDEF) {
fetch(ixold, a, b, f1, '<', 1);
if (a <= b && c <= d && format == D_NORMAL)
@@ -1093,7 +1094,7 @@
}
i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
if (i != 0 && format == D_EDIT) {
-@@ -1148,14 +1187,14 @@ proceed:
+@@ -1148,14 +1188,14 @@ proceed:
* it. We have to add a substitute command to change this
* back and restart where we left off.
*/
@@ -1110,7 +1111,7 @@
if (inifdef) {
printf("#endif /* %s */\n", ifdefname);
inifdef = 0;
-@@ -1165,8 +1204,8 @@ proceed:
+@@ -1165,8 +1205,8 @@ proceed:
static int
fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
{
@@ -1121,7 +1122,7 @@
/*
* When doing #ifdef's, copy down to current line
-@@ -1177,7 +1216,7 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1177,7 +1217,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++)
@@ -1130,7 +1131,7 @@
}
if (a > b)
return (0);
-@@ -1197,12 +1236,12 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1197,12 +1237,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') {
@@ -1146,7 +1147,7 @@
}
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
-@@ -1211,13 +1250,13 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1211,13 +1251,13 @@ fetch(long *f, int a, int b, FILE *lb, i
format == D_NREVERSE)
warnx("No newline at end of file");
else
@@ -1162,7 +1163,7 @@
} while (++col < newcol);
} else {
if (format == D_EDIT && j == 1 && c == '\n'
-@@ -1229,10 +1268,10 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1229,10 +1269,10 @@ fetch(long *f, int a, int b, FILE *lb, i
* giving the caller an offset
* from which to restart.
*/
@@ -1175,7 +1176,7 @@
col++;
}
}
-@@ -1246,8 +1285,8 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1246,8 +1286,8 @@ fetch(long *f, int a, int b, FILE *lb, i
static int
readhash(FILE *f)
{
@@ -1186,12 +1187,14 @@
sum = 1;
space = 0;
-@@ -1305,20 +1344,23 @@ readhash(FILE *f)
+@@ -1305,20 +1345,28 @@ readhash(FILE *f)
return (sum == 0 ? 1 : sum);
}
+/*
-+ * Checks if an open file is a text file.
++ * Checks if an open file is a text file. Looks at the first 3 kilobytes
++ * to see if there is a null character. If so, assumes that the files is
++ * binary.
+ */
static int
-asciifile(FILE *f)
@@ -1200,7 +1203,7 @@
- char buf[BUFSIZ];
- int i, cnt;
+ char buf[BUFSIZ];
-+ int cnt;
++ int cnt, check_size;
if (aflag || f == NULL)
return (1);
@@ -1211,14 +1214,17 @@
- if (!isprint(buf[i]) && !isspace(buf[i]))
- return (0);
+ fread(buf, 1, BUFSIZ, f);
-+ if (cnt = memchr(buf, '\0', BUFSIZ) != NULL) {
-+ printf("%d\n", cnt);
++ if (BUFSIZ >= MAX_CHECK)
++ check_size = MAX_CHECK;
++ else
++ check_size = BUFSIZ;
++ if (memchr(buf, '\0', check_size) != NULL) {
+ return (0);
+ }
return (1);
}
-@@ -1327,10 +1369,10 @@ asciifile(FILE *f)
+@@ -1327,10 +1375,10 @@ asciifile(FILE *f)
static char *
match_function(const long *f, int pos, FILE *file)
{
@@ -1233,7 +1239,7 @@
lastline = pos;
while (pos > last) {
-@@ -1342,7 +1384,6 @@ match_function(const long *f, int pos, F
+@@ -1342,7 +1390,6 @@ match_function(const long *f, int pos, F
if (nc > 0) {
buf[nc] = '\0';
buf[strcspn(buf, "\n")] = '\0';
@@ -1241,7 +1247,7 @@
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
if (begins_with(buf, "private:")) {
if (!state)
-@@ -1373,9 +1414,9 @@ static void
+@@ -1373,9 +1420,9 @@ static void
dump_context_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1254,7 +1260,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1390,8 +1431,8 @@ dump_context_vec(FILE *f1, FILE *f2)
+@@ -1390,8 +1437,8 @@ dump_context_vec(FILE *f1, FILE *f2)
if (pflag) {
f = match_function(ixold, lowa-1, f1);
if (f != NULL) {
@@ -1265,7 +1271,7 @@
}
}
printf("\n*** ");
-@@ -1478,9 +1519,9 @@ static void
+@@ -1478,9 +1525,9 @@ static void
dump_unified_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1278,7 +1284,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1491,19 +1532,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1491,19 +1538,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
lowc = MAX(1, cvp->c - context);
upd = MIN(len[1], context_vec_ptr->d + context);
@@ -1304,7 +1310,7 @@
/*
* Output changes in "unified" diff format--the old and new lines
-@@ -1551,16 +1592,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1551,16 +1598,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
static void
print_header(const char *file1, const char *file2)
{
More information about the svn-soc-all
mailing list