From: Junio C Hamano Date: Fri, 23 Aug 2019 21:33:48 +0000 (-0700) Subject: Merge branch 'nd/diff-parseopt' into next X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d80a83b1e472720e1f1d6eb25e073d1c4b5230ae;p=git Merge branch 'nd/diff-parseopt' into next Compilation fix. * nd/diff-parseopt: parseopt: move definition of enum parse_opt_result up --- d80a83b1e472720e1f1d6eb25e073d1c4b5230ae diff --cc parse-options.h index a4bd40bb6a,c4713a06c6..38a33a087e --- a/parse-options.h +++ b/parse-options.h @@@ -228,28 -231,8 +237,19 @@@ const char *optname(const struct optio BUG("option callback does not expect an argument"); \ } while (0) +/* + * Similar to the assertions above, but checks that "arg" is always non-NULL. + * This assertion also implies BUG_ON_OPT_NEG(), letting you declare both + * assertions in a single line. + */ +#define BUG_ON_OPT_NEG_NOARG(unset, arg) do { \ + BUG_ON_OPT_NEG(unset); \ + if(!(arg)) \ + BUG("option callback expects an argument"); \ +} while(0) + /*----- incremental advanced APIs -----*/ - enum parse_opt_result { - PARSE_OPT_COMPLETE = -3, - PARSE_OPT_HELP = -2, - PARSE_OPT_ERROR = -1, /* must be the same as error() */ - PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ - PARSE_OPT_NON_OPTION, - PARSE_OPT_UNKNOWN - }; - /* * It's okay for the caller to consume argv/argc in the usual way. * Other fields of that structure are private to parse-options and should not