version 1.18, 2006/05/10 14:32:51 |
version 1.19, 2006/05/25 03:20:32 |
|
|
#include <fcntl.h> |
#include <fcntl.h> |
#include <getopt.h> |
#include <getopt.h> |
#include <limits.h> |
#include <limits.h> |
|
#include <paths.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
int lflag; /* print only left column for identical lines */ |
int lflag; /* print only left column for identical lines */ |
int sflag; /* skip identical lines */ |
int sflag; /* skip identical lines */ |
FILE *outfile; /* file to save changes to */ |
FILE *outfile; /* file to save changes to */ |
|
const char *tmpdir; /* TMPDIR or /tmp */ |
|
|
static struct option longopts[] = { |
static struct option longopts[] = { |
{ "text", no_argument, NULL, 'a' }, |
{ "text", no_argument, NULL, 'a' }, |
|
|
} |
} |
|
|
/* Not a regular file, so copy input into temporary file. */ |
/* Not a regular file, so copy input into temporary file. */ |
target_file = xmktemp(NULL); |
if (asprintf(&target_file, "%s/sdiff.XXXXXXXXXX", tmpdir) == -1) |
if ((ofd = open(target_file, O_WRONLY, 0)) == -1) { |
err(2, "asprintf"); |
|
if ((ofd = mkstemp(target_file)) == -1) { |
warn("error opening %s", target_file); |
warn("error opening %s", target_file); |
goto FAIL; |
goto FAIL; |
} |
} |
|
|
|
|
if (argc != 2) |
if (argc != 2) |
usage(); |
usage(); |
|
|
|
if ((tmpdir = getenv("TMPDIR")) == NULL) |
|
tmpdir = _PATH_TMP; |
|
|
filename1 = argv[0]; |
filename1 = argv[0]; |
filename2 = argv[1]; |
filename2 = argv[1]; |