parse-options: export opterr, optbug
opterror and optbug functions are used by some of parsing routines in parse-options.c to report errors and bugs respectively. Export these functions to allow more custom parsing routines to use them in a uniform way. Signed-off-by: Dmitry Ivankov <divanorama@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1421fd9df4
commit
1f275b7c4c
@ -12,14 +12,14 @@ static int parse_options_usage(struct parse_opt_ctx_t *ctx,
|
|||||||
#define OPT_SHORT 1
|
#define OPT_SHORT 1
|
||||||
#define OPT_UNSET 2
|
#define OPT_UNSET 2
|
||||||
|
|
||||||
static int optbug(const struct option *opt, const char *reason)
|
int optbug(const struct option *opt, const char *reason)
|
||||||
{
|
{
|
||||||
if (opt->long_name)
|
if (opt->long_name)
|
||||||
return error("BUG: option '%s' %s", opt->long_name, reason);
|
return error("BUG: option '%s' %s", opt->long_name, reason);
|
||||||
return error("BUG: switch '%c' %s", opt->short_name, reason);
|
return error("BUG: switch '%c' %s", opt->short_name, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int opterror(const struct option *opt, const char *reason, int flags)
|
int opterror(const struct option *opt, const char *reason, int flags)
|
||||||
{
|
{
|
||||||
if (flags & OPT_SHORT)
|
if (flags & OPT_SHORT)
|
||||||
return error("switch `%c' %s", opt->short_name, reason);
|
return error("switch `%c' %s", opt->short_name, reason);
|
||||||
|
@ -165,6 +165,8 @@ extern NORETURN void usage_msg_opt(const char *msg,
|
|||||||
const char * const *usagestr,
|
const char * const *usagestr,
|
||||||
const struct option *options);
|
const struct option *options);
|
||||||
|
|
||||||
|
extern int optbug(const struct option *opt, const char *reason);
|
||||||
|
extern int opterror(const struct option *opt, const char *reason, int flags);
|
||||||
/*----- incremental advanced APIs -----*/
|
/*----- incremental advanced APIs -----*/
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user