From owner-svn-soc-all@FreeBSD.ORG Wed Jun 27 04:19:34 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 7E655106564A for ; Wed, 27 Jun 2012 04:19:32 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 27 Jun 2012 04:19:32 +0000 Date: Wed, 27 Jun 2012 04:19:32 +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: <20120627041932.7E655106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r238371 - 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: Wed, 27 Jun 2012 04:19:34 -0000 Author: jhagewood Date: Wed Jun 27 04:19:31 2012 New Revision: 238371 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238371 Log: Modified: soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/hagewood-diff.patch Modified: soc2012/jhagewood/diff/diff/diff.c ============================================================================== --- soc2012/jhagewood/diff/diff/diff.c Wed Jun 27 03:45:25 2012 (r238370) +++ soc2012/jhagewood/diff/diff/diff.c Wed Jun 27 04:19:31 2012 (r238371) @@ -165,8 +165,8 @@ char *ep, **oargv, *file1, *file2, *file3; long l; int ch, lastch, gotstdin, prevoptind, newarg; - int oargc; - pid_t childpid; + int oargc, childstat; + pid_t childpid, done; oargv = argv; oargc = argc; @@ -308,10 +308,10 @@ file3 = optarg; break; case OPT_TOFILE: + Fromflag = 1; file1 = argv[argc-2]; file2 = argv[argc-1]; file3 = optarg; - Fromflag = 1; break; case OPT_NEW_LF: case OPT_OLD_LF: @@ -378,7 +378,6 @@ exit(2); } childpid = fork(); - switch(childpid) if (childpid == 0) { if (Toflag) execl(_PATH_DIFF, _PATH_DIFF, file1, file3); @@ -387,16 +386,16 @@ exit(127); } if (childpid > 0) { - childpid = fork(); - if (childpid == 0) { - if (Toflag) - execl(_PATH_DIFF, _PATH_DIFF, file2, file3); - if (Fromflag) - execl(_PATH_DIFF, _PATH_DIFF, file3, file2); - exit(127); + while (true) { + 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 (childpid > 0) - exit(0); } } if (yflag) { Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Wed Jun 27 03:45:25 2012 (r238370) +++ soc2012/jhagewood/diff/hagewood-diff.patch Wed Jun 27 04:19:31 2012 (r238371) @@ -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-25 16:05:53.000000000 -0400 -+++ jhagewood/diff/diff/diff.c 2012-06-27 03:39:50.000000000 -0400 ++++ jhagewood/diff/diff/diff.c 2012-06-27 04:19:16.000000000 -0400 @@ -1,4 +1,4 @@ -/*- +/* @@ -192,8 +192,8 @@ + char *ep, **oargv, *file1, *file2, *file3; + long l; + int ch, lastch, gotstdin, prevoptind, newarg; -+ int oargc; -+ pid_t childpid; ++ int oargc, childstat; ++ pid_t childpid, done; + oargv = argv; oargc = argc; @@ -227,10 +227,10 @@ + file3 = optarg; + break; + case OPT_TOFILE: ++ Fromflag = 1; + file1 = argv[argc-2]; + file2 = argv[argc-1]; + file3 = optarg; -+ Fromflag = 1; + break; + case OPT_NEW_LF: + case OPT_OLD_LF: @@ -269,7 +269,7 @@ case OPT_STRIPCR: strip_cr=1; break; -@@ -328,20 +362,52 @@ main(int argc, char **argv) +@@ -328,20 +362,51 @@ main(int argc, char **argv) lastch = ch; newarg = optind != prevoptind; prevoptind = optind; @@ -291,7 +291,6 @@ + exit(2); + } + childpid = fork(); -+ switch(childpid) + if (childpid == 0) { + if (Toflag) + execl(_PATH_DIFF, _PATH_DIFF, file1, file3); @@ -300,16 +299,16 @@ + exit(127); + } + if (childpid > 0) { -+ childpid = fork(); -+ if (childpid == 0) { -+ if (Toflag) -+ execl(_PATH_DIFF, _PATH_DIFF, file2, file3); -+ if (Fromflag) -+ execl(_PATH_DIFF, _PATH_DIFF, file3, file2); -+ exit(127); ++ while (true) { ++ 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 (childpid > 0) -+ exit(0); + } + } + if (yflag) { @@ -327,7 +326,7 @@ execv(_PATH_SDIFF, oargv); _exit(127); } -@@ -380,7 +446,10 @@ main(int argc, char **argv) +@@ -380,7 +445,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) @@ -339,7 +338,7 @@ diffdir(argv[0], argv[1]); } else { if (S_ISDIR(stb1.st_mode)) { -@@ -402,11 +471,10 @@ main(int argc, char **argv) +@@ -402,11 +470,10 @@ main(int argc, char **argv) void * emalloc(size_t n) { @@ -352,7 +351,7 @@ if ((p = malloc(n)) == NULL) errx(2, NULL); return (p); -@@ -415,7 +483,7 @@ emalloc(size_t n) +@@ -415,7 +482,7 @@ emalloc(size_t n) void * erealloc(void *p, size_t n) { @@ -361,7 +360,7 @@ if (n == 0) errx(2, NULL); -@@ -431,13 +499,12 @@ erealloc(void *p, size_t n) +@@ -431,13 +498,12 @@ erealloc(void *p, size_t n) int easprintf(char **ret, const char *fmt, ...) { @@ -377,7 +376,7 @@ if (len < 0 || *ret == NULL) errx(2, NULL); return (len); -@@ -446,11 +513,12 @@ easprintf(char **ret, const char *fmt, . +@@ -446,11 +512,12 @@ easprintf(char **ret, const char *fmt, . char * estrdup(const char *str) { @@ -392,7 +391,7 @@ strlcpy(cp, str, len); return (cp); } -@@ -531,6 +599,7 @@ push_ignore_pats(char *pattern) +@@ -531,6 +598,7 @@ push_ignore_pats(char *pattern) void print_only(const char *path, size_t dirlen, const char *entry) { @@ -400,7 +399,7 @@ if (dirlen > 1) dirlen--; printf("Only in %.*s: %s\n", (int)dirlen, path, entry); -@@ -539,45 +608,46 @@ print_only(const char *path, size_t dirl +@@ -539,45 +607,46 @@ print_only(const char *path, size_t dirl void print_status(int val, char *path1, char *path2, char *entry) { @@ -458,7 +457,7 @@ break; } } -@@ -585,6 +655,7 @@ print_status(int val, char *path1, char +@@ -585,6 +654,7 @@ print_status(int val, char *path1, char void usage(void) {