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:
parent
22730d6560
commit
69ee9b2cb1
1 changed files with 4 additions and 0 deletions
|
|
@ -3,14 +3,18 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
void vwarn(const char *fmt, va_list ap)
|
void vwarn(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "%s: ", __progname);
|
||||||
if (fmt) vfprintf(stderr, fmt, ap);
|
if (fmt) vfprintf(stderr, fmt, ap);
|
||||||
perror("");
|
perror("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void vwarnx(const char *fmt, va_list ap)
|
void vwarnx(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "%s: ", __progname);
|
||||||
if (fmt) vfprintf(stderr, fmt, ap);
|
if (fmt) vfprintf(stderr, fmt, ap);
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue