socsvn commit: r239061 - in soc2012/jhagewood/sdiff: . sdiff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Sat Jul 7 01:08:00 UTC 2012
Author: jhagewood
Date: Sat Jul 7 01:07:58 2012
New Revision: 239061
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239061
Log:
Modified:
soc2012/jhagewood/sdiff/hagewood-sdiff.patch
soc2012/jhagewood/sdiff/sdiff/sdiff.c
Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch
==============================================================================
--- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Sat Jul 7 00:25:17 2012 (r239060)
+++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Sat Jul 7 01:07:58 2012 (r239061)
@@ -12,7 +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-06 17:59:33.000000000 -0400
++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-07 01:03:06.000000000 -0400
@@ -101,7 +101,8 @@ enum {
HLINES_OPT,
LFILES_OPT,
@@ -63,7 +63,14 @@
/*
* Create temporary file if source_file is not a regular file.
* Returns temporary file name if one was malloced, NULL if unnecessary.
-@@ -247,9 +268,6 @@ main(int argc, char **argv)
+@@ -240,18 +261,13 @@ main(int argc, char **argv)
+ const char *errstr;
+
+ switch (ch) {
+-
+ /* only compatible --long-name-form with diff */
+ case FCASE_IGNORE_OPT:
+ case FCASE_SENSITIVE_OPT:
case STRIPCR_OPT:
case TSIZE_OPT:
case 'S':
@@ -71,17 +78,25 @@
- 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 'a':
+ case 'B':
+@@ -261,11 +277,11 @@ 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 );
+- diffargv[1] = realloc( diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2 );
++ 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)
+ break;
+-
+ case DIFFPROG_OPT:
+ diffargv[0] = diffprog = optarg;
+ break;
+@@ -289,26 +305,23 @@ main(int argc, char **argv)
if (errstr)
errx(2, "width is %s: %s", errstr, optarg);
break;
@@ -103,11 +118,23 @@
default:
usage();
break;
-@@ -363,11 +382,11 @@ main(int argc, char **argv)
+ }
+-
+-
+-
+ }
+-
++
+ /* no single switches were used */
+ if( strcmp( diffargv[1], "-" ) == 0 )
+ {
+@@ -362,19 +375,19 @@ main(int argc, char **argv)
+ /* Add NULL to end of array to indicate end of array. */
diffargv[diffargc++] = NULL;
- /* Subtract column divider and divide by two. */
+- /* Subtract column divider and divide by two. */
- width = (wflag - 3) / 2;
++ /* Subtract column divider, divide by two, subtract 2. */
+ width = ((wflag - 3) / 2) - 2;
/* Make sure line_width can fit in size_t. */
if (width > (SIZE_MAX - 3) / 2)
@@ -115,9 +142,18 @@
- line_width = width * 2 + 3;
+ line_width = ((width + 3) * 2);
- if( ppid == -1 )
+- if( ppid == -1 )
++ if (ppid == -1 )
{
-@@ -383,7 +402,6 @@ main(int argc, char **argv)
+ if (pipe(fd))
+ err(2, "pipe");
+
+- switch(pid = fork()) {
++ switch (pid = fork()) {
+ case 0:
+ /* child */
+ /* We don't read from the pipe. */
+@@ -383,7 +396,6 @@ main(int argc, char **argv)
err(2, "child could not duplicate descriptor");
/* Free unused descriptor. */
close(fd[1]);
@@ -125,7 +161,42 @@
execvp(diffprog, diffargv);
err(2, "could not execute diff: %s", diffprog);
break;
-@@ -1117,10 +1135,8 @@ int_usage(void)
+@@ -461,6 +473,7 @@ main(int argc, char **argv)
+ static void
+ printcol(const char *s, size_t *col, const size_t col_max)
+ {
++
+ for (; *s && *col < col_max; ++s) {
+ size_t new_col;
+
+@@ -484,11 +497,9 @@ printcol(const char *s, size_t *col, con
+ return;
+ *col = new_col;
+ break;
+-
+ default:
+ ++(*col);
+ }
+-
+ putchar(*s);
+ }
+ }
+@@ -527,13 +538,12 @@ prompt(const char *s1, const char *s2)
+ /* Choose left column as-is. */
+ if (s1 != NULL)
+ fprintf(outfp, "%s\n", s1);
+-
+ /* End of command parsing. */
+ break;
+
+ case 'q':
+ goto QUIT;
+-
++
+ case 'r':
+ case '2':
+ /* Choose right column as-is. */
+@@ -1117,10 +1127,8 @@ int_usage(void)
static void
usage(void)
{
Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c
==============================================================================
--- soc2012/jhagewood/sdiff/sdiff/sdiff.c Sat Jul 7 00:25:17 2012 (r239060)
+++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Sat Jul 7 01:07:58 2012 (r239061)
@@ -261,7 +261,6 @@
const char *errstr;
switch (ch) {
-
/* only compatible --long-name-form with diff */
case FCASE_IGNORE_OPT:
case FCASE_SENSITIVE_OPT:
@@ -269,7 +268,6 @@
case TSIZE_OPT:
case 'S':
break;
-
/* combine no-arg single switches */
case 'a':
case 'B':
@@ -281,10 +279,9 @@
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 );
+ diffargv[1] = realloc(diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2);
sprintf(diffargv[1], "%s%c", diffargv[1], ch);
break;
-
case DIFFPROG_OPT:
diffargv[0] = diffprog = optarg;
break;
@@ -323,11 +320,8 @@
usage();
break;
}
-
-
-
}
-
+
/* no single switches were used */
if( strcmp( diffargv[1], "-" ) == 0 )
{
@@ -381,19 +375,19 @@
/* Add NULL to end of array to indicate end of array. */
diffargv[diffargc++] = NULL;
- /* Subtract column divider and divide by two. */
+ /* Subtract column divider, divide by two, subtract 2. */
width = ((wflag - 3) / 2) - 2;
/* 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 + 3) * 2);
- if( ppid == -1 )
+ if (ppid == -1 )
{
if (pipe(fd))
err(2, "pipe");
- switch(pid = fork()) {
+ switch (pid = fork()) {
case 0:
/* child */
/* We don't read from the pipe. */
@@ -479,6 +473,7 @@
static void
printcol(const char *s, size_t *col, const size_t col_max)
{
+
for (; *s && *col < col_max; ++s) {
size_t new_col;
@@ -502,11 +497,9 @@
return;
*col = new_col;
break;
-
default:
++(*col);
}
-
putchar(*s);
}
}
@@ -545,13 +538,12 @@
/* Choose left column as-is. */
if (s1 != NULL)
fprintf(outfp, "%s\n", s1);
-
/* End of command parsing. */
break;
case 'q':
goto QUIT;
-
+
case 'r':
case '2':
/* Choose right column as-is. */
More information about the svn-soc-all
mailing list