declare variables extern and define only once (from ralph)
[unix-history] / usr / src / lib / libc / stdio / perror.c
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)perror.c 8.1 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
void
perror(s)
const char *s;
{
register struct iovec *v;
struct iovec iov[4];
v = iov;
if (s && *s) {
v->iov_base = (char *)s;
v->iov_len = strlen(s);
v++;
v->iov_base = ": ";
v->iov_len = 2;
v++;
}
v->iov_base = strerror(errno);
v->iov_len = strlen(v->iov_base);
v++;
v->iov_base = "\n";
v->iov_len = 1;
(void)writev(STDERR_FILENO, iov, (v - iov) + 1);
}