socsvn commit: r238159 - in soc2012/jhagewood: diff diff/diff diff3
mdocml
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Fri Jun 22 21:29:22 UTC 2012
Author: jhagewood
Date: Fri Jun 22 21:29:19 2012
New Revision: 238159
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238159
Log:
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
soc2012/jhagewood/diff3/hagewood-diff3.patch
soc2012/jhagewood/mdocml/hagewood-mdocml-ns.patch
Modified: soc2012/jhagewood/diff/TODO
==============================================================================
--- soc2012/jhagewood/diff/TODO Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/TODO Fri Jun 22 21:29:19 2012 (r238159)
@@ -9,7 +9,7 @@
--normal COMPLETE Sets format to D_NORMAL in getopt_long().
--suppress-common-lines IN PROGRESS
--GTYPE-group-format INCOMPLETE
---line-format IN PROGRESS
+--line-format IN PROGRESS Added new-line-format, old-line-format, and unchanged-line-format for compatibility
--LTYPE-line-format INCOMPLETE
--from-file INCOMPLETE
--to-file INCOMPLETE
@@ -17,8 +17,18 @@
--speed-large-file INCOMPLETE
--ignore-tab-expansion IN PROGRESS Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?)
--width INCOMPLETE
+Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and functionality.
+
Notes:
-- When using large files as input, diff will only output "Files [file1] and [file2] differ."
+- When using text files with non-ascii characters, diff will interpret them as binary files and output "Files [file1] and [file2] differ."
+ Very important compatibility problem with GNU diff, which will diff files that aren't strictly ascii.
+ - Error is associated with asciifile() in diffreg.c
+ - FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character in a file is printable, only check
+ the first character.
+ IMO, This is a sufficient test to check if a file is binary or a text-file.
- With some files, modification times displayed in the timestamp for file1 are different than the time outputted by GNU diff.
+- The -ignore-*-* options need some work.
+
+
Modified: soc2012/jhagewood/diff/diff/diff.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diff.c Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/diff/diff.c Fri Jun 22 21:29:19 2012 (r238159)
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -43,13 +43,13 @@
#include "diff.h"
#include "pathnames.h"
-int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
-int sflag, tflag, Tflag, wflag;
-int Bflag, yflag;
-int strip_cr, tabsize = 8;
-char ignore_file_case = 0;
-int format, context, status;
-char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
+int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
+int sflag, tflag, Tflag, wflag;
+int Bflag, yflag;
+int strip_cr, suppress_cl, tabsize = 8;
+char ignore_file_case = 0;
+int format, context, status;
+char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
struct stat stb1, stb2;
struct excludes *excludes_list;
regex_t ignore_re;
@@ -77,6 +77,9 @@
OPT_HLINES,
OPT_LFILES,
OPT_HELP,
+ OPT_NEW_LF,
+ OPT_OLD_LF,
+ OPT_UNCHGD_LF,
};
@@ -112,8 +115,10 @@
/*{ "LTYPE-line-format", required_argument, NULL, OPT_LLF },*/
{ "minimal", no_argument, NULL, 'd' },
{ "new-file", no_argument, NULL, 'N' },
+ { "new-line-format", required_argument, NULL, OPT_NEW_LF},
{ "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE },
{ "normal", no_argument, NULL, OPT_NORMAL },
+ { "old-line-format", required_argument, NULL, OPT_OLD_LF},
{ "paginate", no_argument, NULL, 'l' },
{ "recursive", no_argument, NULL, 'r' },
{ "report-identical-files", no_argument, NULL, 's' },
@@ -128,6 +133,7 @@
{ "tabsize", optional_argument, NULL, OPT_TSIZE },
{ "text", no_argument, NULL, 'a' },
/*{ "to-file", required_argument, NULL, OPT_TOFILE },*/
+ { "unchanged-line-format", required_argument, NULL, OPT_UNCHGD_LF},
{ "unidirectional-new-file", no_argument, NULL, 'P' },
{ "unified", optional_argument, NULL, 'U' },
{ "version", no_argument, NULL, 'v' },
@@ -294,15 +300,19 @@
case 'y':
yflag = 1;
break;
+ case OPT_NEW_LF:
+ case OPT_OLD_LF:
+ case OPT_UNCHGD_LF:
case OPT_LF:
/* XXX To do: Complete --line-format. */
format = D_IFDEF;
+ ifdefname = optarg;
break;
case OPT_NORMAL:
format = D_NORMAL;
break;
case OPT_SUPCL:
- /* XXX To do: Complete --suppress-common-lines */
+ suppress_cl = 1;
break;
case OPT_TSIZE:
if (optarg != NULL) {
@@ -340,16 +350,15 @@
argc -= optind;
argv += optind;
- if(yflag) {
+ if (yflag) {
/* remove y flag from args and call sdiff */
- for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++);
+ for (argv = oargv; argv && strcmp(*argv, "-y") != 0; argv++);
while(argv != &oargv[oargc]){
- *argv=*(argv+1);
+ *argv= *(argv+1);
argv++;
}
oargv[0] = _PATH_SDIFF;
*argv= "\0";
-
execv(_PATH_SDIFF, oargv);
_exit(127);
}
@@ -388,7 +397,10 @@
set_argstr(oargv, argv);
if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
if (format == D_IFDEF)
- errx(2, "-D option not supported with directories");
+ if (ch == 'D')
+ errx(2, "-D option not supported with directories");
+ if (ch == OPT_LF)
+ errx(2, "--line-format option not supported with directories");
diffdir(argv[0], argv[1]);
} else {
if (S_ISDIR(stb1.st_mode)) {
Modified: soc2012/jhagewood/diff/diff/diff.h
==============================================================================
--- soc2012/jhagewood/diff/diff/diff.h Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/diff/diff.h Fri Jun 22 21:29:19 2012 (r238159)
@@ -77,7 +77,7 @@
extern int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
sflag, tflag, Tflag, wflag;
-extern int Bflag, strip_cr, tabsize;
+extern int Bflag, strip_cr, suppress_cl, tabsize;
extern int format, context, status;
extern char ignore_file_case;
extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/diff/diffreg.c Fri Jun 22 21:29:19 2012 (r238159)
@@ -200,7 +200,7 @@
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);
@@ -368,7 +368,7 @@
goto closem;
}
- if (!asciifile(f1) || !asciifile(f2)) {
+ if (!istextfile(f1) || !istextfile(f2)) {
rval = D_BINARY;
status |= 1;
goto closem;
@@ -751,7 +751,7 @@
static void
check(char *file1, FILE *f1, char *file2, FILE *f2)
{
- int i, j, jackpot, c, d, int spacecount;
+ int i, j, jackpot, c, d, spacecount;
long ctold, ctnew;
fpos_t position;
@@ -812,18 +812,16 @@
if (c == '\n' && d != '\n') {
do {
if (c == '\n') {
- ixold[i] = ctold;
- i++;
+ ctold++;
}
- } while ((c = getc(f1)) == '\n' && i <= len[0]);
+ } while ((c = getc(f1)) == '\n');
}
if (d == '\n' && c != '\n') {
do {
if (d == '\n') {
- ixnew[j] = ctnew;
- j++;
+ ctnew++;
}
- } while ((d = getc(f2)) == '\n' && j <= len[1]);
+ } while ((d = getc(f2)) == '\n');
}
break;
/* ignore-tab-expansion */
@@ -834,13 +832,13 @@
* Checks if file1 has 8 consecutive spaces, which is
* equal to 1 tab.
*/
- getpos(f1, &position);
+ fgetpos(f1, &position);
for (spacecount = 1; spacecount <= 8; spacecount++) {
c = getc(f1);
if (c != ' ')
break;
}
- setpos(f1, &position);
+ fsetpos(f1, &position);
while (c == ' ' && spacecount == 9) {
c = getc(f1);
ctold++;
@@ -851,13 +849,13 @@
* Checks if file2 has 8 consecutive spaces, which is
* equal to 1 tab.
*/
- getpos(f2, &position);
+ fgetpos(f2, &position);
for (spacecount = 1; spacecount <= 8; spacecount++) {
d = getc(f2);
if (d != ' ')
break;
}
- setpos(f2, &position);
+ fsetpos(f2, &position);
while (d == ' ' && spacecount == 9) {
d = getc(f2);
ctnew++;
@@ -1004,7 +1002,7 @@
#define c i0
if ((c = getc(f1)) == EOF)
return;
- putchar(c);
+ printf("%c", c);
}
#undef c
}
@@ -1154,15 +1152,15 @@
case D_NORMAL:
case D_EDIT:
range(a, b, ",");
- putchar(a > b ? 'a' : c > d ? 'd' : 'c');
+ printf("%c", (a > b ? 'a' : c > d ? 'd' : 'c'));
if (format == D_NORMAL)
range(c, d, ",");
- putchar('\n');
+ printf("%c", '\n');
break;
case D_REVERSE:
- putchar(a > b ? 'a' : c > d ? 'd' : 'c');
+ printf("%c", (a > b ? 'a' : c > d ? 'd' : 'c'));
range(a, b, " ");
- putchar('\n');
+ printf("%c", '\n');
break;
case D_NREVERSE:
if (a > b)
@@ -1178,7 +1176,7 @@
if (format == D_NORMAL || format == D_IFDEF) {
fetch(ixold, a, b, f1, '<', 1);
if (a <= b && c <= d && format == D_NORMAL)
- puts("---");
+ printf("---");
}
i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
if (i != 0 && format == D_EDIT) {
@@ -1189,14 +1187,14 @@
* it. We have to add a substitute command to change this
* back and restart where we left off.
*/
- puts(".");
+ printf(".");
printf("%ds/^\\.\\././\n", a);
a += i;
c += i;
goto restart;
}
if ((format == D_EDIT || format == D_REVERSE) && c <= d)
- puts(".");
+ printf(".");
if (inifdef) {
printf("#endif /* %s */\n", ifdefname);
inifdef = 0;
@@ -1218,7 +1216,7 @@
/* 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++)
- putchar(getc(lb));
+ printf("%c", getc(lb));
}
if (a > b)
return (0);
@@ -1238,12 +1236,12 @@
fseek(lb, f[i - 1], SEEK_SET);
nc = f[i] - f[i - 1];
if (format != D_IFDEF && ch != '\0') {
- putchar(ch);
+ printf("%c", ch);
if (Tflag && (format == D_NORMAL || format == D_CONTEXT
|| format == D_UNIFIED))
- putchar('\t');
+ printf("%c", '\t');
else if (format != D_UNIFIED)
- putchar(' ');
+ printf("%c", ' ');
}
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
@@ -1252,13 +1250,13 @@
format == D_NREVERSE)
warnx("No newline at end of file");
else
- puts("\n\\ No newline at end of file");
+ printf("\n\\ No newline at end of file");
return (0);
}
if (c == '\t' && tflag) {
newcol = ((col/tabsize)+1)*tabsize;
do {
- putchar(' ');
+ printf("%c", ' ');
} while (++col < newcol);
} else {
if (format == D_EDIT && j == 1 && c == '\n'
@@ -1270,10 +1268,10 @@
* giving the caller an offset
* from which to restart.
*/
- puts(".");
+ printf(".");
return (i - a + 1);
}
- putchar(c);
+ printf("%c", c);
col++;
}
}
@@ -1347,7 +1345,7 @@
}
static int
-asciifile(FILE *f)
+textfile(FILE *f)
{
char buf[BUFSIZ];
int i, cnt;
@@ -1356,9 +1354,8 @@
return (1);
rewind(f);
cnt = fread(buf, 1, sizeof(buf), f);
- for (i = 0; i < cnt; i++)
- if (!isprint(buf[i]) && !isspace(buf[i]))
- return (0);
+ if (!isprint(buf[0]) && !isspace(buf[1]))
+ return (0);
return (1);
}
@@ -1429,8 +1426,8 @@
if (pflag) {
f = match_function(ixold, lowa-1, f1);
if (f != NULL) {
- putchar(' ');
- fputs(f, stdout);
+ printf("%c", ' ');
+ printf("%s", f);
}
}
printf("\n*** ");
@@ -1530,19 +1527,19 @@
lowc = MAX(1, cvp->c - context);
upd = MIN(len[1], context_vec_ptr->d + context);
- fputs("@@ -", stdout);
+ printf("@@ -");
uni_range(lowa, upb);
- fputs(" +", stdout);
+ printf(" +");
uni_range(lowc, upd);
- fputs(" @@", stdout);
+ printf(" @@");
if (pflag) {
f = match_function(ixold, lowa-1, f1);
if (f != NULL) {
- putchar(' ');
- fputs(f, stdout);
+ printf("%c", ' ');
+ printf("%s", f);
}
}
- putchar('\n');
+ printf("%c", '\n');
/*
* Output changes in "unified" diff format--the old and new lines
Modified: soc2012/jhagewood/diff/diff/pathnames.h
==============================================================================
--- soc2012/jhagewood/diff/diff/pathnames.h Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/diff/pathnames.h Fri Jun 22 21:29:19 2012 (r238159)
@@ -23,4 +23,4 @@
#include <paths.h>
#define _PATH_PR "/usr/bin/pr"
-#define _PATH_SDIFF "/usr/bin/sdiff
+#define _PATH_SDIFF "/usr/bin/sdiff"
Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch Fri Jun 22 20:42:11 2012 (r238158)
+++ soc2012/jhagewood/diff/hagewood-diff.patch Fri Jun 22 21:29:19 2012 (r238159)
@@ -1,6 +1,12 @@
diff -rupN jhagewood/diff/diff-orig/diff.c jhagewood/diff/diff/diff.c
---- jhagewood/diff/diff-orig/diff.c 2012-06-18 03:07:38.000000000 -0400
-+++ jhagewood/diff/diff/diff.c 2012-06-20 21:51:36.000000000 -0400
+--- jhagewood/diff/diff-orig/diff.c 2012-06-17 23:07:38.000000000 -0400
++++ jhagewood/diff/diff/diff.c 2012-06-22 17:14:38.000000000 -0400
+@@ -1,4 +1,4 @@
+-/*-
++/*
+ * Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
@@ -18,15 +18,13 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
@@ -21,20 +27,27 @@
#include <sys/param.h>
#include <sys/stat.h>
-@@ -45,10 +43,10 @@ __FBSDID("$FreeBSD$");
+@@ -45,20 +43,20 @@ __FBSDID("$FreeBSD$");
#include "diff.h"
#include "pathnames.h"
-int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
-+int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
- int sflag, tflag, Tflag, wflag;
- int Bflag, yflag;
+-int sflag, tflag, Tflag, wflag;
+-int Bflag, yflag;
-int strip_cr, tabsize=8;
-+int strip_cr, tabsize = 8;
- char ignore_file_case = 0;
- int format, context, status;
- char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
-@@ -58,7 +56,7 @@ regex_t ignore_re;
+-char ignore_file_case = 0;
+-int format, context, status;
+-char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
++int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
++int sflag, tflag, Tflag, wflag;
++int Bflag, yflag;
++int strip_cr, suppress_cl, tabsize = 8;
++char ignore_file_case = 0;
++int format, context, status;
++char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
+ struct stat stb1, stb2;
+ struct excludes *excludes_list;
+ regex_t ignore_re;
int flag_opts = 0;
@@ -43,7 +56,7 @@
/* Options which exceed manageable alphanumeric assignments */
-@@ -69,12 +67,11 @@ enum
+@@ -69,75 +67,77 @@ enum
OPT_STRIPCR,
OPT_NORMAL,
OPT_LEFTC,
@@ -57,7 +70,12 @@
OPT_FFILE,
OPT_TOFILE,
OPT_HLINES,
-@@ -84,60 +81,57 @@ enum
+ OPT_LFILES,
+ OPT_HELP,
++ OPT_NEW_LF,
++ OPT_OLD_LF,
++ OPT_UNCHGD_LF,
+ };
static struct option longopts[] = {
@@ -126,8 +144,10 @@
- { "unidirectional-new-file", no_argument, NULL, 'P' },
- { "show-c-function", no_argument, NULL, 'p' },
- { "brief", no_argument, NULL, 'q' },
++ { "new-line-format", required_argument, NULL, OPT_NEW_LF},
+ { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE },
+ { "normal", no_argument, NULL, OPT_NORMAL },
++ { "old-line-format", required_argument, NULL, OPT_OLD_LF},
+ { "paginate", no_argument, NULL, 'l' },
{ "recursive", no_argument, NULL, 'r' },
- { "starting-file", required_argument, NULL, 'S' },
@@ -146,6 +166,7 @@
+ { "tabsize", optional_argument, NULL, OPT_TSIZE },
+ { "text", no_argument, NULL, 'a' },
+ /*{ "to-file", required_argument, NULL, OPT_TOFILE },*/
++ { "unchanged-line-format", required_argument, NULL, OPT_UNCHGD_LF},
+ { "unidirectional-new-file", no_argument, NULL, 'P' },
{ "unified", optional_argument, NULL, 'U' },
{ "version", no_argument, NULL, 'v' },
@@ -159,7 +180,7 @@
{ NULL, 0, NULL, '\0'}
};
-@@ -162,10 +156,10 @@ void read_excludes_file(char *);
+@@ -162,10 +162,10 @@ void read_excludes_file(char *);
int
main(int argc, char **argv)
{
@@ -174,7 +195,7 @@
oargv = argv;
oargc = argc;
-@@ -197,6 +191,7 @@ main(int argc, char **argv)
+@@ -197,6 +197,7 @@ main(int argc, char **argv)
break;
case 'C':
case 'c':
@@ -182,7 +203,7 @@
format = D_CONTEXT;
if (optarg != NULL) {
l = strtol(optarg, &ep, 10);
-@@ -213,6 +208,9 @@ main(int argc, char **argv)
+@@ -213,6 +214,9 @@ main(int argc, char **argv)
case 'd':
dflag = 1;
break;
@@ -192,19 +213,23 @@
case 'e':
format = D_EDIT;
break;
-@@ -296,15 +294,25 @@ main(int argc, char **argv)
+@@ -296,15 +300,29 @@ main(int argc, char **argv)
case 'y':
yflag = 1;
break;
++ case OPT_NEW_LF:
++ case OPT_OLD_LF:
++ case OPT_UNCHGD_LF:
+ case OPT_LF:
+ /* XXX To do: Complete --line-format. */
+ format = D_IFDEF;
++ ifdefname = optarg;
+ break;
+ case OPT_NORMAL:
+ format = D_NORMAL;
+ break;
+ case OPT_SUPCL:
-+ /* XXX To do: Complete --suppress-common-lines */
++ suppress_cl = 1;
+ break;
case OPT_TSIZE:
- if (optarg != NULL) {
@@ -226,7 +251,39 @@
case OPT_STRIPCR:
strip_cr=1;
break;
-@@ -402,11 +410,10 @@ main(int argc, char **argv)
+@@ -332,16 +350,15 @@ main(int argc, char **argv)
+ argc -= optind;
+ argv += optind;
+
+- if(yflag) {
++ if (yflag) {
+ /* remove y flag from args and call sdiff */
+- for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++);
++ for (argv = oargv; argv && strcmp(*argv, "-y") != 0; argv++);
+ while(argv != &oargv[oargc]){
+- *argv=*(argv+1);
++ *argv= *(argv+1);
+ argv++;
+ }
+ oargv[0] = _PATH_SDIFF;
+ *argv= "\0";
+-
+ execv(_PATH_SDIFF, oargv);
+ _exit(127);
+ }
+@@ -380,7 +397,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)
+- errx(2, "-D option not supported with directories");
++ if (ch == 'D')
++ errx(2, "-D option not supported with directories");
++ if (ch == OPT_LF)
++ errx(2, "--line-format option not supported with directories");
+ diffdir(argv[0], argv[1]);
+ } else {
+ if (S_ISDIR(stb1.st_mode)) {
+@@ -402,11 +422,10 @@ main(int argc, char **argv)
void *
emalloc(size_t n)
{
@@ -239,7 +296,7 @@
if ((p = malloc(n)) == NULL)
errx(2, NULL);
return (p);
-@@ -415,7 +422,7 @@ emalloc(size_t n)
+@@ -415,7 +434,7 @@ emalloc(size_t n)
void *
erealloc(void *p, size_t n)
{
@@ -248,7 +305,7 @@
if (n == 0)
errx(2, NULL);
-@@ -431,13 +438,12 @@ erealloc(void *p, size_t n)
+@@ -431,13 +450,12 @@ erealloc(void *p, size_t n)
int
easprintf(char **ret, const char *fmt, ...)
{
@@ -264,7 +321,7 @@
if (len < 0 || *ret == NULL)
errx(2, NULL);
return (len);
-@@ -446,11 +452,12 @@ easprintf(char **ret, const char *fmt, .
+@@ -446,11 +464,12 @@ easprintf(char **ret, const char *fmt, .
char *
estrdup(const char *str)
{
@@ -279,7 +336,7 @@
strlcpy(cp, str, len);
return (cp);
}
-@@ -531,6 +538,7 @@ push_ignore_pats(char *pattern)
+@@ -531,6 +550,7 @@ push_ignore_pats(char *pattern)
void
print_only(const char *path, size_t dirlen, const char *entry)
{
@@ -287,7 +344,7 @@
if (dirlen > 1)
dirlen--;
printf("Only in %.*s: %s\n", (int)dirlen, path, entry);
-@@ -539,45 +547,46 @@ print_only(const char *path, size_t dirl
+@@ -539,45 +559,46 @@ print_only(const char *path, size_t dirl
void
print_status(int val, char *path1, char *path2, char *entry)
{
@@ -345,7 +402,7 @@
break;
}
}
-@@ -585,6 +594,7 @@ print_status(int val, char *path1, char
+@@ -585,6 +606,7 @@ print_status(int val, char *path1, char
void
usage(void)
{
@@ -353,21 +410,9 @@
(void)fprintf(stderr,
"usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n"
" [-L label] file1 file2\n"
-diff -rupN jhagewood/diff/diff-orig/diff.h jhagewood/diff/diff/diff.h
---- jhagewood/diff/diff-orig/diff.h 2012-06-18 03:07:38.000000000 -0400
-+++ jhagewood/diff/diff/diff.h 2012-06-18 03:07:38.000000000 -0400
-@@ -75,7 +75,7 @@ struct excludes {
- struct excludes *next;
- };
-
--extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
-+extern int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
- sflag, tflag, Tflag, wflag;
- extern int Bflag, strip_cr, tabsize;
- extern int format, context, status;
diff -rupN jhagewood/diff/diff-orig/diffdir.c jhagewood/diff/diff/diffdir.c
---- jhagewood/diff/diff-orig/diffdir.c 2012-06-18 03:07:38.000000000 -0400
-+++ jhagewood/diff/diff/diffdir.c 2012-06-20 05:43:28.000000000 -0400
+--- jhagewood/diff/diff-orig/diffdir.c 2012-06-17 23:07:38.000000000 -0400
++++ jhagewood/diff/diff/diffdir.c 2012-06-20 01:43:28.000000000 -0400
@@ -20,14 +20,13 @@
#include <sys/cdefs.h>
@@ -475,9 +520,24 @@
strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1);
if (stat(path1, &stb1) != 0) {
+diff -rupN jhagewood/diff/diff-orig/diff.h jhagewood/diff/diff/diff.h
+--- jhagewood/diff/diff-orig/diff.h 2012-06-17 23:07:38.000000000 -0400
++++ jhagewood/diff/diff/diff.h 2012-06-22 14:44:50.000000000 -0400
+@@ -75,9 +75,9 @@ struct excludes {
+ struct excludes *next;
+ };
+
+-extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
++extern int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
+ sflag, tflag, Tflag, wflag;
+-extern int Bflag, strip_cr, tabsize;
++extern int Bflag, strip_cr, suppress_cl, tabsize;
+ extern int format, context, status;
+ extern char ignore_file_case;
+ 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-18 03:07:38.000000000 -0400
-+++ jhagewood/diff/diff/diffreg.c 2012-06-19 05:18:57.000000000 -0400
+--- jhagewood/diff/diff-orig/diffreg.c 2012-06-17 23:07:38.000000000 -0400
++++ jhagewood/diff/diff/diffreg.c 2012-06-22 17:05:42.000000000 -0400
@@ -62,15 +62,13 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
@@ -511,6 +571,15 @@
/*
* diff - compare two files.
*/
+@@ -196,7 +200,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 *);
+-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);
@@ -294,13 +298,13 @@ u_char cup2low[256] = {
int
diffreg(char *ofile1, char *ofile2, int flags)
@@ -532,7 +601,7 @@
anychange = 0;
lastline = 0;
-@@ -353,7 +357,6 @@ diffreg(char *ofile1, char *ofile2, int
+@@ -353,7 +357,6 @@ diffreg(char *ofile1, char *ofile2, int
status |= 2;
goto closem;
}
@@ -540,6 +609,15 @@
switch (files_differ(f1, f2, flags)) {
case 0:
goto closem;
+@@ -365,7 +368,7 @@ diffreg(char *ofile1, char *ofile2, int
+ goto closem;
+ }
+
+- if (!asciifile(f1) || !asciifile(f2)) {
++ if (!istextfile(f1) || !istextfile(f2)) {
+ rval = D_BINARY;
+ status |= 1;
+ goto closem;
@@ -477,8 +480,8 @@ closem:
static int
files_differ(FILE *f1, FILE *f2, int flags)
@@ -649,7 +727,7 @@
- int i, j, jackpot, c, d;
- long ctold, ctnew;
-
-+ int i, j, jackpot, c, d, int spacecount;
++ int i, j, jackpot, c, d, spacecount;
+ long ctold, ctnew;
+ fpos_t position;
+
@@ -681,7 +759,7 @@
} else if (wflag) {
while (isspace(c) && c != '\n') {
c = getc(f1);
-@@ -801,31 +807,64 @@ check(char *file1, FILE *f1, char *file2
+@@ -801,31 +807,62 @@ check(char *file1, FILE *f1, char *file2
d = getc(f2);
ctnew++;
}
@@ -693,22 +771,26 @@
+ if (c == '\n' && d != '\n') {
do {
if (c == '\n') {
- ixold[i] = ctold;
- i++;
+- ixold[i] = ctold;
+- i++;
++ ctold++;
}
-
- } while ((c = getc(f1)) == '\n' && i <= len[0]);
+- } while ((c = getc(f1)) == '\n' && i <= len[0]);
++ } while ((c = getc(f1)) == '\n');
}
-
- if( d == '\n' && c != '\n') {
+ if (d == '\n' && c != '\n') {
do {
if (d == '\n') {
- ixnew[j] = ctnew;
- j++;
+- ixnew[j] = ctnew;
+- j++;
++ ctnew++;
}
- } while ((d = getc(f2)) == '\n' && j <= len[1]);
+- } while ((d = getc(f2)) == '\n' && j <= len[1]);
-
++ } while ((d = getc(f2)) == '\n');
}
-
break;
@@ -721,13 +803,13 @@
+ * Checks if file1 has 8 consecutive spaces, which is
+ * equal to 1 tab.
+ */
-+ getpos(f1, &position);
++ fgetpos(f1, &position);
+ for (spacecount = 1; spacecount <= 8; spacecount++) {
+ c = getc(f1);
+ if (c != ' ')
+ break;
+ }
-+ setpos(f1, &position);
++ fsetpos(f1, &position);
+ while (c == ' ' && spacecount == 9) {
+ c = getc(f1);
+ ctold++;
@@ -738,13 +820,13 @@
+ * Checks if file2 has 8 consecutive spaces, which is
+ * equal to 1 tab.
+ */
-+ getpos(f2, &position);
++ fgetpos(f2, &position);
+ for (spacecount = 1; spacecount <= 8; spacecount++) {
+ d = getc(f2);
+ if (d != ' ')
+ break;
+ }
-+ setpos(f2, &position);
++ fsetpos(f2, &position);
+ while (d == ' ' && spacecount == 9) {
+ d = getc(f2);
+ ctnew++;
@@ -755,7 +837,7 @@
if (chrtran[c] != chrtran[d]) {
jackpot++;
J[i] = 0;
-@@ -872,7 +911,7 @@ static void
+@@ -872,7 +909,7 @@ static void
sort(struct line *a, int n)
{
struct line *ai, *aim, w;
@@ -764,7 +846,7 @@
if (n == 0)
return;
-@@ -916,7 +955,7 @@ unsort(struct line *f, int l, int *b)
+@@ -916,7 +953,7 @@ unsort(struct line *f, int l, int *b)
static int
skipline(FILE *f)
{
@@ -773,7 +855,7 @@
for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
continue;
-@@ -926,7 +965,7 @@ skipline(FILE *f)
+@@ -926,7 +963,7 @@ skipline(FILE *f)
static void
output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
{
@@ -782,7 +864,16 @@
rewind(f1);
rewind(f2);
-@@ -980,6 +1019,7 @@ output(char *file1, FILE *f1, char *file
+@@ -965,7 +1002,7 @@ output(char *file1, FILE *f1, char *file
+ #define c i0
+ if ((c = getc(f1)) == EOF)
+ return;
+- putchar(c);
++ printf("%c", c);
+ }
+ #undef c
+ }
+@@ -980,6 +1017,7 @@ output(char *file1, FILE *f1, char *file
static void
range(int a, int b, char *separator)
{
@@ -790,7 +881,7 @@
printf("%d", a > b ? b : a);
if (a < b)
printf("%s%d", separator, b);
-@@ -988,6 +1028,7 @@ range(int a, int b, char *separator)
+@@ -988,6 +1026,7 @@ range(int a, int b, char *separator)
static void
uni_range(int a, int b)
{
@@ -798,7 +889,7 @@
if (a < b)
printf("%d,%d", a, b - a + 1);
else if (a == b)
-@@ -999,8 +1040,8 @@ uni_range(int a, int b)
+@@ -999,8 +1038,8 @@ uni_range(int a, int b)
static char *
preadline(int fd, size_t len, off_t off)
{
@@ -809,7 +900,7 @@
line = emalloc(len + 1);
if ((nr = pread(fd, line, len, off)) < 0)
-@@ -1014,7 +1055,7 @@ preadline(int fd, size_t len, off_t off)
+@@ -1014,7 +1053,7 @@ preadline(int fd, size_t len, off_t off)
static int
ignoreline(char *line)
{
@@ -818,7 +909,7 @@
ret = regexec(&ignore_re, line, 0, NULL, 0);
free(line);
-@@ -1032,8 +1073,8 @@ static void
+@@ -1032,8 +1071,8 @@ static void
change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
int *pflags)
{
@@ -829,7 +920,53 @@
restart:
if (format != D_IFDEF && a > b && c > d)
-@@ -1165,8 +1206,8 @@ proceed:
+@@ -1113,15 +1152,15 @@ proceed:
+ case D_NORMAL:
+ case D_EDIT:
+ range(a, b, ",");
+- putchar(a > b ? 'a' : c > d ? 'd' : 'c');
++ printf("%c", (a > b ? 'a' : c > d ? 'd' : 'c'));
+ if (format == D_NORMAL)
+ range(c, d, ",");
+- putchar('\n');
++ printf("%c", '\n');
+ break;
+ case D_REVERSE:
+- putchar(a > b ? 'a' : c > d ? 'd' : 'c');
++ printf("%c", (a > b ? 'a' : c > d ? 'd' : 'c'));
+ range(a, b, " ");
+- putchar('\n');
++ printf("%c", '\n');
+ break;
+ case D_NREVERSE:
+ if (a > b)
+@@ -1137,7 +1176,7 @@ proceed:
+ if (format == D_NORMAL || format == D_IFDEF) {
+ fetch(ixold, a, b, f1, '<', 1);
+ if (a <= b && c <= d && format == D_NORMAL)
+- puts("---");
++ printf("---");
+ }
+ i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0);
+ if (i != 0 && format == D_EDIT) {
+@@ -1148,14 +1187,14 @@ proceed:
+ * it. We have to add a substitute command to change this
+ * back and restart where we left off.
+ */
+- puts(".");
++ printf(".");
+ printf("%ds/^\\.\\././\n", a);
+ a += i;
+ c += i;
+ goto restart;
+ }
+ if ((format == D_EDIT || format == D_REVERSE) && c <= d)
+- puts(".");
++ printf(".");
+ if (inifdef) {
+ printf("#endif /* %s */\n", ifdefname);
+ inifdef = 0;
+@@ -1165,8 +1204,8 @@ proceed:
static int
fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
{
@@ -840,7 +977,61 @@
/*
* When doing #ifdef's, copy down to current line
-@@ -1246,8 +1287,8 @@ fetch(long *f, int a, int b, FILE *lb, i
+@@ -1177,7 +1216,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++)
+- putchar(getc(lb));
++ printf("%c", getc(lb));
+ }
+ if (a > b)
+ return (0);
+@@ -1197,12 +1236,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') {
+- putchar(ch);
++ printf("%c", ch);
+ if (Tflag && (format == D_NORMAL || format == D_CONTEXT
+ || format == D_UNIFIED))
+- putchar('\t');
++ printf("%c", '\t');
+ else if (format != D_UNIFIED)
+- putchar(' ');
++ printf("%c", ' ');
+ }
+ 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
+ format == D_NREVERSE)
+ warnx("No newline at end of file");
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list