Add weprintf()

This commit is contained in:
sin 2014-03-12 16:18:29 +02:00
parent f7a4849ded
commit 6df1301594
2 changed files with 18 additions and 0 deletions

1
util.h
View File

@ -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 *, ...);

View File

@ -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);
}
}