From 6422f633216475939f9a6f317e41a164737cbb02 Mon Sep 17 00:00:00 2001 From: Michele Ballabio Date: Sun, 22 Jun 2008 16:39:04 +0200 Subject: parse-options.c: fix documentation syntax of optional arguments When an argument for an option is optional, short options don't need a space between the option and the argument, and long options need a "=". Otherwise, arguments are misinterpreted. Signed-off-by: Michele Ballabio Signed-off-by: Junio C Hamano --- parse-options.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'parse-options.c') diff --git a/parse-options.c b/parse-options.c index acf3fe3a1a..f8d52e21fe 100644 --- a/parse-options.c +++ b/parse-options.c @@ -344,7 +344,10 @@ void usage_with_options_internal(const char * const *usagestr, break; case OPTION_INTEGER: if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, "[]"); + if (opts->long_name) + pos += fprintf(stderr, "[=]"); + else + pos += fprintf(stderr, "[]"); else pos += fprintf(stderr, " "); break; @@ -355,12 +358,18 @@ void usage_with_options_internal(const char * const *usagestr, case OPTION_STRING: if (opts->argh) { if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " [<%s>]", opts->argh); + if (opts->long_name) + pos += fprintf(stderr, "[=<%s>]", opts->argh); + else + pos += fprintf(stderr, "[<%s>]", opts->argh); else pos += fprintf(stderr, " <%s>", opts->argh); } else { if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " [...]"); + if (opts->long_name) + pos += fprintf(stderr, "[=...]"); + else + pos += fprintf(stderr, "[...]"); else pos += fprintf(stderr, " ..."); } -- cgit v1.2.3