Add weprintf()
This commit is contained in:
parent
f7a4849ded
commit
6df1301594
1
util.h
1
util.h
@ -19,3 +19,4 @@ size_t strlcat(char *, const char *, size_t);
|
||||
#undef strlcpy
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
char *ttytostr(int, int);
|
||||
void weprintf(const char *, ...);
|
||||
|
@ -44,3 +44,20 @@ venprintf(int status, const char *fmt, va_list ap)
|
||||
|
||||
exit(status);
|
||||
}
|
||||
|
||||
void
|
||||
weprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "%s: ", argv0);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user