socsvn commit: r239053 - in soc2012/jhagewood/sdiff: . sdiff

jhagewood at FreeBSD.org jhagewood at FreeBSD.org
Fri Jul 6 18:09:44 UTC 2012


Author: jhagewood
Date: Fri Jul  6 18:09:42 2012
New Revision: 239053
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239053

Log:

Modified:
  soc2012/jhagewood/sdiff/TODO
  soc2012/jhagewood/sdiff/hagewood-sdiff.patch
  soc2012/jhagewood/sdiff/sdiff/sdiff.c

Modified: soc2012/jhagewood/sdiff/TODO
==============================================================================
--- soc2012/jhagewood/sdiff/TODO	Fri Jul  6 17:42:34 2012	(r239052)
+++ soc2012/jhagewood/sdiff/TODO	Fri Jul  6 18:09:42 2012	(r239053)
@@ -1,7 +1,7 @@
 Combine diff-spec args and pipe to diff 	INCOMPLETE
 Test script					COMPLETE
 Adapt code to FreeBSD style guidelines		INCOMPLETE
-Fix --width output indention			IN PROGRESS
+Fix --width output indention			COMPLETE
 --help						COMPLETE
 Add more information to man file.		INCOMPLETE
 
@@ -11,3 +11,16 @@
 	-FIX: In println(), change column width to width-1, take out 
 		extra space when it prints 'div' on no right column. 
 
+- diff-specific args:
+
+     -a      Treat file1 and file2 as text files.
+     -b      Ignore trailing blank spaces.
+     -d      Minimize diff size.
+     -I regexp
+             Ignore line changes matching regexp.  All lines in the change
+             must match regexp for the change to be ignored.
+	NOTE: Missing ')' on tests.
+
+     -i      Do a case-insensitive comparison.
+     -t      Expand tabs to spaces.
+     -W      Ignore all spaces (the -w flag is passed to diff(1)).

Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch
==============================================================================
--- soc2012/jhagewood/sdiff/hagewood-sdiff.patch	Fri Jul  6 17:42:34 2012	(r239052)
+++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch	Fri Jul  6 18:09:42 2012	(r239053)
@@ -12,16 +12,7 @@
  .Sh NAME
 diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c
 --- jhagewood/sdiff/sdiff-orig/sdiff.c	2012-07-02 15:05:58.000000000 -0400
-+++ jhagewood/sdiff/sdiff/sdiff.c	2012-07-05 19:48:01.000000000 -0400
-@@ -34,7 +34,7 @@
- #include "common.h"
- #include "extern.h"
- 
--#define WIDTH 130
-+#define WIDTH 128
- /*
-  * Each column must be at least one character wide, plus three
-  * characters between the columns (space, [<|>], space).
++++ jhagewood/sdiff/sdiff/sdiff.c	2012-07-06 17:59:33.000000000 -0400
 @@ -101,7 +101,8 @@ enum {
        HLINES_OPT,
        LFILES_OPT,
@@ -32,8 +23,22 @@
  /* pid from the diff parent (if applicable) */
        DIFF_PID,
        
