parse-options: make sure argh string does not have SP or _
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>
Junio C Hamano committed
Mar 23, 2014 at 16:04 UTC
b6c2a0d45d4165dfd326bd7a28e66d9cedb8ae84
1 file changed
+3
parse-options.c
+3
@@ -375,6 +375,9 @@ static void parse_options_check(const struct option *opts)
375
default:
376
; /* ok. (usually accepts an argument) */
377
}
378
+ if (opts->argh &&
379
+ strcspn(opts->argh, " _") != strlen(opts->argh))
380
+ err |= optbug(opts, "multi-word argh should use dash to separate words");
381
}
382
if (err)
383
exit(128);