PERFORCE change 145821 for review
Gabor Kovesdan
gabor at FreeBSD.org
Thu Jul 24 15:51:50 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145821
Change 145821 by gabor at gabor_server on 2008/07/24 15:50:59
- Revert --to-file and --from-file, they were badly implemented
and caused an infinite loop in recursive diffs
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/diff/diff.c#13 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/diff/diff.c#13 (text+ko) ====
@@ -137,7 +137,6 @@
{
char *ep, *fromfile = NULL, *tofile = NULL, **oargv;
int ch, lastch, gotstdin, prevoptind, newarg, flags = 0;
- char *dst, *src;
setlocale(LC_ALL, "");
@@ -321,62 +320,40 @@
errx(2, "%s", buf);
}
}
-
- if (fromfile != NULL) {
- src = fromfile;
- dst = argv[0];
- } else if (tofile != NULL) {
- dst = tofile;
- src = argv[0];
+ if (strcmp(argv[0], "-") == 0) {
+ fstat(STDIN_FILENO, &stb1);
+ gotstdin = 1;
+ } else if (stat(argv[0], &stb1) != 0) {
+ if (uniflag)
+ flags |= D_EMPTY1;
+ else
+ err(2, "%s", argv[0]);
+ }
+ if (strcmp(argv[1], "-") == 0) {
+ fstat(STDIN_FILENO, &stb2);
+ gotstdin = 1;
+ } else if (stat(argv[1], &stb2) != 0)
+ err(2, "%s", argv[1]);
+ if (gotstdin && (S_ISDIR(stb1.st_mode) || S_ISDIR(stb2.st_mode)))
+ errx(2, "can't compare - to a directory");
+ set_argstr(oargv, argv);
+ if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
+ if (format == D_IFDEF)
+ errx(2, "-D option not supported with directories");
+ diffdir(argv[0], argv[1]);
} else {
- src = argv[0];
- dst = argv[1];
- }
-
- for (ch = 1; src && dst;ch++) {
- if (strcmp(src, "-") == 0) {
- fstat(STDIN_FILENO, &stb1);
- gotstdin = 1;
- } else if (stat(src, &stb1) != 0) {
- if (uniflag)
- flags |= D_EMPTY1;
- else
- err(2, "%s", src);
+ if (S_ISDIR(stb1.st_mode)) {
+ argv[0] = splice(argv[0], argv[1]);
+ if (stat(argv[0], &stb1) < 0)
+ err(2, "%s", argv[0]);
}
- if (strcmp(dst, "-") == 0) {
- fstat(STDIN_FILENO, &stb2);
- gotstdin = 1;
- } else if (stat(dst, &stb2) != 0)
- err(2, "%s", dst);
- if (gotstdin && (S_ISDIR(stb1.st_mode) || S_ISDIR(stb2.st_mode)))
- errx(2, "can't compare - to a directory");
-/* XXX: ???
- set_argstr(oargv, argv); */
- if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
- if (format == D_IFDEF)
- errx(2, "-D option not supported with directories");
- diffdir(src, dst);
- } else {
- if (S_ISDIR(stb1.st_mode)) {
- src = splice(src, dst);
- if (stat(argv[0], &stb1) < 0)
- err(2, "%s", argv[0]);
- }
- if (S_ISDIR(stb2.st_mode)) {
- argv[1] = splice(dst, src);
- if (stat(argv[1], &stb2) < 0)
- err(2, "%s", argv[1]);
- }
- print_status(diffreg(src, dst, flags), src, dst,
- NULL);
- if (fromfile != NULL)
- dst = argv[ch];
- else if (tofile != NULL)
- src = argv[ch];
- else
- break;
+ if (S_ISDIR(stb2.st_mode)) {
+ argv[1] = splice(argv[1], argv[0]);
+ if (stat(argv[1], &stb2) < 0)
+ err(2, "%s", argv[1]);
}
-
+ print_status(diffreg(argv[0], argv[1], flags), argv[0], argv[1],
+ NULL);
}
exit(status);
}
More information about the p4-projects
mailing list