version 1.3, 2003/06/25 03:02:33 |
version 1.4, 2003/06/25 03:37:32 |
|
|
if (*argp) { |
if (*argp) { |
fprintf(stderr, |
fprintf(stderr, |
"diff: -c: bad count\n"); |
"diff: -c: bad count\n"); |
done(); |
done(0); |
} |
} |
argp = ""; |
argp = ""; |
} else |
} else |
|
|
case 'S': |
case 'S': |
if (*argp == 0) { |
if (*argp == 0) { |
fprintf(stderr, "diff: use -Sstart\n"); |
fprintf(stderr, "diff: use -Sstart\n"); |
done(); |
done(0); |
} |
} |
start = argp; |
start = argp; |
*--argp = 0; /* don't pass it on */ |
*--argp = 0; /* don't pass it on */ |
|
|
default: |
default: |
fprintf(stderr, "diff: -%s: unknown option\n", |
fprintf(stderr, "diff: -%s: unknown option\n", |
--argp); |
--argp); |
done(); |
done(0); |
} |
} |
} |
} |
if (argc != 2) { |
if (argc != 2) { |
fprintf(stderr, "diff: two filename arguments required\n"); |
fprintf(stderr, "diff: two filename arguments required\n"); |
done(); |
done(0); |
} |
} |
file1 = argv[0]; |
file1 = argv[0]; |
file2 = argv[1]; |
file2 = argv[1]; |
if (hflag && opt) { |
if (hflag && opt) { |
fprintf(stderr, |
fprintf(stderr, |
"diff: -h doesn't support -e, -f, -n, -c, or -I\n"); |
"diff: -h doesn't support -e, -f, -n, -c, or -I\n"); |
done(); |
done(0); |
} |
} |
if (!strcmp(file1, "-")) |
if (!strcmp(file1, "-")) |
stb1.st_mode = S_IFREG; |
stb1.st_mode = S_IFREG; |
else if (stat(file1, &stb1) < 0) { |
else if (stat(file1, &stb1) < 0) { |
fprintf(stderr, "diff: "); |
fprintf(stderr, "diff: "); |
perror(file1); |
perror(file1); |
done(); |
done(0); |
} |
} |
if (!strcmp(file2, "-")) |
if (!strcmp(file2, "-")) |
stb2.st_mode = S_IFREG; |
stb2.st_mode = S_IFREG; |
else if (stat(file2, &stb2) < 0) { |
else if (stat(file2, &stb2) < 0) { |
fprintf(stderr, "diff: "); |
fprintf(stderr, "diff: "); |
perror(file2); |
perror(file2); |
done(); |
done(0); |
} |
} |
if ((stb1.st_mode & S_IFMT) == S_IFDIR && |
if ((stb1.st_mode & S_IFMT) == S_IFDIR && |
(stb2.st_mode & S_IFMT) == S_IFDIR) { |
(stb2.st_mode & S_IFMT) == S_IFDIR) { |
diffdir(argv); |
diffdir(argv); |
} else |
} else |
diffreg(); |
diffreg(); |
done(); |
done(0); |
/* notreached */ |
/* notreached */ |
return (0); |
return (0); |
} |
} |
|
|
} |
} |
|
|
void |
void |
done(void) |
done(int sig) |
{ |
{ |
if (tempfile) |
if (tempfile) |
unlink(tempfile); |
unlink(tempfile); |
|
if (sig) |
|
_exit(status); |
exit(status); |
exit(status); |
} |
} |
|
|
|
|
catchsig(int sigraised) |
catchsig(int sigraised) |
{ |
{ |
/* print something? */ |
/* print something? */ |
done(); |
done(0); |
} |
} |
|
|
void * |
void * |
|
|
noroom(void) |
noroom(void) |
{ |
{ |
fprintf(stderr, "diff: files too big, try -h\n"); |
fprintf(stderr, "diff: files too big, try -h\n"); |
done(); |
done(0); |
} |
} |