socsvn commit: r238367 - in soc2012/jhagewood/diff: . diff

jhagewood at FreeBSD.org jhagewood at FreeBSD.org
Wed Jun 27 03:40:22 UTC 2012


Author: jhagewood
Date: Wed Jun 27 03:40:19 2012
New Revision: 238367
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238367

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:16:36 2012	(r238366)
+++ soc2012/jhagewood/diff/diff/diff.c	Wed Jun 27 03:40:19 2012	(r238367)
@@ -166,7 +166,8 @@
 	long l;
 	int ch, lastch, gotstdin, prevoptind, newarg;
 	int oargc;
-
+	pid_t childpid;
+	
 	oargv = argv;
 	oargc = argc;
 	gotstdin = 0;
@@ -366,22 +367,37 @@
 	argc -= optind;
 	argv += optind;
 	
-	/* XXX to do- pass arguements */
+	/* 
+	 * 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);
 		}
-		if (Toflag) {
-			execl(_PATH_DIFF, _PATH_DIFF, file1, file3);
-			execl(_PATH_DIFF, _PATH_DIFF, file2, file3);
+		childpid = fork();
+		switch(childpid)
+		if (childpid == 0) {
+			if (Toflag)
+				execl(_PATH_DIFF, _PATH_DIFF, file1, file3);
+			if (Fromflag)
+				execl(_PATH_DIFF, _PATH_DIFF, file3, file1);
 			exit(127);
 		}
-		if (Fromflag) {
-			execl(_PATH_DIFF, _PATH_DIFF, file3, file1);
-			execl(_PATH_DIFF, _PATH_DIFF, file3, file2);
-			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);
+			}
+			if (childpid > 0)
+				exit(0);
+		}	
 	}
 	if (yflag) {
 		/* remove y flag from args and call sdiff */

Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch	Wed Jun 27 03:16:36 2012	(r238366)
+++ soc2012/jhagewood/diff/hagewood-diff.patch	Wed Jun 27 03:40:19 2012	(r238367)
@@ -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:16:17.000000000 -0400
++++ jhagewood/diff/diff/diff.c	2012-06-27 03:39:50.000000000 -0400
 @@ -1,4 +1,4 @@
 -/*-
 +/*
@@ -180,7 +180,7 @@
  	{ NULL,				0,			NULL,	'\0'}
  };
  
-@@ -162,10 +162,10 @@ void read_excludes_file(char *);
+@@ -162,11 +162,12 @@ void read_excludes_file(char *);
  int
  main(int argc, char **argv)
  {
@@ -188,14 +188,17 @@
 -	long	 l;
 -	int	 ch, lastch, gotstdin, prevoptind, newarg;
 -	int	 oargc;
+-
 +	char *ep, **oargv, *file1, *file2, *file3;
 +	long l;
 +	int ch, lastch, gotstdin, prevoptind, newarg;
 +	int oargc;
- 
++	pid_t childpid;
++	
  	oargv = argv;
  	oargc = argc;
-@@ -197,6 +197,7 @@ main(int argc, char **argv)
+ 	gotstdin = 0;
+@@ -197,6 +198,7 @@ main(int argc, char **argv)
  			break;
  		case 'C':
  		case 'c':
@@ -203,7 +206,7 @@
  			format = D_CONTEXT;
  			if (optarg != NULL) {
  				l = strtol(optarg, &ep, 10);
-@@ -213,6 +214,9 @@ main(int argc, char **argv)
+@@ -213,6 +215,9 @@ main(int argc, char **argv)
  		case 'd':
  			dflag = 1;
  			break;
@@ -213,7 +216,7 @@
  		case 'e':
  			format = D_EDIT;
  			break;
-@@ -296,15 +300,44 @@ main(int argc, char **argv)
+@@ -296,15 +301,44 @@ main(int argc, char **argv)
  		case 'y':
  			yflag = 1;
  			break;
@@ -266,7 +269,7 @@
  		case OPT_STRIPCR:
  			strip_cr=1;
  			break;
-@@ -328,20 +361,37 @@ main(int argc, char **argv)
+@@ -328,20 +362,52 @@ main(int argc, char **argv)
  		lastch = ch;
  		newarg = optind != prevoptind;
  		prevoptind = optind;
@@ -277,22 +280,37 @@
 -
 -	if(yflag) {
 +	
-+	/* XXX to do- pass arguements */
++	/* 
++	 * 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);
 +		}
-+		if (Toflag) {
-+			execl(_PATH_DIFF, _PATH_DIFF, file1, file3);
-+			execl(_PATH_DIFF, _PATH_DIFF, file2, file3);
++		childpid = fork();
++		switch(childpid)
++		if (childpid == 0) {
++			if (Toflag)
++				execl(_PATH_DIFF, _PATH_DIFF, file1, file3);
++			if (Fromflag)
++				execl(_PATH_DIFF, _PATH_DIFF, file3, file1);
 +			exit(127);
 +		}
-+		if (Fromflag) {
-+			execl(_PATH_DIFF, _PATH_DIFF, file3, file1);
-+			execl(_PATH_DIFF, _PATH_DIFF, file3, file2);
-+			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);
++			}
++			if (childpid > 0)
++				exit(0);
++		}	
 +	}
 +	if (yflag) {
  		/* remove y flag from args and call sdiff */
