version 1.83, 2014/08/27 15:22:40 |
version 1.84, 2015/01/16 06:40:07 |
|
|
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93 |
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93 |
*/ |
*/ |
|
|
#include <sys/param.h> |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/wait.h> |
#include <sys/wait.h> |
|
|
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
#include <limits.h> |
|
|
#include "diff.h" |
#include "diff.h" |
#include "pathnames.h" |
#include "pathnames.h" |
#include "xmalloc.h" |
#include "xmalloc.h" |
|
|
|
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) |
|
#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) |
|
|
/* |
/* |
* diff - compare two files. |
* diff - compare two files. |
*/ |
*/ |
|
|
static FILE * |
static FILE * |
opentemp(const char *file) |
opentemp(const char *file) |
{ |
{ |
char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN]; |
char buf[BUFSIZ], *tempdir, tempfile[PATH_MAX]; |
ssize_t nread; |
ssize_t nread; |
int ifd, ofd; |
int ifd, ofd; |
|
|
|
|
bound = UINT_MAX; |
bound = UINT_MAX; |
else { |
else { |
sq = isqrt(n); |
sq = isqrt(n); |
bound = MAX(256, sq); |
bound = MAXIMUM(256, sq); |
} |
} |
|
|
k = 0; |
k = 0; |
|
|
return; |
return; |
|
|
b = d = 0; /* gcc */ |
b = d = 0; /* gcc */ |
lowa = MAX(1, cvp->a - diff_context); |
lowa = MAXIMUM(1, cvp->a - diff_context); |
upb = MIN(len[0], context_vec_ptr->b + diff_context); |
upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); |
lowc = MAX(1, cvp->c - diff_context); |
lowc = MAXIMUM(1, cvp->c - diff_context); |
upd = MIN(len[1], context_vec_ptr->d + diff_context); |
upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); |
|
|
diff_output("***************"); |
diff_output("***************"); |
if ((flags & D_PROTOTYPE)) { |
if ((flags & D_PROTOTYPE)) { |
|
|
return; |
return; |
|
|
b = d = 0; /* gcc */ |
b = d = 0; /* gcc */ |
lowa = MAX(1, cvp->a - diff_context); |
lowa = MAXIMUM(1, cvp->a - diff_context); |
upb = MIN(len[0], context_vec_ptr->b + diff_context); |
upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); |
lowc = MAX(1, cvp->c - diff_context); |
lowc = MAXIMUM(1, cvp->c - diff_context); |
upd = MIN(len[1], context_vec_ptr->d + diff_context); |
upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); |
|
|
diff_output("@@ -"); |
diff_output("@@ -"); |
uni_range(lowa, upb); |
uni_range(lowa, upb); |