X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ad7871609881e73855d0b04da49b486cd93efca7..ed554bc5e4201344d7eaad78263566e79428759c:/usr/src/usr.bin/cmp/cmp.c diff --git a/usr/src/usr.bin/cmp/cmp.c b/usr/src/usr.bin/cmp/cmp.c index 8dd69cb5f7..dc6c64e8be 100644 --- a/usr/src/usr.bin/cmp/cmp.c +++ b/usr/src/usr.bin/cmp/cmp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1987, 1990, 1993 + * Copyright (c) 1987, 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,28 +33,31 @@ #ifndef lint static char copyright[] = -"@(#) Copyright (c) 1987, 1990, 1993\n\ +"@(#) Copyright (c) 1987, 1990, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)cmp.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ #include #include + +#include #include -#include -#include #include #include #include +#include + #include "extern.h" int lflag, sflag; static void usage __P((void)); +int main(argc, argv) int argc; char *argv[]; @@ -84,7 +87,7 @@ endargs: argc -= optind; if (lflag && sflag) - err("only one of -l and -s may be specified"); + errx(ERR_EXIT, "only one of -l and -s may be specified"); if (argc < 2 || argc > 4) usage(); @@ -97,28 +100,29 @@ endargs: file1 = "stdin"; } else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) - err("%s: %s", file1, strerror(errno)); + err(ERR_EXIT, "%s", file1); if (strcmp(file2 = argv[1], "-") == 0) { if (special) - err("standard input may only be specified once"); + errx(ERR_EXIT, + "standard input may only be specified once"); special = 1; fd2 = 0; file2 = "stdin"; } else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) - err("%s: %s", file2, strerror(errno)); + err(ERR_EXIT, "%s", file2); skip1 = argc > 2 ? strtol(argv[2], NULL, 10) : 0; skip2 = argc == 4 ? strtol(argv[3], NULL, 10) : 0; if (!special) { if (fstat(fd1, &sb1)) - err("%s: %s", file1, strerror(errno)); + err(ERR_EXIT, "%s", file1); if (!S_ISREG(sb1.st_mode)) special = 1; else { if (fstat(fd2, &sb2)) - err("%s: %s", file2, strerror(errno)); + err(ERR_EXIT, "%s", file2); if (!S_ISREG(sb2.st_mode)) special = 1; } @@ -135,7 +139,8 @@ endargs: static void usage() { + (void)fprintf(stderr, "usage: cmp [-l | s] file1 file2 [skip1 [skip2]]\n"); - exit(2); + exit(ERR_EXIT); }