提交 69ee9b2c 编写于 作者: R Rich Felker

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.
上级 22730d65
...@@ -3,14 +3,18 @@ ...@@ -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);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册