version 1.14, 2003/06/25 07:26:59 |
version 1.15, 2003/06/25 17:49:22 |
|
|
if (hflag) { |
if (hflag) { |
diffargv[0] = "diffh"; |
diffargv[0] = "diffh"; |
execv(diffh, diffargv); |
execv(diffh, diffargv); |
fprintf(stderr, "diff: "); |
warn("%s", diffh); |
perror(diffh); |
|
done(0); |
done(0); |
} |
} |
chrtran = (iflag ? cup2low : clow2low); |
chrtran = (iflag ? cup2low : clow2low); |
if ((stb1.st_mode & S_IFMT) == S_IFDIR) { |
if ((stb1.st_mode & S_IFMT) == S_IFDIR) { |
file1 = splice(file1, file2); |
file1 = splice(file1, file2); |
if (stat(file1, &stb1) < 0) { |
if (stat(file1, &stb1) < 0) { |
fprintf(stderr, "diff: "); |
warn("%s", file1); |
perror(file1); |
|
done(0); |
done(0); |
} |
} |
} else if ((stb2.st_mode & S_IFMT) == S_IFDIR) { |
} else if ((stb2.st_mode & S_IFMT) == S_IFDIR) { |
file2 = splice(file2, file1); |
file2 = splice(file2, file1); |
if (stat(file2, &stb2) < 0) { |
if (stat(file2, &stb2) < 0) { |
fprintf(stderr, "diff: "); |
warn("%s", file2); |
perror(file2); |
|
done(0); |
done(0); |
} |
} |
} else if ((stb1.st_mode & S_IFMT) != S_IFREG || !strcmp(file1, "-")) { |
} else if ((stb1.st_mode & S_IFMT) != S_IFREG || !strcmp(file1, "-")) { |
if (!strcmp(file2, "-")) { |
if (!strcmp(file2, "-")) { |
fprintf(stderr, "diff: can't specify - -\n"); |
warnx("can't specify - -"); |
done(0); |
done(0); |
} |
} |
file1 = copytemp(); |
file1 = copytemp(); |
if (stat(file1, &stb1) < 0) { |
if (stat(file1, &stb1) < 0) { |
fprintf(stderr, "diff: "); |
warn("%s", file1); |
perror(file1); |
|
done(0); |
done(0); |
} |
} |
} else if ((stb2.st_mode & S_IFMT) != S_IFREG || !strcmp(file2, "-")) { |
} else if ((stb2.st_mode & S_IFMT) != S_IFREG || !strcmp(file2, "-")) { |
file2 = copytemp(); |
file2 = copytemp(); |
if (stat(file2, &stb2) < 0) { |
if (stat(file2, &stb2) < 0) { |
fprintf(stderr, "diff: "); |
warn("%s", file2); |
perror(file2); |
|
done(0); |
done(0); |
} |
} |
} |
} |
if ((f1 = fopen(file1, "r")) == NULL) { |
if ((f1 = fopen(file1, "r")) == NULL) { |
fprintf(stderr, "diff: "); |
warn("%s", file1); |
perror(file1); |
|
done(0); |
done(0); |
} |
} |
if ((f2 = fopen(file2, "r")) == NULL) { |
if ((f2 = fopen(file2, "r")) == NULL) { |
fprintf(stderr, "diff: "); |
warn("%s", file2); |
perror(file2); |
|
fclose(f1); |
fclose(f1); |
done(0); |
done(0); |
} |
} |
|
|
signal(SIGTERM, done); |
signal(SIGTERM, done); |
f = mkstemp(tempfile); |
f = mkstemp(tempfile); |
if (f < 0) { |
if (f < 0) { |
fprintf(stderr, "diff: "); |
warn("%s", tempfile); |
perror(tempfile); |
|
done(0); |
done(0); |
} |
} |
while ((i = read(0, buf, BUFSIZ)) > 0) |
while ((i = read(0, buf, BUFSIZ)) > 0) |
if (write(f, buf, i) != i) { |
if (write(f, buf, i) != i) { |
fprintf(stderr, "diff: "); |
warn("%s", tempfile); |
perror(tempfile); |
|
done(0); |
done(0); |
} |
} |
close(f); |
close(f); |
|
|
char *tail, buf[BUFSIZ]; |
char *tail, buf[BUFSIZ]; |
|
|
if (!strcmp(file, "-")) { |
if (!strcmp(file, "-")) { |
fprintf(stderr, "diff: can't specify - with other arg directory\n"); |
warnx("can't specify - with other arg directory"); |
done(0); |
done(0); |
} |
} |
tail = strrchr(file, '/'); |
tail = strrchr(file, '/'); |