Date: Thu, 14 Jun 2012 21:17:36 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r237728 - in soc2012/jhagewood/diff3: . diff3 Message-ID: <20120614211736.E2746106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhagewood Date: Thu Jun 14 21:17:35 2012 New Revision: 237728 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237728 Log: Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3prog.c Thu Jun 14 21:04:41 2012 (r237727) +++ soc2012/jhagewood/diff3/diff3/diff3prog.c Thu Jun 14 21:17:35 2012 (r237728) @@ -128,7 +128,7 @@ char *diff_prog = NULL; char *labels[3] = {NULL}; /* - * the latest known correspondence between line numbers of the 3 files + * The latest known correspondence between line numbers of the 3 files * is stored in last[1-3]; */ int last[4]; @@ -167,7 +167,7 @@ #define OPTIONS "3aAeEiL:mTvxX" static struct option longopts[] = { - { "ed", no_argument, NULL, 'e' }, + { "ed", no_argument, NULL, 'e' }, { "show-overlap", no_argument, NULL, 'E' }, { "overlap-only", no_argument, NULL, 'x' }, { "initial-tab", no_argument, NULL, 'T' }, @@ -186,7 +186,6 @@ }; - int main(int argc, char **argv) { @@ -247,16 +246,18 @@ argc -= optind; argv += optind; /* XXX - argc usage seems wrong here */ - if (argc < 5) { + if (argc < 5) usage(); - } if (oflag) { - (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", labels[0] - != NULL ? labels[0] : argc >= 6 ? argv[5] : argv[2]); - (void)snprintf(f2mark, sizeof(f2mark), "||||||| %s", labels[1] - != NULL ? labels[1] : argc >= 6 ? argv[4] : argv[3]); - (void)snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", labels[2] - != NULL ? labels[2] : argc >= 7 ? argv[6] : argv[4]); + (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", + labels[0] != NULL ? labels[0] : + argc >= 6 ? argv[5] : argv[2]); + (void)snprintf(f2mark, sizeof(f2mark), "||||||| %s", + labels[1] != NULL ? labels[1] : + argc >= 6 ? argv[4] : argv[3]); + (void)snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", + labels[2] != NULL ? labels[2] : + argc >= 7 ? argv[6] : argv[4]); } increase(); m = readin(argv[0], &d13); @@ -380,7 +381,7 @@ d2 = d23; j = 0; - if( (asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2]) ) == 0) { + if ((asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2])) == 0) { printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } @@ -524,7 +525,7 @@ } /* - * print the range of line numbers, rold.from thru rold.to, as n1,n2 or + * Print the range of line numbers, rold.from thru rold.to, as n1,n2 or * n1. */ static void @@ -740,18 +741,18 @@ help(void) { - printf("%s%s%s%s", - "\t-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE.\n", - "\t-A --show-all Output all changes, bracketing conflicts.\n", - "\t-x --overlap-only Output overlapping changes.\n", + printf("%s", + "\t-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE.\n" + "\t-A --show-all Output all changes, bracketing conflicts.\n" + "\t-x --overlap-only Output overlapping changes.\n" "\t-3 --easy-only Output unmerged nonoverlapping changes.\n\n"); - printf("%s%s%s%s", - "\t-m --merge Output merged file instead of ed script (default -A).\n", - "\t-L LABEL --label=LABEL Use LABEL instead of file name.\n", - "\t-a --text Treat all files as text.\n", + printf("%s", + "\t-m --merge Output merged file instead of ed script (default -A).\n" + "\t-L LABEL --label=LABEL Use LABEL instead of file name.\n" + "\t-a --text Treat all files as text.\n" "\t-T --initial-tab Make tabs line up by prepending a tab.\n\n"); - printf("%s%s", - "\t-v --version Output version info.\n", + printf("%s", + "\t-v --version Output version info.\n" "\t--help Output this help.\n\n"); } Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Thu Jun 14 21:04:41 2012 (r237727) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Thu Jun 14 21:17:35 2012 (r237728) @@ -11,7 +11,7 @@ .include <bsd.prog.mk> diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c --- jhagewood/diff3/diff3-orig/diff3prog.c 2012-06-14 05:32:21.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-06-14 21:04:21.000000000 -0400 ++++ jhagewood/diff3/diff3/diff3prog.c 2012-06-14 21:15:59.000000000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ @@ -24,7 +24,7 @@ #endif +#endif /* not lint */ +#include <sys/cdefs.h> -+__FBSDID("$FreeBSD: soc2012/jhagewood/diff3/diff3/diff3prog.c 237663 2012-06-14 06:11:59Z jhagewood $"); ++__FBSDID("$FreeBSD: soc2012/jhagewood/diff3/diff3/diff3prog.c 237727 2012-06-14 21:04:41Z jhagewood $"); +#include <ctype.h> +#include <err.h> @@ -43,7 +43,16 @@ #include <wchar.h> #include <wctype.h> -@@ -134,48 +138,52 @@ int strip_cr; +@@ -124,7 +128,7 @@ int cline[3]; /* # of the last-read lin + char *diff_prog = NULL; + char *labels[3] = {NULL}; + /* +- * the latest known correspondence between line numbers of the 3 files ++ * The latest known correspondence between line numbers of the 3 files + * is stored in last[1-3]; + */ + int last[4]; +@@ -134,29 +138,31 @@ int strip_cr; int debug = 0; char f1mark[40], f2mark[40], f3mark[40]; /* markers for -E and -X */ @@ -93,10 +102,7 @@ }; #define OPTIONS "3aAeEiL:mTvxX" - static struct option longopts[] = { -- { "ed", no_argument, NULL, 'e' }, -+ { "ed", no_argument, NULL, 'e' }, - { "show-overlap", no_argument, NULL, 'E' }, +@@ -166,19 +172,20 @@ static struct option longopts[] = { { "overlap-only", no_argument, NULL, 'x' }, { "initial-tab", no_argument, NULL, 'T' }, { "text", no_argument, NULL, 'a' }, @@ -114,12 +120,15 @@ { "diff-program", required_argument, NULL, DIFFPROG_OPT }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, HELP_OPT } -+ -+ - }; +-}; -@@ -216,12 +224,18 @@ main(int argc, char **argv) ++}; ++ + int + main(int argc, char **argv) + { +@@ -216,12 +223,18 @@ main(int argc, char **argv) case 'X': oflag = eflag = 1; break; @@ -138,31 +147,17 @@ case STRIPCR_OPT: strip_cr = 1; break; -@@ -233,27 +247,25 @@ main(int argc, char **argv) - argc -= optind; - argv += optind; +@@ -235,7 +248,6 @@ main(int argc, char **argv) /* XXX - argc usage seems wrong here */ -- if (argc < 5) -+ if (argc < 5) { + if (argc < 5) usage(); - -+ } if (oflag) { -- (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", -- labels[0] != NULL ? labels[0] : -- argc >= 6 ? argv[5] : argv[2]); -- (void)snprintf(f2mark, sizeof(f2mark), "||||||| %s", -- labels[1] != NULL ? labels[1] : -- argc >= 6 ? argv[4] : argv[3]); -- (void)snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", -- labels[2] != NULL ? labels[2] : -- argc >= 7 ? argv[6] : argv[4]); -+ (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", labels[0] -+ != NULL ? labels[0] : argc >= 6 ? argv[5] : argv[2]); -+ (void)snprintf(f2mark, sizeof(f2mark), "||||||| %s", labels[1] -+ != NULL ? labels[1] : argc >= 6 ? argv[4] : argv[3]); -+ (void)snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", labels[2] -+ != NULL ? labels[2] : argc >= 7 ? argv[6] : argv[4]); + (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", + labels[0] != NULL ? labels[0] : +@@ -247,13 +259,14 @@ main(int argc, char **argv) + labels[2] != NULL ? labels[2] : + argc >= 7 ? argv[6] : argv[4]); } - increase(); @@ -176,7 +171,7 @@ } merge(m, n); exit(EXIT_SUCCESS); -@@ -265,7 +277,7 @@ main(int argc, char **argv) +@@ -265,7 +278,7 @@ main(int argc, char **argv) * since the vector is processed in one sequential pass. * The vector could be optimized out of existence) */ @@ -185,7 +180,7 @@ readin(char *name, struct diff **dd) { int a, b, c, d, i; -@@ -307,17 +319,18 @@ readin(char *name, struct diff **dd) +@@ -307,17 +320,18 @@ readin(char *name, struct diff **dd) return (i); } @@ -206,7 +201,7 @@ getchange(FILE *b) { char *line; -@@ -329,7 +342,7 @@ getchange(FILE *b) +@@ -329,7 +343,7 @@ getchange(FILE *b) return (NULL); } @@ -215,7 +210,7 @@ getline(FILE *b, size_t *n) { char *cp; -@@ -357,7 +370,7 @@ getline(FILE *b, size_t *n) +@@ -357,7 +371,7 @@ getline(FILE *b, size_t *n) return (buf); } @@ -224,17 +219,17 @@ merge(int m1, int m2) { struct diff *d1, *d2, *d3; -@@ -367,8 +380,7 @@ merge(int m1, int m2) +@@ -367,8 +381,7 @@ merge(int m1, int m2) d2 = d23; j = 0; - if( (asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2]) ) == 0) - { -+ if( (asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2]) ) == 0) { ++ if ((asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2])) == 0) { printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } -@@ -466,29 +478,29 @@ merge(int m1, int m2) +@@ -466,29 +479,29 @@ merge(int m1, int m2) static int asciifile(FILE *f) { @@ -282,7 +277,7 @@ printf("====%s\n", s); } -@@ -497,9 +509,10 @@ separate(const char *s) +@@ -497,9 +510,10 @@ separate(const char *s) * It is to be printed only if it does not duplicate something to be * printed later. */ @@ -294,14 +289,14 @@ printf("%d:", i); last[i] = rold->to; prange(rold); -@@ -510,12 +523,14 @@ change(int i, struct range *rold, int du +@@ -510,12 +524,14 @@ change(int i, struct range *rold, int du (void)skip(i, rold->to, " "); } -/* - * print the range of line numbers, rold.from thru rold.to, as n1,n2 or n1 +/* -+ * print the range of line numbers, rold.from thru rold.to, as n1,n2 or ++ * Print the range of line numbers, rold.from thru rold.to, as n1,n2 or + * n1. */ -void @@ -312,7 +307,7 @@ if (rold->to <= rold->from) printf("%da\n", rold->from - 1); else { -@@ -531,7 +546,7 @@ prange(struct range *rold) +@@ -531,7 +547,7 @@ prange(struct range *rold) * and an artificial dummy difference (trange) must be ginned up to * correspond to the change reported in the other file. */ @@ -321,7 +316,7 @@ keep(int i, struct range *rnew) { int delta; -@@ -547,7 +562,7 @@ keep(int i, struct range *rnew) +@@ -547,7 +563,7 @@ keep(int i, struct range *rnew) * skip to just before line number from in file "i". If "pr" is non-NULL, * print all skipped stuff with string pr as a prefix. */ @@ -330,7 +325,7 @@ skip(int i, int from, char *pr) { size_t j, n; -@@ -558,7 +573,6 @@ skip(int i, int from, char *pr) +@@ -558,7 +574,6 @@ skip(int i, int from, char *pr) trouble(); if (pr != NULL) printf("%s%s", Tflag == 1? "\t" : pr, line); @@ -338,7 +333,7 @@ cline[i]++; } return ((int) n); -@@ -568,10 +582,10 @@ skip(int i, int from, char *pr) +@@ -568,10 +583,10 @@ skip(int i, int from, char *pr) * Return 1 or 0 according as the old range (in file 1) contains exactly * the same data as the new range (in file 2). */ @@ -351,7 +346,7 @@ int nchar; int nline; -@@ -597,7 +611,7 @@ duplicate(struct range *r1, struct range +@@ -597,7 +612,7 @@ duplicate(struct range *r1, struct range return (1); } @@ -360,7 +355,7 @@ repos(int nchar) { int i; -@@ -606,18 +620,43 @@ repos(int nchar) +@@ -606,18 +621,43 @@ repos(int nchar) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } @@ -406,7 +401,7 @@ if (((dup + 1) & eflag) == 0) return (j); j++; -@@ -632,10 +671,10 @@ edit(struct diff *diff, int dup, int j) +@@ -632,10 +672,10 @@ edit(struct diff *diff, int dup, int j) } /* regurgitate */ @@ -419,7 +414,7 @@ char block[BUFSIZ]; for (n = n; n > 0; n--) { -@@ -657,14 +696,13 @@ edscript(int n) +@@ -657,14 +697,13 @@ edscript(int n) printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); } } @@ -436,7 +431,7 @@ increase(void) { struct diff *p; -@@ -698,13 +736,29 @@ increase(void) +@@ -698,13 +737,29 @@ increase(void) szchanges = newsz; } @@ -444,18 +439,18 @@ +help(void) +{ + -+ printf("%s%s%s%s", -+ "\t-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE.\n", -+ "\t-A --show-all Output all changes, bracketing conflicts.\n", -+ "\t-x --overlap-only Output overlapping changes.\n", ++ printf("%s", ++ "\t-e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE.\n" ++ "\t-A --show-all Output all changes, bracketing conflicts.\n" ++ "\t-x --overlap-only Output overlapping changes.\n" + "\t-3 --easy-only Output unmerged nonoverlapping changes.\n\n"); -+ printf("%s%s%s%s", -+ "\t-m --merge Output merged file instead of ed script (default -A).\n", -+ "\t-L LABEL --label=LABEL Use LABEL instead of file name.\n", -+ "\t-a --text Treat all files as text.\n", ++ printf("%s", ++ "\t-m --merge Output merged file instead of ed script (default -A).\n" ++ "\t-L LABEL --label=LABEL Use LABEL instead of file name.\n" ++ "\t-a --text Treat all files as text.\n" + "\t-T --initial-tab Make tabs line up by prepending a tab.\n\n"); -+ printf("%s%s", -+ "\t-v --version Output version info.\n", ++ printf("%s", ++ "\t-v --version Output version info.\n" + "\t--help Output this help.\n\n"); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120614211736.E2746106566C>