From owner-svn-soc-all@FreeBSD.ORG Sun Aug 12 19:43:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8CE43106566C for ; Sun, 12 Aug 2012 19:43:05 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 12 Aug 2012 19:43:05 +0000 Date: Sun, 12 Aug 2012 19:43:05 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120812194305.8CE43106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r240299 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2012 19:43:07 -0000 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 *);