From 62673745e898e1b006d19bc0e4a9340adb772532 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 27 Jan 2014 20:28:16 +0100 Subject: [PATCH] Opt: opt_failure() is public, opt_usage() not so --- tools/libucw.api | 2 +- ucw/opt-internal.h | 2 -- ucw/opt.c | 4 +--- ucw/opt.h | 7 ++----- ucw/opt.t | 6 +++--- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/libucw.api b/tools/libucw.api index 80b2472a..2d48c08d 100644 --- a/tools/libucw.api +++ b/tools/libucw.api @@ -382,9 +382,9 @@ mp_vprintf mp_printf_append mp_vprintf_append # ucw/opt-internal.h -opt_failure opt_precompute # ucw/opt.h +opt_failure opt_handle_config opt_handle_set opt_handle_dumpconfig diff --git a/ucw/opt-internal.h b/ucw/opt-internal.h index 05694ca5..54717b39 100644 --- a/ucw/opt-internal.h +++ b/ucw/opt-internal.h @@ -12,7 +12,6 @@ #define _UCW_OPT_INTERNAL_H #ifdef CONFIG_UCW_CLEAN_ABI -#define opt_failure ucw_opt_failure #define opt_precompute ucw_opt_precompute #endif @@ -23,7 +22,6 @@ struct opt_precomputed { short count; }; -void opt_failure(const char * mesg, ...) FORMAT_CHECK(printf,1,2) NONRET; void opt_precompute(struct opt_precomputed *opt, struct opt_item *item); #endif diff --git a/ucw/opt.c b/ucw/opt.c index f7bae0d8..bba273c4 100644 --- a/ucw/opt.c +++ b/ucw/opt.c @@ -49,13 +49,11 @@ struct opt_context { bool stop_parsing; }; -// FIXME: Make public? void opt_failure(const char * mesg, ...) { va_list args; va_start(args, mesg); vfprintf(stderr, mesg, args); - fprintf(stderr, "\n"); - opt_usage(); + fprintf(stderr, "\nRun with --help for more information.\n"); exit(OPT_EXIT_BAD_ARGS); } diff --git a/ucw/opt.h b/ucw/opt.h index 25db7d45..aa9166e9 100644 --- a/ucw/opt.h +++ b/ucw/opt.h @@ -21,6 +21,7 @@ #define cf_def_file ucw_cf_def_file #define cf_env_file ucw_cf_env_file #define opt_conf_hook_internal ucw_opt_conf_hook_internal +#define opt_failure ucw_opt_failure #define opt_handle_config ucw_opt_handle_config #define opt_handle_dumpconfig ucw_opt_handle_dumpconfig #define opt_handle_help ucw_opt_handle_help @@ -193,14 +194,10 @@ extern char *cf_env_file; #define OPT_HOOK_AFTER_VALUE 0x4 /** Call after value parsing **/ #define OPT_HOOK_FINAL 0x8 /** Call just before opt_parse() returns **/ +void opt_failure(const char * mesg, ...) FORMAT_CHECK(printf,1,2) NONRET; void opt_help(const struct opt_section * sec); void opt_handle_help(struct opt_item * opt, const char * value, void * data); -// FIXME: Should this be public? -static inline void opt_usage(void) { - fprintf(stderr, "Run with argument --help for more information.\n"); -} - /** * Parse all arguments, given in a NULL-terminated array of strings. * diff --git a/ucw/opt.t b/ucw/opt.t index 4d4f7f58..26c9ab37 100644 --- a/ucw/opt.t +++ b/ucw/opt.t @@ -4,7 +4,7 @@ Name: Opt-1 Run: ../obj/ucw/opt-test 2>&1 1>/dev/null Exit: 2 Out: Required option -t/--temperature not found. - Run with argument --help for more information. + Run with --help for more information. Name: Opt-2 Run: ../obj/ucw/opt-test -t95C -w640 -gG darjeeling @@ -22,7 +22,7 @@ Name: Opt-5 Run: ../obj/ucw/opt-test -ghx 2>&1 1>/dev/null Exit: 2 Out: Multiple switches: -h - Run with argument --help for more information. + Run with --help for more information. Name: Opt-6 Run: ../obj/ucw/opt-test -t120F -w4 -b15 -he -- --puerh darjeeling earl-grey @@ -36,7 +36,7 @@ Name: Opt-Conf-1 Run: ../obj/ucw/opt-test -h -SX.Y=Z 2>&1 1>/dev/null Exit: 2 Out: Config options must stand before other options. - Run with argument --help for more information. + Run with --help for more information. Name: Opt-Hook-1 Run: ../obj/ucw/opt-test -Ht 95C -w640 -gG darjeeling -- 2.39.2