From: Junio C Hamano Date: Mon, 9 Sep 2019 19:26:38 +0000 (-0700) Subject: Merge branch 'nd/diff-parseopt' X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4c49dd042d34a44b3238ea901aeceeea716ab8e2 Merge branch 'nd/diff-parseopt' Compilation fix. * nd/diff-parseopt: parseopt: move definition of enum parse_opt_result up --- 4c49dd042d34a44b3238ea901aeceeea716ab8e2 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