Use err(3) instead of local redefinition.

This commit is contained in:
Philippe Charnier 1997-08-11 07:28:19 +00:00
parent 439165e504
commit 3042ea1f52
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28069
3 changed files with 12 additions and 36 deletions

View File

@ -56,6 +56,6 @@ attempts to report on the file
.Xr a.out 5 .Xr a.out 5
.Sh HISTORY .Sh HISTORY
A A
.Nm size .Nm
command appeared in command appeared in
.At v6 . .At v6 .

View File

@ -56,6 +56,6 @@ attempts to report on the file
.Xr a.out 5 .Xr a.out 5
.Sh HISTORY .Sh HISTORY
A A
.Nm size .Nm
command appeared in command appeared in
.At v6 . .At v6 .

View File

@ -32,27 +32,30 @@
*/ */
#ifndef lint #ifndef lint
static char copyright[] = static const char copyright[] =
"@(#) Copyright (c) 1988, 1993\n\ "@(#) Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n"; The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
#if 0
static char sccsid[] = "@(#)size.c 8.2 (Berkeley) 12/9/93"; static char sccsid[] = "@(#)size.c 8.2 (Berkeley) 12/9/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
#include <sys/file.h> #include <sys/file.h>
#include <errno.h> #include <err.h>
#include <a.out.h> #include <a.out.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
void err __P((const char *, ...));
int show __P((int, char *)); int show __P((int, char *));
void usage __P((void)); static void usage __P((void));
int int
main(argc, argv) main(argc, argv)
@ -91,12 +94,12 @@ show(count, name)
int fd; int fd;
if ((fd = open(name, O_RDONLY, 0)) < 0) { if ((fd = open(name, O_RDONLY, 0)) < 0) {
err("%s: %s", name, strerror(errno)); warn("%s", name);
return (1); return (1);
} }
if (read(fd, &head, sizeof(head)) != sizeof(head) || N_BADMAG(head)) { if (read(fd, &head, sizeof(head)) != sizeof(head) || N_BADMAG(head)) {
(void)close(fd); (void)close(fd);
err("%s: not in a.out format", name); warnx("%s: not in a.out format", name);
return (1); return (1);
} }
(void)close(fd); (void)close(fd);
@ -114,36 +117,9 @@ show(count, name)
return (0); return (0);
} }
void static void
usage() usage()
{ {
(void)fprintf(stderr, "usage: size [file ...]\n"); (void)fprintf(stderr, "usage: size [file ...]\n");
exit(1); exit(1);
} }
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
err(const char *fmt, ...)
#else
err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "size: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
}