[PATCH 3/3] parse-options: make sure argh string does not have SP or _
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 24, 2014, 17:52 UTC
- Message-ID
- <1395683525-2868-4-git-send-email-gitster@pobox.com>
- In-Reply-To
- <1395683525-2868-1-git-send-email-gitster@pobox.com>
We encourage to spell an argument hint that consists of multiple words as a single-token separated with dashes. In order to help catching violations added by new callers of parse-options, make sure argh does not contain SP or _ when the code validates the option definitions.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- parse-options.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/parse-options.c b/parse-options.c index a5fa0b8..c81d3a0 100644 --- a/parse-options.c +++ b/parse-options.c @@ -375,6 +375,9 @@ static void parse_options_check(const struct option *opts) default: ; /* ok. (usually accepts an argument) */ } + if (opts->argh && + strcspn(opts->argh, " _") != strlen(opts->argh)) + err |= optbug(opts, "multi-word argh should use dash to separate words"); } if (err) exit(128);
-- 1.9.1-471-gcccbd8b