Use err(3) instead of local redefinition.
This commit is contained in:
parent
439165e504
commit
3042ea1f52
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28069
@ -56,6 +56,6 @@ attempts to report on the file
|
||||
.Xr a.out 5
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm size
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v6 .
|
||||
|
@ -56,6 +56,6 @@ attempts to report on the file
|
||||
.Xr a.out 5
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm size
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v6 .
|
||||
|
@ -32,27 +32,30 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)size.c 8.2 (Berkeley) 12/9/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <a.out.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void err __P((const char *, ...));
|
||||
int show __P((int, char *));
|
||||
void usage __P((void));
|
||||
static void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
@ -91,12 +94,12 @@ show(count, name)
|
||||
int fd;
|
||||
|
||||
if ((fd = open(name, O_RDONLY, 0)) < 0) {
|
||||
err("%s: %s", name, strerror(errno));
|
||||
warn("%s", name);
|
||||
return (1);
|
||||
}
|
||||
if (read(fd, &head, sizeof(head)) != sizeof(head) || N_BADMAG(head)) {
|
||||
(void)close(fd);
|
||||
err("%s: not in a.out format", name);
|
||||
warnx("%s: not in a.out format", name);
|
||||
return (1);
|
||||
}
|
||||
(void)close(fd);
|
||||
@ -114,36 +117,9 @@ show(count, name)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: size [file ...]\n");
|
||||
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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user