=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/diff/diff.c,v retrieving revision 1.14 retrieving revision 1.15 diff -c -r1.14 -r1.15 *** src/usr.bin/diff/diff.c 2003/06/26 07:20:12 1.14 --- src/usr.bin/diff/diff.c 2003/06/26 18:19:29 1.15 *************** *** 1,4 **** ! /* $OpenBSD: diff.c,v 1.14 2003/06/26 07:20:12 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. --- 1,4 ---- ! /* $OpenBSD: diff.c,v 1.15 2003/06/26 18:19:29 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. *************** *** 34,40 **** --- 34,42 ---- * POSSIBILITY OF SUCH DAMAGE. */ + #include #include + #include #include #include "diff.h" *************** *** 88,94 **** const char *diffh = _PATH_DIFFH; const char *pr = _PATH_PR; - static void noroom(void); __dead void usage(void); int --- 90,95 ---- *************** *** 178,196 **** argv += optind; if (argc != 2) ! errx(1, "two filename arguments required"); file1 = argv[0]; file2 = argv[1]; if (hflag && opt) ! errx(1, "-h doesn't support -D, -c, -C, -e, -f, -I, -n, -u or -U"); if (!strcmp(file1, "-")) stb1.st_mode = S_IFREG; else if (stat(file1, &stb1) < 0) ! err(1, "%s", file1); if (!strcmp(file2, "-")) stb2.st_mode = S_IFREG; else if (stat(file2, &stb2) < 0) ! err(1, "%s", file2); if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) diffdir(argv); else --- 179,197 ---- argv += optind; if (argc != 2) ! errorx("two filename arguments required"); file1 = argv[0]; file2 = argv[1]; if (hflag && opt) ! errorx("-h doesn't support -D, -c, -C, -e, -f, -I, -n, -u or -U"); if (!strcmp(file1, "-")) stb1.st_mode = S_IFREG; else if (stat(file1, &stb1) < 0) ! error("%s", file1); if (!strcmp(file2, "-")) stb2.st_mode = S_IFREG; else if (stat(file2, &stb2) < 0) ! error("%s", file2); if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) diffdir(argv); else *************** *** 215,223 **** __dead void done(int sig) { ! if (tempfiles[0]) unlink(tempfiles[0]); ! if (tempfiles[1]) unlink(tempfiles[1]); if (sig) _exit(status); --- 216,224 ---- __dead void done(int sig) { ! if (tempfiles[0] != NULL) unlink(tempfiles[0]); ! if (tempfiles[1] != NULL) unlink(tempfiles[1]); if (sig) _exit(status); *************** *** 230,236 **** void *p; if ((p = malloc(n)) == NULL) ! noroom(); return (p); } --- 231,237 ---- void *p; if ((p = malloc(n)) == NULL) ! error("files too big, try -h"); return (p); } *************** *** 240,257 **** void *q; if ((q = realloc(p, n)) == NULL) ! noroom(); return (q); } ! static void ! noroom(void) { ! warn("files too big, try -h"); ! done(0); } __dead void usage(void) { (void)fprintf(stderr, --- 241,281 ---- void *q; if ((q = realloc(p, n)) == NULL) ! error("files too big, try -h"); return (q); } ! __dead void ! error(const char *fmt, ...) { ! va_list ap; ! int sverrno = errno; ! ! if (tempfiles[0] != NULL) ! unlink(tempfiles[0]); ! if (tempfiles[1] != NULL) ! unlink(tempfiles[1]); ! errno = sverrno; ! va_start(ap, fmt); ! verr(status, fmt, ap); ! va_end(ap); } __dead void + errorx(const char *fmt, ...) + { + va_list ap; + + if (tempfiles[0] != NULL) + unlink(tempfiles[0]); + if (tempfiles[1] != NULL) + unlink(tempfiles[1]); + va_start(ap, fmt); + verrx(status, fmt, ap); + va_end(ap); + } + + __dead void usage(void) { (void)fprintf(stderr, *************** *** 262,266 **** " diff [-biwt] [-c | -e | -f | -h | -n | -u ] " "[-l] [-r] [-s] [-S name]\n dir1 dir2\n"); ! exit(1); } --- 286,290 ---- " diff [-biwt] [-c | -e | -f | -h | -n | -u ] " "[-l] [-r] [-s] [-S name]\n dir1 dir2\n"); ! exit(2); }