PERFORCE change 181625 for review

Benjamin Fiedler bfiedler at FreeBSD.org
Fri Jul 30 23:54:29 UTC 2010


http://p4web.freebsd.org/@@181625?ac=10

Change 181625 by bfiedler at freebsd-7803 on 2010/07/30 23:53:45

	Diff3 now compiles warning-free; iflag implemented

Affected files ...

.. //depot/projects/soc2010/bsdtextproc/diff3/diff3prog.c#2 edit

Differences ...

==== //depot/projects/soc2010/bsdtextproc/diff3/diff3prog.c#2 (text+ko) ====

@@ -64,11 +64,18 @@
  *	@(#)diff3.c	8.1 (Berkeley) 6/6/93
  */
 
+#ifdef __FreeBSD__
+#define __dead
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <err.h>
+#include <unistd.h>
+#include <limits.h>
+#include <getopt.h>
 
 /* diff3 - 3-way differential file comparison */
 
@@ -116,8 +123,9 @@
  * is stored in last[1-3];
  */
 int last[4];
-int eflag;
+int eflag, iflag;
 int oflag;		/* indicates whether to mark overlaps (-E or -X)*/
+int strip_cr;
 int debug  = 0;
 char f1mark[40], f3mark[40];	/* markers for -E and -X */
 
@@ -139,6 +147,32 @@
 void increase(void);
 __dead void usage(void);
 
+enum {  
+        HELP_OPT = CHAR_MAX + 1,
+        STRIPCR_OPT,
+	DIFFPROG_OPT,
+};
+
+#define OPTIONS "3aAeEiL:mTvxX"
+static struct option longopts[] = {
+        { "ed",    		no_argument,		NULL,   'e' },
+	{ "show-overlap", 	no_argument,		NULL,	'E' },
+	{ "overlap-only",	no_argument,		NULL,	'x' },
+
+	/* features to implement */
+	{ "show-all",		no_argument,		NULL,	'A' },
+	{ "easy-only", 		no_argument,		NULL,	'3' },
+	{ "merge",		no_argument,		NULL,	'm' },
+	{ "label",		required_argument,	NULL,	'L' },
+	{ "text",		no_argument,		NULL,	'a' },
+	{ "strip-trailing-cr",	no_argument,		NULL,	STRIPCR_OPT },
+	{ "initial-tab",	no_argument,		NULL,	'T' },
+	{ "diff-program",	required_argument,	NULL,	DIFFPROG_OPT },
+	{ "version",		no_argument,		NULL,	'v' },
+	{ "help",		no_argument,		NULL,	HELP_OPT }
+};
+
+
 int
 main(int argc, char **argv)
 {
@@ -146,7 +180,7 @@
 
 	eflag = 0;
 	oflag = 0;
-	while ((ch = getopt(argc, argv, "EeXx3")) != -1) {
+	while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) {
 		switch (ch) {
 		case 'E':
 			eflag = 3;
@@ -155,6 +189,9 @@
 		case 'e':
 			eflag = 3;
 			break;
+		case 'i':
+			iflag = 1;
+			break;
 		case 'X':
 			oflag = eflag = 1;
 			break;
@@ -164,6 +201,10 @@
 		case '3':
 			eflag = 2;
 			break;
+		case STRIPCR_OPT:
+			strip_cr = 1;
+			break;
+			
 		}
 	}
 	argc -= optind;
@@ -558,6 +599,10 @@
 			printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark);
 		}
 	}
+
+	if( iflag )
+		printf("w\nq\n");
+
 	exit(overlapcnt);
 }
 


More information about the p4-projects mailing list