[PATCH 3/4] parseopt: make usage optional
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Mar 8, 2009, 18:16 UTC
- Message-ID
- <49B40B9A.8080202@lsrfire.ath.cx>
- In-Reply-To
- <49B2C784.90800@lsrfire.ath.cx>
Allow usagestr to be NULL and don't display anything a help screen in this case. This is useful to implement incremental parsers.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> --- parse-options.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/parse-options.c b/parse-options.c index 8b21dea..51e804b 100644 --- a/parse-options.c +++ b/parse-options.c @@ -364,6 +364,9 @@ int parse_options(int argc, const char **argv, const struct option *options, int usage_with_options_internal(const char * const *usagestr, const struct option *opts, int full) { + if (!usagestr) + return PARSE_OPT_HELP; + fprintf(stderr, "usage: %s\n", *usagestr++); while (*usagestr && **usagestr) fprintf(stderr, " or: %s\n", *usagestr++);
-- 1.6.2