From 50326660792937362d5710dff973861d61332e0d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Oct 1995 00:00:58 +0000 Subject: (argp_error): New function. --- libshouldbeinlibc/argp-help.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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); +} -- cgit v1.2.3