@@ -309,7 +327,7 @@
  		execv(_PATH_SDIFF, oargv);
  		_exit(127);
  	}
-@@ -380,7 +430,10 @@ main(int argc, char **argv)
+@@ -380,7 +446,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)
@@ -321,7 +339,7 @@
  		diffdir(argv[0], argv[1]);
  	} else {
  		if (S_ISDIR(stb1.st_mode)) {
-@@ -402,11 +455,10 @@ main(int argc, char **argv)
+@@ -402,11 +471,10 @@ main(int argc, char **argv)
  void *
  emalloc(size_t n)
  {
@@ -334,7 +352,7 @@
  	if ((p = malloc(n)) == NULL)
  		errx(2, NULL);
  	return (p);
-@@ -415,7 +467,7 @@ emalloc(size_t n)
+@@ -415,7 +483,7 @@ emalloc(size_t n)
  void *
  erealloc(void *p, size_t n)
  {
@@ -343,7 +361,7 @@
  
  	if (n == 0)
  		errx(2, NULL);
-@@ -431,13 +483,12 @@ erealloc(void *p, size_t n)
+@@ -431,13 +499,12 @@ erealloc(void *p, size_t n)
  int
  easprintf(char **ret, const char *fmt, ...)
  {
@@ -359,7 +377,7 @@
  	if (len < 0 || *ret == NULL)
  		errx(2, NULL);
  	return (len);
-@@ -446,11 +497,12 @@ easprintf(char **ret, const char *fmt, .
+@@ -446,11 +513,12 @@ easprintf(char **ret, const char *fmt, .
  char *
  estrdup(const char *str)
  {
@@ -374,7 +392,7 @@
  	strlcpy(cp, str, len);
  	return (cp);
  }
-@@ -531,6 +583,7 @@ push_ignore_pats(char *pattern)
+@@ -531,6 +599,7 @@ push_ignore_pats(char *pattern)
  void
  print_only(const char *path, size_t dirlen, const char *entry)
  {
@@ -382,7 +400,7 @@
  	if (dirlen > 1)
  		dirlen--;
  	printf("Only in %.*s: %s\n", (int)dirlen, path, entry);
-@@ -539,45 +592,46 @@ print_only(const char *path, size_t dirl
+@@ -539,45 +608,46 @@ print_only(const char *path, size_t dirl
  void
  print_status(int val, char *path1, char *path2, char *entry)
  {
@@ -440,7 +458,7 @@
  		break;
  	}
  }
-@@ -585,6 +639,7 @@ print_status(int val, char *path1, char 
+@@ -585,6 +655,7 @@ print_status(int val, char *path1, char 
  void
  usage(void)
  {


More information about the svn-soc-all mailing list