socsvn commit: r240299 - soc2012/jhagewood/sdiff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Sun Aug 12 19:43:07 UTC 2012
Author: jhagewood
Date: Sun Aug 12 19:43:04 2012
New Revision: 240299
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240299
Log:
gzip file support in sdiff
Modified:
soc2012/jhagewood/sdiff/sdiff.c
soc2012/jhagewood/sdiff/sdiff.h
Modified: soc2012/jhagewood/sdiff/sdiff.c
==============================================================================
--- soc2012/jhagewood/sdiff/sdiff.c Sun Aug 12 17:53:06 2012 (r240298)
+++ soc2012/jhagewood/sdiff/sdiff.c Sun Aug 12 19:43:04 2012 (r240299)
@@ -61,6 +61,8 @@
char *right;
};
+extern FILE *decompressfile(char *, char *);
+
static void astrcat(char **, const char *);
static void enqueue(char *, char, char *);
static char *mktmpcpy(const char *);
@@ -250,7 +252,7 @@
pid_t pid=0; pid_t ppid =-1;
const char *outfile = NULL;
struct option *popt;
- char **diffargv, *diffprog = "/usr/bin/diff", *filename1, *filename2,
+ char **diffargv, *diffprog = DIFF_PATH, *filename1, *filename2,
*tmp1, *tmp2, *s1, *s2;
filebehave = FILE_NORMAL;
@@ -516,17 +518,25 @@
return (WEXITSTATUS(status));
}
+/*
+ * When sdiff/zsdiff detects a binary file as input, executes them with
+ * diff/zdiff to maintain the same behavior as GNU sdiff with binary input.
+ */
static void
binexec(char *diffprog, char *f1, char *f2)
{
char *args[] = {diffprog, f1, f2, (char *) 0};
+ if (filebehave == FILE_GZIP) {
+ diffprog = ZDIFF_PATH;
+ }
execv(diffprog, args);
/* If execv() fails, this program's execution will continue. */
sprintf(stderr, "Could not execute diff process.\n");
exit(1);
}
+
/*
* Checks whether a file appears to be a text file.
*/
Modified: soc2012/jhagewood/sdiff/sdiff.h
==============================================================================
--- soc2012/jhagewood/sdiff/sdiff.h Sun Aug 12 17:53:06 2012 (r240298)
+++ soc2012/jhagewood/sdiff/sdiff.h Sun Aug 12 19:43:04 2012 (r240299)
@@ -24,10 +24,16 @@
* SUCH DAMAGE.
*/
-FILE *decompressfile(char *, char *);
-
/*
* File input types
*/
#define FILE_NORMAL 0
#define FILE_GZIP 1
+
+/*
+ * Program paths
+ */
+#define DIFF_PATH "/usr/bin/diff"
+#define ZDIFF_PATH "/usr/bin/zdiff"
+
+FILE *decompressfile(char *, char *);
More information about the svn-soc-all
mailing list