-@@ -137,6 +138,25 @@ static struct option longopts[] = {
+@@ -113,7 +114,7 @@ static struct option longopts[] = {
+       { "left-column",                no_argument,            NULL,   LEFTC_OPT },
+       { "suppress-common-lines",      no_argument,            NULL,   's' },
+       { "width",                      required_argument,      NULL,   'w' },
+-      { "ignore-all-space",           no_argument,            NULL,   'W' },
++
+       { "output",			required_argument,	NULL,	'o' },
+       { "diff-program",               required_argument,      NULL,   DIFFPROG_OPT },
        
+@@ -134,9 +135,29 @@ static struct option longopts[] = {
+       { "ignore-case",                no_argument,            NULL,   'i' },
+       { "expand-tabs",                no_argument,            NULL,   't' },
+       { "speed-large-files",          no_argument,            NULL,   'H' },
+-      
++      { "ignore-all-space",           no_argument,            NULL,   'W' },   
++         
        { NULL,                         0,                      NULL,   '\0'}
  };
 +
@@ -58,7 +63,25 @@
  /*
   * Create temporary file if source_file is not a regular file.
   * Returns temporary file name if one was malloced, NULL if unnecessary.
-@@ -289,17 +309,17 @@ main(int argc, char **argv)
+@@ -247,9 +268,6 @@ main(int argc, char **argv)
+ 		case STRIPCR_OPT:
+ 		case TSIZE_OPT:
+ 		case 'S':
+-		case 'W':
+-			for(popt = longopts; ch != popt->val && popt->name != NULL; popt++);
+-			asprintf(&diffargv[diffargc++], "%s", popt->name );
+ 		break;
+ 		
+ 		/* combine no-arg single switches */
+@@ -261,6 +279,7 @@ main(int argc, char **argv)
+ 		case 'i':
+ 		case 't':
+ 		case 'H':
++		case 'W':
+ 			for(popt = longopts; ch != popt->val && popt->name != NULL; popt++);
+ 			diffargv[1]  = realloc( diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2 ); 
+ 			sprintf(diffargv[1], "%s%c", diffargv[1], ch);
+@@ -289,17 +308,17 @@ main(int argc, char **argv)
  			if (errstr)
  				errx(2, "width is %s: %s", errstr, optarg);
  			break;
@@ -80,7 +103,7 @@
  		default:
  			usage();
  			break;
-@@ -363,7 +383,7 @@ main(int argc, char **argv)
+@@ -363,11 +382,11 @@ main(int argc, char **argv)
  	diffargv[diffargc++] = NULL;
  
  	/* Subtract column divider and divide by two. */
@@ -89,7 +112,12 @@
  	/* Make sure line_width can fit in size_t. */
  	if (width > (SIZE_MAX - 3) / 2)
  		errx(2, "width is too large: %zu", width);
-@@ -383,7 +403,6 @@ main(int argc, char **argv)
+-	line_width = width * 2 + 3;
++	line_width = ((width + 3) * 2);
+ 
+ 	if( ppid == -1 )
+ 	{
+@@ -383,7 +402,6 @@ main(int argc, char **argv)
  				err(2, "child could not duplicate descriptor");
  			/* Free unused descriptor. */
  			close(fd[1]);
@@ -97,7 +125,7 @@
  			execvp(diffprog, diffargv);
  			err(2, "could not execute diff: %s", diffprog);
  			break;
-@@ -1117,10 +1136,8 @@ int_usage(void)
+@@ -1117,10 +1135,8 @@ int_usage(void)
  static void
  usage(void)
  {

Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c
==============================================================================
--- soc2012/jhagewood/sdiff/sdiff/sdiff.c	Fri Jul  6 17:42:34 2012	(r239052)
+++ soc2012/jhagewood/sdiff/sdiff/sdiff.c	Fri Jul  6 18:09:42 2012	(r239053)
@@ -34,7 +34,7 @@
 #include "common.h"
 #include "extern.h"
 
-#define WIDTH 128
+#define WIDTH 130
 /*
  * Each column must be at least one character wide, plus three
  * characters between the columns (space, [<|>], space).
@@ -114,7 +114,7 @@
       { "left-column",                no_argument,            NULL,   LEFTC_OPT },
       { "suppress-common-lines",      no_argument,            NULL,   's' },
       { "width",                      required_argument,      NULL,   'w' },
-      { "ignore-all-space",           no_argument,            NULL,   'W' },
+
       { "output",			required_argument,	NULL,	'o' },
       { "diff-program",               required_argument,      NULL,   DIFFPROG_OPT },
       
@@ -135,7 +135,8 @@
       { "ignore-case",                no_argument,            NULL,   'i' },
       { "expand-tabs",                no_argument,            NULL,   't' },
       { "speed-large-files",          no_argument,            NULL,   'H' },
-      
+      { "ignore-all-space",           no_argument,            NULL,   'W' },   
+         
       { NULL,                         0,                      NULL,   '\0'}
 };
 
@@ -267,9 +268,6 @@
 		case STRIPCR_OPT:
 		case TSIZE_OPT:
 		case 'S':
-		case 'W':
-			for(popt = longopts; ch != popt->val && popt->name != NULL; popt++);
-			asprintf(&diffargv[diffargc++], "%s", popt->name );
 		break;
 		
 		/* combine no-arg single switches */
@@ -281,6 +279,7 @@
 		case 'i':
 		case 't':
 		case 'H':
+		case 'W':
 			for(popt = longopts; ch != popt->val && popt->name != NULL; popt++);
 			diffargv[1]  = realloc( diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2 ); 
 			sprintf(diffargv[1], "%s%c", diffargv[1], ch);
@@ -387,7 +386,7 @@
 	/* Make sure line_width can fit in size_t. */
 	if (width > (SIZE_MAX - 3) / 2)
 		errx(2, "width is too large: %zu", width);
-	line_width = width * 2 + 3;
+	line_width = ((width + 3) * 2);
 
 	if( ppid == -1 )
 	{


More information about the svn-soc-all mailing list