Port of OpenBSD's sdiff

Steven Kreuzer skreuzer at exit2shell.com
Tue Jun 26 21:26:33 UTC 2007


On Mon, Jun 25, 2007 at 11:42:23AM +0100, Robert Watson wrote:
> 
> On Sun, 24 Jun 2007, Gabor Kovesdan wrote:
> 
> >Robert Watson escribi?:
> >>On Sun, 24 Jun 2007, Stanislav Sedov wrote:
> >>>
> >>>Personally, I see no point in adding -- style options, since the entire 
> >>>our world build without them. GNU people can always install gnu- ports, 
> >>>we just should insure they're posix compatible.
> >>>
> >>>Furthermore, having -- and - style options in one world effectively 
> >>>broke BSD's perfect look and feel:-)
> >>
> >>On the other hand -- intentionally breaking scripts that have worked with 
> >>FreeBSD for years isn't exactly the best way to make end-users happy.
> >>
> >How you mean this? The current GNU textproc tools have those -- options. 
> >How would that break scripts, then?
> >
> >Personally, I don't need or insist on having -- style options, but 
> >currently we have those and people might have got used to them. If we 
> >change the available options by just changing to the BSD-licensed ones 
> >without a deeper look of their functionality, we might break POLA.
> >
> >Moreover, the BSD-licensed ones have some of those, too as I wrote before, 
> >thus we just need to document them in the accompanying manpages. It's 
> >strange, but the manpages don't cover the existing long options, maybe the 
> >OpenBSD people didn't want people to use them.
> 
> Ah, OK -- I read the e-mail as stating that the options didn't exit in the 
> OpenBSD tools, yet proposing moving to them, and hence was concerned about 
> compatibility with existing scripts.

My apologizes for not being clear. With the exception of --help 
and --version, all the GNU style options are available. (However, 
they are not documented in the man page). The original authors 
reason --help is not included is that it doesn't make sense to 
duplicate the man page in the code. I tend to agree with this.

I had a little time on my hands today so I sat down and compared 
the GNU options to the options avaialble in OpenBSD's version and 
they are compatible. However, I did notice that --ignore-case was  
missing, so I added that in. 

In addition, I got an email from a person asking to include '1' 
and '2' as alises for 'l' and 'r' when doing merges.

(See http://www.nabble.com/sdiff-UI-enhancement-t3877253.html for 
the reasoning behind it. Its quite interesting)

It was a very trivial change so I added it in.

Both changes I made are attached to this email as a patch.

Finally, as per Doug's request, I did some regression testing 
with mergemaster and did not run into any issues. Hopefully, if 
anyone is planning on running mergemaster in the future, please 
consider doing it with this version of sdiff and let me know if 
you encounter any problems.

Thanks.

-- 
Steven Kreuzer
http://www.exit2shell.com/~skreuzer
-------------- next part --------------
--- /usr/src/usr.bin/sdiff/sdiff.c	Sun Apr 22 06:52:20 2007
+++ sdiff.c	Thu Jun 21 10:52:52 2007
@@ -1,4 +1,5 @@
 /*	$OpenBSD: sdiff.c,v 1.20 2006/09/19 05:52:23 otto Exp $ */
+/*	$FreeBSD$ */
 
 /*
  * Written by Raymond Lai <ray at cyth.net>.
@@ -84,6 +85,7 @@
 	{ "expand-tabs",		no_argument,		NULL,	't' },
 	{ "ignore-all-space",		no_argument,		NULL,	'W' },
 	{ "width",			required_argument,	NULL,	'w' },
+	{ "ignore-case",		no_argument,		NULL,	'i' },
 	{ NULL,				0,			NULL,	 0  }
 };
 
@@ -435,6 +437,7 @@
 			break;
 
 		case 'l':
+		case '1':
 			/* Choose left column as-is. */
 			if (s1 != NULL)
 				fprintf(outfile, "%s\n", s1);
@@ -446,6 +449,7 @@
 			goto QUIT;
 
 		case 'r':
+		case '2':
 			/* Choose right column as-is. */
 			if (s2 != NULL)
 				fprintf(outfile, "%s\n", s2);
@@ -1018,8 +1022,8 @@
 	    "eb:\tedit both diffs concatenated\n"
 	    "el:\tedit left diff\n"
 	    "er:\tedit right diff\n"
-	    "l:\tchoose left diff\n"
-	    "r:\tchoose right diff\n"
+	    "l | 1:\tchoose left diff\n"
+	    "r | 2:\tchoose right diff\n"
 	    "s:\tsilent mode--don't print identical lines\n"
 	    "v:\tverbose mode--print identical lines\n"
 	    "q:\tquit");


More information about the freebsd-current mailing list