make err.h functions print __progname

patch by Strake. previously is was not feasible to duplicate this
functionality of the functions these were modeled on, since argv[0]
was not saved at program startup, but now that it's available it's
easy to use.
This commit is contained in:
Rich Felker 2013-05-18 10:20:42 -04:00
parent 22730d6560
commit 69ee9b2cb1
1 changed files with 4 additions and 0 deletions

View File

@ -3,14 +3,18 @@
#include <stdarg.h>
#include <stdlib.h>
extern char *__progname;
void vwarn(const char *fmt, va_list ap)
{
fprintf (stderr, "%s: ", __progname);
if (fmt) vfprintf(stderr, fmt, ap);
perror("");
}
void vwarnx(const char *fmt, va_list ap)
{
fprintf (stderr, "%s: ", __progname);
if (fmt) vfprintf(stderr, fmt, ap);
putc('\n', stderr);
}