Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jun 2010 00:27:27 GMT
From:      Benjamin Fiedler <bfiedler@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 179375 for review
Message-ID:  <201006100027.o5A0RRDg075642@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@179375?ac=10

Change 179375 by bfiedler@freebsd-7803 on 2010/06/10 00:26:37

	Add y flag (presently just calls sdiff with the 2 file args). Something is strange with the argv pointer arithmetic..

Affected files ...

.. //depot/projects/soc2010/bsdtextproc/diff/diff.c#4 edit
.. //depot/projects/soc2010/bsdtextproc/diff/pathnames.h#2 edit

Differences ...

==== //depot/projects/soc2010/bsdtextproc/diff/diff.c#4 (text+ko) ====

@@ -43,9 +43,11 @@
 #include <unistd.h>
 
 #include "diff.h"
+#include "pathnames.h"
 
-int	 aflag, Bflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
+int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
 int	 sflag, tflag, Tflag, wflag;
+int	 Bflag, yflag;
 int	 format, context, status;
 char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
 struct stat stb1, stb2;
@@ -54,7 +56,7 @@
 
 int flag_opts = 0;
 
-#define	OPTIONS	"0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwX:x:"
+#define	OPTIONS	"0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwXy:x"
 
 char ignore_file_case = 0;
 
@@ -134,8 +136,7 @@
 	{ "ignore-all-space",		no_argument,		NULL,	'w' },
 	{ "exclude-from",		required_argument,	NULL,	'X' },
 	{ "exclude",			required_argument,	NULL,	'x' },
-/* XXX: UNIMPLEMENTED
-	{ "side-by-side",		no_argument,		NULL,	'y' }, */
+	{ "side-by-side",		no_argument,		NULL,	'y' }, 
 	{ NULL,				0,			NULL,	'\0'}
 };
 
@@ -162,8 +163,10 @@
 	char	*ep, **oargv;
 	long	 l;
 	int	 ch, lastch, gotstdin, prevoptind, newarg;
+	int	oargc;
 
 	oargv = argv;
+	oargc = argc;
 	gotstdin = 0;
 
 	lastch = '\0';
@@ -288,6 +291,9 @@
 		case 'x':
 			push_excludes(optarg);
 			break;
+		case 'y':
+			yflag = 1;
+			break;
 		case OPT_IGN_FN_CASE:
 			ignore_file_case = 1;
 			break;
@@ -312,6 +318,22 @@
 	argc -= optind;
 	argv += optind;
 
+	if(yflag) {
+		/* remove y flag from args and call sdiff */
+/*
+		for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++);
+		while(argv != oargv[oargc]){
+			*argv=*(argv+1)
+			argv++;
+		}
+		*argv= "\0";
+*/
+		set_argstr(oargv, argv);
+		char    *sdiff_argv[] = { "sdiff", argv[-1], argv[0], NULL };
+		execv(_PATH_SDIFF, sdiff_argv);
+		_exit(127);
+	}
+
 	/*
 	 * Do sanity checks, fill in stb1 and stb2 and call the appropriate
 	 * driver routine.  Both drivers use the contents of stb1 and stb2.

==== //depot/projects/soc2010/bsdtextproc/diff/pathnames.h#2 (text+ko) ====

@@ -23,3 +23,4 @@
 #include <paths.h>
 
 #define	_PATH_PR	"/usr/bin/pr"
+#define _PATH_SDIFF	"/usr/bin/sdiff"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006100027.o5A0RRDg075642>