From owner-svn-soc-all@FreeBSD.ORG Sat Jun 30 02:52:30 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9CC601065670 for ; Sat, 30 Jun 2012 02:52:28 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 30 Jun 2012 02:52:28 +0000 Date: Sat, 30 Jun 2012 02:52:28 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120630025228.9CC601065670@hub.freebsd.org> Cc: Subject: socsvn commit: r238621 - in soc2012/jhagewood/diff: . diff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jun 2012 02:52:30 -0000 Author: jhagewood Date: Sat Jun 30 02:52:27 2012 New Revision: 238621 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238621 Log: Modified: soc2012/jhagewood/diff/TODO soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/hagewood-diff.patch Modified: soc2012/jhagewood/diff/TODO ============================================================================== --- soc2012/jhagewood/diff/TODO Sat Jun 30 02:27:29 2012 (r238620) +++ soc2012/jhagewood/diff/TODO Sat Jun 30 02:52:27 2012 (r238621) @@ -11,8 +11,8 @@ --GTYPE-group-format IN PROGRESS Added options for various GTYPEs. --line-format IN PROGRESS Added new-line-format, old-line-format, and unchanged-line-format for compatibility --LTYPE-line-format INCOMPLETE ---from-file COMPLETE Calls exec1() twice with optarg as file input. BUG. ---to-file COMPLETE Calls exec1() twice with optarg as file input. BUG. +--from-file COMPLETE Checks for flag then calls diffreg() with input files diff'd against optarg. +--to-file COMPLETE Checks for flag then calls diffreg() with optarg diff'd against input files. --horizon-lines INCOMPLETE --speed-large-file INCOMPLETE --ignore-tab-expansion IN PROGRESS Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?) Modified: soc2012/jhagewood/diff/diff/diff.c ============================================================================== --- soc2012/jhagewood/diff/diff/diff.c Sat Jun 30 02:27:29 2012 (r238620) +++ soc2012/jhagewood/diff/diff/diff.c Sat Jun 30 02:52:27 2012 (r238621) @@ -204,7 +204,7 @@ int main(int argc, char **argv) { - char *ep, **oargv, *args, *file1, *file2, *file3; + char *ep, **oargv, *args, *optfile; long l; int ch, lastch, gotstdin, prevoptind, newarg; int oargc, childstat; @@ -345,15 +345,11 @@ break; case OPT_FFILE: Toflag = 1; - file1 = argv[argc-2]; - file2 = argv[argc-1]; - file3 = optarg; + optfile3 = optarg; break; case OPT_TOFILE: Fromflag = 1; - file1 = argv[argc-2]; - file2 = argv[argc-1]; - file3 = optarg; + optfile = optarg; break; case OPT_CHGD_GF: case OPT_NEW_GF: @@ -416,44 +412,6 @@ } argc -= optind; argv += optind; - - /* - * Execute --to-file or --from-file by forking and executing diff - * with new input files. - * XXX to do- pass arguements - */ - if (Toflag || Fromflag) { - if (Toflag && Fromflag) { - (void)fprintf(stderr, "--from-file and --to-file both specified.\n"); - exit(2); - } - while ((ch = getopt(argc, argv, OPTIONS)) != -1) - strcat(args, ch); - childpid = fork(); - if (childpid < 0) { - (void)fprintf(stderr, "Error forking process.\n"); - exit(2); - } - if (childpid == 0) { - if (Toflag) - execl(_PATH_DIFF, _PATH_DIFF, args, file1, file3); - if (Fromflag) - execl(_PATH_DIFF, _PATH_DIFF, args, file3, file1); - exit(127); - } - if (childpid > 0) { - while (1) { - done = wait(&childstat); - if (done == 0) { - if (Toflag) - execl(_PATH_DIFF, _PATH_DIFF, file2, file3); - if (Fromflag) - execl(_PATH_DIFF, _PATH_DIFF, file3, file2); - exit(127); - } - } - } - } if (yflag) { /* remove y flag from args and call sdiff */ for (argv = oargv; argv && strcmp(*argv, "-y") != 0 && @@ -518,8 +476,26 @@ if (stat(argv[1], &stb2) < 0) err(2, "%s", argv[1]); } - print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], - NULL); + /* 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); + } + if (Toflag) { + print_status(diffreg(argv[0], optfile, 0), argv[0], optfile, + NULL); + print_status(diffreg(argv[1], optfile, 0), argv[1], optfile, + NULL); + } + if (Fromflag) { + print_status(diffreg(optfile, argv[0], 0), optfile, argv[0] + NULL); + print_status(diffreg(optfile, argv[1], 0), optfile, argv[1], + NULL); + } + else + print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], + NULL); } exit(status); } Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Sat Jun 30 02:27:29 2012 (r238620) +++ soc2012/jhagewood/diff/hagewood-diff.patch Sat Jun 30 02:52:27 2012 (r238621) @@ -1,6 +1,6 @@ diff -rupN jhagewood/diff/diff-orig/diff.c jhagewood/diff/diff/diff.c --- jhagewood/diff/diff-orig/diff.c 2012-06-28 18:13:23.287983517 -0400 -+++ jhagewood/diff/diff/diff.c 2012-06-28 22:39:58.023958340 -0400 ++++ jhagewood/diff/diff/diff.c 2012-06-29 22:49:21.899973597 -0400 @@ -1,4 +1,4 @@ -/*- +/* @@ -246,7 +246,7 @@ - int ch, lastch, gotstdin, prevoptind, newarg; - int oargc; - -+ char *ep, **oargv, *args, *file1, *file2, *file3; ++ char *ep, **oargv, *args, *optfile; + long l; + int ch, lastch, gotstdin, prevoptind, newarg; + int oargc, childstat; @@ -273,21 +273,17 @@ case 'e': format = D_EDIT; break; -@@ -296,15 +343,52 @@ main(int argc, char **argv) +@@ -296,15 +343,48 @@ main(int argc, char **argv) case 'y': yflag = 1; break; + case OPT_FFILE: + Toflag = 1; -+ file1 = argv[argc-2]; -+ file2 = argv[argc-1]; -+ file3 = optarg; ++ optfile3 = optarg; + break; + case OPT_TOFILE: + Fromflag = 1; -+ file1 = argv[argc-2]; -+ file2 = argv[argc-1]; -+ file3 = optarg; ++ optfile = optarg; + break; + case OPT_CHGD_GF: + case OPT_NEW_GF: @@ -334,7 +330,7 @@ case OPT_STRIPCR: strip_cr=1; break; -@@ -328,20 +412,58 @@ main(int argc, char **argv) +@@ -328,20 +408,20 @@ main(int argc, char **argv) lastch = ch; newarg = optind != prevoptind; prevoptind = optind; @@ -344,44 +340,6 @@ argv += optind; - - if(yflag) { -+ -+ /* -+ * Execute --to-file or --from-file by forking and executing diff -+ * with new input files. -+ * XXX to do- pass arguements -+ */ -+ if (Toflag || Fromflag) { -+ if (Toflag && Fromflag) { -+ (void)fprintf(stderr, "--from-file and --to-file both specified.\n"); -+ exit(2); -+ } -+ while ((ch = getopt(argc, argv, OPTIONS)) != -1) -+ strcat(args, ch); -+ childpid = fork(); -+ if (childpid < 0) { -+ (void)fprintf(stderr, "Error forking process.\n"); -+ exit(2); -+ } -+ if (childpid == 0) { -+ if (Toflag) -+ execl(_PATH_DIFF, _PATH_DIFF, args, file1, file3); -+ if (Fromflag) -+ execl(_PATH_DIFF, _PATH_DIFF, args, file3, file1); -+ exit(127); -+ } -+ if (childpid > 0) { -+ while (1) { -+ done = wait(&childstat); -+ if (done == 0) { -+ if (Toflag) -+ execl(_PATH_DIFF, _PATH_DIFF, file2, file3); -+ if (Fromflag) -+ execl(_PATH_DIFF, _PATH_DIFF, file3, file2); -+ exit(127); -+ } -+ } -+ } -+ } + if (yflag) { /* remove y flag from args and call sdiff */ - for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++); @@ -398,7 +356,7 @@ execv(_PATH_SDIFF, oargv); _exit(127); } -@@ -380,7 +502,10 @@ main(int argc, char **argv) +@@ -380,7 +460,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) @@ -410,7 +368,36 @@ diffdir(argv[0], argv[1]); } else { if (S_ISDIR(stb1.st_mode)) { -@@ -402,11 +527,10 @@ main(int argc, char **argv) +@@ -393,8 +476,26 @@ main(int argc, char **argv) + if (stat(argv[1], &stb2) < 0) + err(2, "%s", argv[1]); + } +- print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], +- NULL); ++ /* 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); ++ } ++ if (Toflag) { ++ print_status(diffreg(argv[0], optfile, 0), argv[0], optfile, ++ NULL); ++ print_status(diffreg(argv[1], optfile, 0), argv[1], optfile, ++ NULL); ++ } ++ if (Fromflag) { ++ print_status(diffreg(optfile, argv[0], 0), optfile, argv[0] ++ NULL); ++ print_status(diffreg(optfile, argv[1], 0), optfile, argv[1], ++ NULL); ++ } ++ else ++ print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], ++ NULL); + } + exit(status); + } +@@ -402,11 +503,10 @@ main(int argc, char **argv) void * emalloc(size_t n) { @@ -423,7 +410,7 @@ if ((p = malloc(n)) == NULL) errx(2, NULL); return (p); -@@ -415,7 +539,7 @@ emalloc(size_t n) +@@ -415,7 +515,7 @@ emalloc(size_t n) void * erealloc(void *p, size_t n) { @@ -432,7 +419,7 @@ if (n == 0) errx(2, NULL); -@@ -431,13 +555,12 @@ erealloc(void *p, size_t n) +@@ -431,13 +531,12 @@ erealloc(void *p, size_t n) int easprintf(char **ret, const char *fmt, ...) { @@ -448,7 +435,7 @@ if (len < 0 || *ret == NULL) errx(2, NULL); return (len); -@@ -446,11 +569,12 @@ easprintf(char **ret, const char *fmt, . +@@ -446,11 +545,12 @@ easprintf(char **ret, const char *fmt, . char * estrdup(const char *str) { @@ -463,7 +450,7 @@ strlcpy(cp, str, len); return (cp); } -@@ -531,6 +655,7 @@ push_ignore_pats(char *pattern) +@@ -531,6 +631,7 @@ push_ignore_pats(char *pattern) void print_only(const char *path, size_t dirlen, const char *entry) { @@ -471,7 +458,7 @@ if (dirlen > 1) dirlen--; printf("Only in %.*s: %s\n", (int)dirlen, path, entry); -@@ -539,45 +664,46 @@ print_only(const char *path, size_t dirl +@@ -539,45 +640,46 @@ print_only(const char *path, size_t dirl void print_status(int val, char *path1, char *path2, char *entry) { @@ -529,7 +516,7 @@ break; } } -@@ -585,6 +711,7 @@ print_status(int val, char *path1, char +@@ -585,6 +687,7 @@ print_status(int val, char *path1, char void usage(void) {