summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-10-20 00:00:58 +0000
committerMiles Bader <miles@gnu.org>1995-10-20 00:00:58 +0000
commit50326660792937362d5710dff973861d61332e0d (patch)
tree2d04fe799b0cea1e839eef4570feaf168ce944a7 /libshouldbeinlibc
parent1532f4f28fe5ec893c6e4980d1d73c99010b336f (diff)
(argp_error): New function.
Diffstat (limited to 'libshouldbeinlibc')
-rw-r--r--libshouldbeinlibc/argp-help.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libshouldbeinlibc/argp-help.c b/libshouldbeinlibc/argp-help.c
index 9c93a2f6..db6a8629 100644
--- a/libshouldbeinlibc/argp-help.c
+++ b/libshouldbeinlibc/argp-help.c
@@ -748,3 +748,25 @@ void argp_help (struct argp *argp, FILE *stream, unsigned flags)
if (flags & ARGP_HELP_EXIT_OK)
exit (0);
}
+
+/* Print the printf string FMT and following args, preceded by the program
+ name and `:', to stderr, and followed by a `Try ... --help' message. Then
+ exit (1). */
+void argp_error (struct argp *argp, char *fmt, ...)
+{
+ /* Assert that argp_help doesn't return, which it doesn't, as we use it. */
+ void argp_help (struct argp *, FILE *, unsigned) __attribute__ ((noreturn));
+ va_list ap;
+
+ fputs (program_invocation_name, stderr);
+ putc (':', stderr);
+ putc (' ', stderr);
+
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+
+ putc ('\n', stderr);
+
+ argp_help (argp, stderr, ARGP_HELP_STD_ERR);
+}