socsvn commit: r239479 - in soc2012/jhagewood: diff diff/diff sdiff
sdiff/sdiff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Mon Jul 16 19:24:30 UTC 2012
Author: jhagewood
Date: Mon Jul 16 19:24:27 2012
New Revision: 239479
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239479
Log:
Fixed some style issues in diff and sdiff
Modified:
soc2012/jhagewood/diff/diff/diff.c
soc2012/jhagewood/diff/diff/diffdir.c
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/diff.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diff.c Mon Jul 16 18:13:43 2012 (r239478)
+++ soc2012/jhagewood/diff/diff/diff.c Mon Jul 16 19:24:27 2012 (r239479)
@@ -194,13 +194,11 @@
};
char **help_strs = (char **)help_msg;
-void set_argstr(char **, char **);
-
-
-void usage(void);
-void push_excludes(char *);
-void push_ignore_pats(char *);
-void read_excludes_file(char *);
+static void set_argstr(char **, char **);
+static void usage(void);
+static void push_excludes(char *);
+static void push_ignore_pats(char *);
+static void read_excludes_file(char *);
int
main(int argc, char **argv)
@@ -423,7 +421,7 @@
oargv[0] = _PATH_SDIFF;
*argv= "\0";
execv(_PATH_SDIFF, oargv);
- _exit(127);
+ _exit(1);
}
/*
@@ -479,7 +477,7 @@
/* Checks if --to-file or --from-file are specified */
if (Toflag && Fromflag) {
(void)fprintf(stderr, "--from-file and --to-file both specified.\n");
- exit(2);
+ exit(1);
}
if (Toflag) {
print_status(diffreg(optfile, argv[0], 0), optfile, argv[0],
@@ -555,11 +553,11 @@
return (cp);
}
-void
+static void
set_argstr(char **av, char **ave)
{
- size_t argsize;
- char **ap;
+ size_t argsize;
+ char **ap;
argsize = 4 + *ave - *av + 1;
diffargs = emalloc(argsize);
@@ -575,12 +573,12 @@
/*
* Read in an excludes file and push each line.
*/
-void
+static void
read_excludes_file(char *file)
{
- FILE *fp;
- char *buf, *pattern;
- size_t len;
+ FILE *fp;
+ char *buf, *pattern;
+ size_t len;
if (strcmp(file, "-") == 0)
fp = stdin;
@@ -601,7 +599,7 @@
/*
* Push a pattern onto the excludes list.
*/
-void
+static void
push_excludes(char *pattern)
{
struct excludes *entry;
@@ -612,10 +610,10 @@
excludes_list = entry;
}
-void
+static void
push_ignore_pats(char *pattern)
{
- size_t len;
+ size_t len;
if (ignore_pats == NULL)
ignore_pats = estrdup(pattern);
@@ -684,7 +682,7 @@
}
}
-void
+static void
usage(void)
{
@@ -698,5 +696,5 @@
" [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n"
" diff [-v]\n");
- exit(2);
+ exit(1);
}
Modified: soc2012/jhagewood/diff/diff/diffdir.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffdir.c Mon Jul 16 18:13:43 2012 (r239478)
+++ soc2012/jhagewood/diff/diff/diffdir.c Mon Jul 16 19:24:27 2012 (r239479)
@@ -27,6 +27,7 @@
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/stat.h>
Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 16 18:13:43 2012 (r239478)
+++ soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 16 19:24:27 2012 (r239479)
@@ -94,7 +94,7 @@
# define TIMESPEC_NS(timespec) 0
#endif
-#define MAX_CHECK 768
+#define MAX_CHECK 768 /* 3 kilobytes of chars. */
/*
* diff - compare two files.
@@ -187,47 +187,47 @@
};
static FILE *opentemp(const char *);
-static void output(char *, FILE *, char *, FILE *, int);
-static void check(char *, FILE *, char *, FILE *);
-static void range(int, int, char *);
-static void uni_range(int, int);
-static void dump_context_vec(FILE *, FILE *);
-static void dump_unified_vec(FILE *, FILE *);
-static void prepare(int, FILE *, off_t);
-static void prune(void);
-static void equiv(struct line *, int, struct line *, int, int *);
-static void unravel(int);
-static void unsort(struct line *, int, int *);
-static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *);
-static void sort(struct line *, int);
-static void print_header(const char *, const char *);
-static int ignoreline(char *);
-static int istextfile(FILE *);
-static int fetch(long *, int, int, FILE *, int, int);
-static int newcand(int, int, int);
-static int search(int *, int, int);
-static int skipline(FILE *);
-static int isqrt(int);
-static int stone(int *, int, int *, int *);
-static int readhash(FILE *);
-static int files_differ(FILE *, FILE *, int);
+static void output(char *, FILE *, char *, FILE *, int);
+static void check(char *, FILE *, char *, FILE *);
+static void range(int, int, char *);
+static void uni_range(int, int);
+static void dump_context_vec(FILE *, FILE *);
+static void dump_unified_vec(FILE *, FILE *);
+static void prepare(int, FILE *, off_t);
+static void prune(void);
+static void equiv(struct line *, int, struct line *, int, int *);
+static void unravel(int);
+static void unsort(struct line *, int, int *);
+static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *);
+static void sort(struct line *, int);
+static void print_header(const char *, const char *);
+static int ignoreline(char *);
+static int istextfile(FILE *);
+static int fetch(long *, int, int, FILE *, int, int);
+static int newcand(int, int, int);
+static int search(int *, int, int);
+static int skipline(FILE *);
+static int isqrt(int);
+static int stone(int *, int, int *, int *);
+static int readhash(FILE *);
+static int files_differ(FILE *, FILE *, int);
static char *match_function(const long *, int, FILE *);
static char *preadline(int, size_t, off_t);
-static int *J; /* will be overlaid on class */
-static int *class; /* will be overlaid on file[0] */
-static int *klist; /* will be overlaid on file[0] after class */
-static int *member; /* will be overlaid on file[1] */
-static int clen;
-static int inifdef; /* whether or not we are in a #ifdef block */
-static int len[2];
-static int pref, suff; /* length of prefix and suffix */
-static int slen[2];
-static int anychange;
+static int *J; /* will be overlaid on class */
+static int *class; /* will be overlaid on file[0] */
+static int *klist; /* will be overlaid on file[0] after class */
+static int *member; /* will be overlaid on file[1] */
+static int clen;
+static int inifdef; /* whether or not we are in a #ifdef block */
+static int len[2];
+static int pref, suff; /* length of prefix and suffix */
+static int slen[2];
+static int anychange;
static long *ixnew; /* will be overlaid on file[1] */
static long *ixold; /* will be overlaid on klist */
static struct cand *clist; /* merely a free storage pot for candidates */
-static int clistlen; /* the length of clist */
+static int clistlen; /* the length of clist */
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;
@@ -316,7 +316,7 @@
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)
- goto closem;
+ goto CLOSEM;
if (flags & D_EMPTY1)
f1 = fopen(_PATH_DEVNULL, "r");
@@ -326,7 +326,7 @@
fstat(fileno(f1), &stb1) < 0) {
warn("%s", file1);
status |= 2;
- goto closem;
+ goto CLOSEM;
}
} else if (strcmp(file1, "-") == 0)
f1 = stdin;
@@ -336,7 +336,7 @@
if (f1 == NULL) {
warn("%s", file1);
status |= 2;
- goto closem;
+ goto CLOSEM;
}
if (flags & D_EMPTY2)
@@ -347,7 +347,7 @@
fstat(fileno(f2), &stb2) < 0) {
warn("%s", file2);
status |= 2;
- goto closem;
+ goto CLOSEM;
}
} else if (strcmp(file2, "-") == 0)
f2 = stdin;
@@ -357,23 +357,23 @@
if (f2 == NULL) {
warn("%s", file2);
status |= 2;
- goto closem;
+ goto CLOSEM;
}
switch (files_differ(f1, f2, flags)) {
case 0:
- goto closem;
+ goto CLOSEM;
case 1:
break;
default:
/* error */
status |= 2;
- goto closem;
+ goto CLOSEM;
}
if (!istextfile(f1) || !istextfile(f2)) {
rval = D_BINARY;
status |= 1;
- goto closem;
+ goto CLOSEM;
}
if (lflag) {
/* redirect stdout to pr */
@@ -457,7 +457,11 @@
}
waitpid(pid, &wstatus, 0);
}
-closem:
+
+ /*
+ * Closes and frees open files
+ */
+CLOSEM:
if (anychange) {
status |= 1;
if (rval == D_SAME)
@@ -1069,7 +1073,7 @@
static size_t max_context = 64;
int i;
-restart:
+RESTART:
if (format != D_IFDEF && a > b && c > d)
return;
if (ignore_pats != NULL) {
@@ -1084,7 +1088,7 @@
line = preadline(fileno(f1),
ixold[i] - ixold[i - 1], ixold[i - 1]);
if (!ignoreline(line))
- goto proceed;
+ goto PROCEED;
}
}
if (a > b || c <= d) { /* Changes and inserts. */
@@ -1092,12 +1096,12 @@
line = preadline(fileno(f2),
ixnew[i] - ixnew[i - 1], ixnew[i - 1]);
if (!ignoreline(line))
- goto proceed;
+ goto PROCEED;
}
}
return;
}
-proceed:
+PROCEED:
if (*pflags & D_HEADER) {
printf("%s %s %s\n", diffargs, file1, file2);
*pflags &= ~D_HEADER;
@@ -1186,7 +1190,7 @@
printf("%ds/^\\.\\././\n", a);
a += i;
c += i;
- goto restart;
+ goto RESTART;
}
if ((format == D_EDIT || format == D_REVERSE) && c <= d)
printf(".");
Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 16 18:13:43 2012 (r239478)
+++ soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 16 19:24:27 2012 (r239479)
@@ -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-07 19:37:17.000000000 -0400
-+++ jhagewood/diff/diff/diff.c 2012-07-07 19:37:18.000000000 -0400
+--- 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
@@ -1,4 +1,4 @@
-/*-
+/*
@@ -56,7 +56,7 @@
/* Options which exceed manageable alphanumeric assignments */
-@@ -69,84 +67,129 @@ enum
+@@ -69,107 +67,151 @@ enum
OPT_STRIPCR,
OPT_NORMAL,
OPT_LEFTC,
@@ -238,7 +238,20 @@
NULL,
};
char **help_strs = (char **)help_msg;
-@@ -162,14 +205,15 @@ void read_excludes_file(char *);
+
+-void set_argstr(char **, char **);
+-
+-
+-void usage(void);
+-void push_excludes(char *);
+-void push_ignore_pats(char *);
+-void read_excludes_file(char *);
++static void set_argstr(char **, char **);
++static void usage(void);
++static void push_excludes(char *);
++static void push_ignore_pats(char *);
++static void read_excludes_file(char *);
+
int
main(int argc, char **argv)
{
@@ -259,7 +272,7 @@
lastch = '\0';
prevoptind = 1;
-@@ -197,6 +241,7 @@ main(int argc, char **argv)
+@@ -197,6 +239,7 @@ main(int argc, char **argv)
break;
case 'C':
case 'c':
@@ -267,7 +280,7 @@
format = D_CONTEXT;
if (optarg != NULL) {
l = strtol(optarg, &ep, 10);
-@@ -213,6 +258,9 @@ main(int argc, char **argv)
+@@ -213,6 +256,9 @@ main(int argc, char **argv)
case 'd':
dflag = 1;
break;
@@ -277,7 +290,7 @@
case 'e':
format = D_EDIT;
break;
-@@ -284,7 +332,7 @@ main(int argc, char **argv)
+@@ -284,7 +330,7 @@ main(int argc, char **argv)
case 'v':
printf("FreeBSD diff 2.8.7\n");
exit(0);
@@ -286,7 +299,7 @@
wflag = 1;
break;
case 'X':
-@@ -296,15 +344,48 @@ main(int argc, char **argv)
+@@ -296,15 +342,48 @@ main(int argc, char **argv)
case 'y':
yflag = 1;
break;
@@ -343,7 +356,7 @@
case OPT_STRIPCR:
strip_cr=1;
break;
-@@ -315,11 +396,10 @@ main(int argc, char **argv)
+@@ -315,11 +394,10 @@ main(int argc, char **argv)
ignore_file_case = 0;
break;
case OPT_HELP:
@@ -357,7 +370,7 @@
break;
default:
usage();
-@@ -328,20 +408,20 @@ main(int argc, char **argv)
+@@ -328,22 +406,22 @@ main(int argc, char **argv)
lastch = ch;
newarg = optind != prevoptind;
prevoptind = optind;
@@ -381,9 +394,12 @@
*argv= "\0";
-
execv(_PATH_SDIFF, oargv);
- _exit(127);
+- _exit(127);
++ _exit(1);
}
-@@ -380,7 +460,10 @@ main(int argc, char **argv)
+
+ /*
+@@ -380,7 +458,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)
@@ -395,7 +411,7 @@
diffdir(argv[0], argv[1]);
} else {
if (S_ISDIR(stb1.st_mode)) {
-@@ -393,8 +476,26 @@ main(int argc, char **argv)
+@@ -393,8 +474,26 @@ main(int argc, char **argv)
if (stat(argv[1], &stb2) < 0)
err(2, "%s", argv[1]);
}
@@ -404,7 +420,7 @@
+ /* Checks if --to-file or --from-file are specified */
+ if (Toflag && Fromflag) {
+ (void)fprintf(stderr, "--from-file and --to-file both specified.\n");
-+ exit(2);
++ exit(1);
+ }
+ if (Toflag) {
+ print_status(diffreg(optfile, argv[0], 0), optfile, argv[0],
@@ -424,7 +440,7 @@
}
exit(status);
}
-@@ -402,11 +503,10 @@ main(int argc, char **argv)
+@@ -402,11 +501,10 @@ main(int argc, char **argv)
void *
emalloc(size_t n)
{
@@ -437,7 +453,7 @@
if ((p = malloc(n)) == NULL)
errx(2, NULL);
return (p);
-@@ -415,7 +515,7 @@ emalloc(size_t n)
+@@ -415,7 +513,7 @@ emalloc(size_t n)
void *
erealloc(void *p, size_t n)
{
@@ -446,7 +462,7 @@
if (n == 0)
errx(2, NULL);
-@@ -431,13 +531,12 @@ erealloc(void *p, size_t n)
+@@ -431,13 +529,12 @@ erealloc(void *p, size_t n)
int
easprintf(char **ret, const char *fmt, ...)
{
@@ -462,7 +478,7 @@
if (len < 0 || *ret == NULL)
errx(2, NULL);
return (len);
-@@ -446,11 +545,12 @@ easprintf(char **ret, const char *fmt, .
+@@ -446,20 +543,21 @@ easprintf(char **ret, const char *fmt, .
char *
estrdup(const char *str)
{
@@ -477,7 +493,58 @@
strlcpy(cp, str, len);
return (cp);
}
-@@ -531,6 +631,7 @@ push_ignore_pats(char *pattern)
+
+-void
++static void
+ set_argstr(char **av, char **ave)
+ {
+- size_t argsize;
+- char **ap;
++ size_t argsize;
++ char **ap;
+
+ argsize = 4 + *ave - *av + 1;
+ diffargs = emalloc(argsize);
+@@ -475,12 +573,12 @@ set_argstr(char **av, char **ave)
+ /*
+ * Read in an excludes file and push each line.
+ */
+-void
++static void
+ read_excludes_file(char *file)
+ {
+- FILE *fp;
+- char *buf, *pattern;
+- size_t len;
++ FILE *fp;
++ char *buf, *pattern;
++ size_t len;
+
+ if (strcmp(file, "-") == 0)
+ fp = stdin;
+@@ -501,7 +599,7 @@ read_excludes_file(char *file)
+ /*
+ * Push a pattern onto the excludes list.
+ */
+-void
++static void
+ push_excludes(char *pattern)
+ {
+ struct excludes *entry;
+@@ -512,10 +610,10 @@ push_excludes(char *pattern)
+ excludes_list = entry;
+ }
+
+-void
++static void
+ push_ignore_pats(char *pattern)
+ {
+- size_t len;
++ size_t len;
+
+ if (ignore_pats == NULL)
+ ignore_pats = estrdup(pattern);
+@@ -531,6 +629,7 @@ push_ignore_pats(char *pattern)
void
print_only(const char *path, size_t dirlen, const char *entry)
{
@@ -485,7 +552,7 @@
if (dirlen > 1)
dirlen--;
printf("Only in %.*s: %s\n", (int)dirlen, path, entry);
-@@ -539,45 +640,46 @@ print_only(const char *path, size_t dirl
+@@ -539,52 +638,54 @@ print_only(const char *path, size_t dirl
void
print_status(int val, char *path1, char *path2, char *entry)
{
@@ -543,17 +610,25 @@
break;
}
}
-@@ -585,6 +687,7 @@ print_status(int val, char *path1, char
- void
+
+-void
++static void
usage(void)
{
+
(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)
+ " [-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-07 19:37:17.000000000 -0400
-+++ jhagewood/diff/diff/diff.h 2012-07-07 19:37:18.000000000 -0400
+--- 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
@@ -48,6 +48,8 @@
#define D_NREVERSE 5 /* Reverse ed script with numbered
lines and no trailing . */
@@ -577,9 +652,9 @@
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-07 19:37:17.000000000 -0400
-+++ jhagewood/diff/diff/diffdir.c 2012-07-07 19:37:18.000000000 -0400
-@@ -20,14 +20,13 @@
+--- 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
+@@ -20,13 +20,13 @@
#include <sys/cdefs.h>
@@ -592,13 +667,12 @@
+static char sccsid[] = "@(#)diffdir.c 8.1 (Berkeley) 6/6/93";
#endif
#endif /* not lint */
--
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/stat.h>
-
-@@ -57,12 +56,12 @@ static void diffit(struct dirent *, char
+@@ -57,12 +57,12 @@ static void diffit(struct dirent *, char
void
diffdir(char *p1, char *p2)
{
@@ -617,7 +691,7 @@
dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1));
if (dirlen1 >= sizeof(path1) - 1) {
-@@ -169,17 +168,16 @@ diffdir(char *p1, char *p2)
+@@ -169,17 +169,16 @@ diffdir(char *p1, char *p2)
static struct dirent **
slurpdir(char *path, char **bufp, int enoentok)
{
@@ -641,7 +715,7 @@
if (!enoentok || errno != ENOENT) {
warn("%s", path);
return (NULL);
-@@ -191,19 +189,17 @@ slurpdir(char *path, char **bufp, int en
+@@ -191,19 +190,17 @@ slurpdir(char *path, char **bufp, int en
close(fd);
return (NULL);
}
@@ -666,7 +740,7 @@
}
nbytes = getdirentries(fd, ebuf, have, &base);
if (nbytes == -1) {
-@@ -255,8 +251,8 @@ slurpdir(char *path, char **bufp, int en
+@@ -255,8 +252,8 @@ slurpdir(char *path, char **bufp, int en
static int
dircompare(const void *vp1, const void *vp2)
{
@@ -677,7 +751,7 @@
return (strcmp(dp1->d_name, dp2->d_name));
}
-@@ -267,7 +263,7 @@ dircompare(const void *vp1, const void *
+@@ -267,7 +264,7 @@ dircompare(const void *vp1, const void *
static void
diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2)
{
@@ -687,8 +761,8 @@
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-07 19:37:17.000000000 -0400
-+++ jhagewood/diff/diff/diffreg.c 2012-07-07 19:37:18.000000000 -0400
+--- 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
@@ -62,15 +62,13 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
@@ -719,20 +793,94 @@
+# define TIMESPEC_NS(timespec) 0
+#endif
+
-+#define MAX_CHECK 768
++#define MAX_CHECK 768 /* 3 kilobytes of chars. */
+
/*
* diff - compare two files.
*/
-@@ -196,7 +202,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 *);
+@@ -181,47 +187,47 @@ struct context_vec {
+ };
+
+ static FILE *opentemp(const char *);
+-static void output(char *, FILE *, char *, FILE *, int);
+-static void check(char *, FILE *, char *, FILE *);
+-static void range(int, int, char *);
+-static void uni_range(int, int);
+-static void dump_context_vec(FILE *, FILE *);
+-static void dump_unified_vec(FILE *, FILE *);
+-static void prepare(int, FILE *, off_t);
+-static void prune(void);
+-static void equiv(struct line *, int, struct line *, int, int *);
+-static void unravel(int);
+-static void unsort(struct line *, int, int *);
+-static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *);
+-static void sort(struct line *, int);
+-static void print_header(const char *, const char *);
+-static int ignoreline(char *);
-static int asciifile(FILE *);
-+static int istextfile(FILE *);
- static int fetch(long *, int, int, FILE *, int, int);
- static int newcand(int, int, int);
- static int search(int *, int, int);
+-static int fetch(long *, int, int, FILE *, int, int);
+-static int newcand(int, int, int);
+-static int search(int *, int, int);
+-static int skipline(FILE *);
+-static int isqrt(int);
+-static int stone(int *, int, int *, int *);
+-static int readhash(FILE *);
+-static int files_differ(FILE *, FILE *, int);
++static void output(char *, FILE *, char *, FILE *, int);
++static void check(char *, FILE *, char *, FILE *);
++static void range(int, int, char *);
++static void uni_range(int, int);
++static void dump_context_vec(FILE *, FILE *);
++static void dump_unified_vec(FILE *, FILE *);
++static void prepare(int, FILE *, off_t);
++static void prune(void);
++static void equiv(struct line *, int, struct line *, int, int *);
++static void unravel(int);
++static void unsort(struct line *, int, int *);
++static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *);
++static void sort(struct line *, int);
++static void print_header(const char *, const char *);
++static int ignoreline(char *);
++static int istextfile(FILE *);
++static int fetch(long *, int, int, FILE *, int, int);
++static int newcand(int, int, int);
++static int search(int *, int, int);
++static int skipline(FILE *);
++static int isqrt(int);
++static int stone(int *, int, int *, int *);
++static int readhash(FILE *);
++static int files_differ(FILE *, FILE *, int);
+ static char *match_function(const long *, int, FILE *);
+ static char *preadline(int, size_t, off_t);
+
+-static int *J; /* will be overlaid on class */
+-static int *class; /* will be overlaid on file[0] */
+-static int *klist; /* will be overlaid on file[0] after class */
+-static int *member; /* will be overlaid on file[1] */
+-static int clen;
+-static int inifdef; /* whether or not we are in a #ifdef block */
+-static int len[2];
+-static int pref, suff; /* length of prefix and suffix */
+-static int slen[2];
+-static int anychange;
++static int *J; /* will be overlaid on class */
++static int *class; /* will be overlaid on file[0] */
++static int *klist; /* will be overlaid on file[0] after class */
++static int *member; /* will be overlaid on file[1] */
++static int clen;
++static int inifdef; /* whether or not we are in a #ifdef block */
++static int len[2];
++static int pref, suff; /* length of prefix and suffix */
++static int slen[2];
++static int anychange;
+ static long *ixnew; /* will be overlaid on file[1] */
+ static long *ixold; /* will be overlaid on klist */
+ static struct cand *clist; /* merely a free storage pot for candidates */
+-static int clistlen; /* the length of clist */
++static int clistlen; /* the length of clist */
+ 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] = {
int
diffreg(char *ofile1, char *ofile2, int flags)
@@ -754,24 +902,86 @@
anychange = 0;
lastline = 0;
-@@ -353,7 +359,6 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -310,7 +316,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)
+- goto closem;
++ goto CLOSEM;
+
+ if (flags & D_EMPTY1)
+ f1 = fopen(_PATH_DEVNULL, "r");
+@@ -320,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int
+ fstat(fileno(f1), &stb1) < 0) {
+ warn("%s", file1);
+ status |= 2;
+- goto closem;
++ goto CLOSEM;
+ }
+ } else if (strcmp(file1, "-") == 0)
+ f1 = stdin;
+@@ -330,7 +336,7 @@ diffreg(char *ofile1, char *ofile2, int
+ if (f1 == NULL) {
+ warn("%s", file1);
status |= 2;
- goto closem;
+- goto closem;
++ goto CLOSEM;
+ }
+
+ if (flags & D_EMPTY2)
+@@ -341,7 +347,7 @@ diffreg(char *ofile1, char *ofile2, int
+ fstat(fileno(f2), &stb2) < 0) {
+ warn("%s", file2);
+ status |= 2;
+- goto closem;
++ goto CLOSEM;
+ }
+ } else if (strcmp(file2, "-") == 0)
+ f2 = stdin;
+@@ -351,24 +357,23 @@ diffreg(char *ofile1, char *ofile2, int
+ if (f2 == NULL) {
+ warn("%s", file2);
+ status |= 2;
+- goto closem;
++ goto CLOSEM;
}
-
switch (files_differ(f1, f2, flags)) {
case 0:
- goto closem;
-@@ -365,7 +370,7 @@ diffreg(char *ofile1, char *ofile2, int
- goto closem;
+- goto closem;
++ goto CLOSEM;
+ case 1:
+ break;
+ default:
+ /* error */
+ status |= 2;
+- goto closem;
++ goto CLOSEM;
}
- if (!asciifile(f1) || !asciifile(f2)) {
+ if (!istextfile(f1) || !istextfile(f2)) {
rval = D_BINARY;
status |= 1;
- goto closem;
-@@ -477,8 +482,8 @@ closem:
+- goto closem;
++ goto CLOSEM;
+ }
+ if (lflag) {
+ /* redirect stdout to pr */
+@@ -452,7 +457,11 @@ diffreg(char *ofile1, char *ofile2, int
+ }
+ waitpid(pid, &wstatus, 0);
+ }
+-closem:
++
++ /*
++ * Closes and frees open files
++ */
++CLOSEM:
+ if (anychange) {
+ status |= 1;
+ if (rval == D_SAME)
+@@ -477,8 +486,8 @@ closem:
static int
files_differ(FILE *f1, FILE *f2, int flags)
{
@@ -782,7 +992,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 +508,9 @@ files_differ(FILE *f1, FILE *f2, int fla
+@@ -503,9 +512,9 @@ files_differ(FILE *f1, FILE *f2, int fla
static FILE *
opentemp(const char *file)
{
@@ -795,7 +1005,7 @@
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
-@@ -541,7 +546,7 @@ opentemp(const char *file)
+@@ -541,7 +550,7 @@ opentemp(const char *file)
char *
splice(char *dir, char *file)
{
@@ -804,7 +1014,7 @@
if ((tail = strrchr(file, '/')) == NULL)
tail = file;
-@@ -555,8 +560,8 @@ static void
+@@ -555,8 +564,8 @@ static void
prepare(int i, FILE *fd, off_t filesize)
{
struct line *p;
@@ -815,7 +1025,7 @@
rewind(fd);
-@@ -579,7 +584,7 @@ prepare(int i, FILE *fd, off_t filesize)
+@@ -579,7 +588,7 @@ prepare(int i, FILE *fd, off_t filesize)
static void
prune(void)
{
@@ -824,7 +1034,7 @@
for (pref = 0; pref < len[0] && pref < len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
-@@ -600,7 +605,7 @@ prune(void)
+@@ -600,7 +609,7 @@ prune(void)
static void
equiv(struct line *a, int n, struct line *b, int m, int *c)
{
@@ -833,7 +1043,7 @@
i = j = 1;
while (i <= n && j <= m) {
-@@ -629,7 +634,7 @@ equiv(struct line *a, int n, struct line
+@@ -629,7 +638,7 @@ equiv(struct line *a, int n, struct line
static int
isqrt(int n)
{
@@ -842,7 +1052,7 @@
if (n == 0)
return (0);
-@@ -647,9 +652,9 @@ isqrt(int n)
+@@ -647,9 +656,9 @@ isqrt(int n)
static int
stone(int *a, int n, int *b, int *c)
{
@@ -855,7 +1065,7 @@
const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
k = 0;
-@@ -705,7 +710,7 @@ newcand(int x, int y, int pred)
+@@ -705,7 +714,7 @@ newcand(int x, int y, int pred)
static int
search(int *c, int k, int y)
{
@@ -864,7 +1074,7 @@
if (clist[c[k]].y < y) /* quick look for typical case */
return (k + 1);
-@@ -730,7 +735,7 @@ static void
+@@ -730,7 +739,7 @@ static void
unravel(int p)
{
struct cand *q;
@@ -873,7 +1083,7 @@
for (i = 0; i <= len[0]; i++)
J[i] = i <= pref ? i :
-@@ -748,9 +753,10 @@ unravel(int p)
+@@ -748,9 +757,10 @@ unravel(int p)
static void
check(char *file1, FILE *f1, char *file2, FILE *f2)
{
@@ -887,7 +1097,7 @@
rewind(f1);
rewind(f2);
j = 1;
-@@ -766,7 +772,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -766,7 +776,7 @@ check(char *file1, FILE *f1, char *file2
ixnew[j] = ctnew += skipline(f2);
j++;
}
@@ -896,7 +1106,7 @@
for (;;) {
c = getc(f1);
d = getc(f2);
-@@ -781,6 +787,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -781,6 +791,7 @@ check(char *file1, FILE *f1, char *file2
}
ctold++;
ctnew++;
@@ -904,7 +1114,7 @@
if (bflag && isspace(c) && isspace(d)) {
do {
if (c == '\n')
-@@ -792,6 +799,7 @@ check(char *file1, FILE *f1, char *file2
+@@ -792,6 +803,7 @@ check(char *file1, FILE *f1, char *file2
break;
ctnew++;
} while (isspace(d = getc(f2)));
@@ -912,7 +1122,7 @@
} else if (wflag) {
while (isspace(c) && c != '\n') {
c = getc(f1);
-@@ -801,31 +809,55 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +813,55 @@ check(char *file1, FILE *f1, char *file2
d = getc(f2);
ctnew++;
}
@@ -989,7 +1199,7 @@
if (chrtran[c] != chrtran[d]) {
jackpot++;
J[i] = 0;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list