]> mj.ucw.cz Git - libucw.git/commitdiff
Opt: opt_failure() is public, opt_usage() not so
authorMartin Mares <mj@ucw.cz>
Mon, 27 Jan 2014 19:28:16 +0000 (20:28 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 27 Jan 2014 19:28:16 +0000 (20:28 +0100)
tools/libucw.api
ucw/opt-internal.h
ucw/opt.c
ucw/opt.h
ucw/opt.t

index 80b2472ad6f154f461abcdec23462157d7d9cf52..2d48c08d584105fb0abeddb8a370abdba49b18a2 100644 (file)
@@ -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
index 05694ca5d8bc5a78af3c8111eb35b235da5c1781..54717b3952addc13425795ec05c1d3dd9a404d9d 100644 (file)
@@ -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
index f7bae0d847c314c0ae0ebc1b3cfc948ea0068fb6..bba273c4d729ec378790c28b5c5e5708d7065564 100644 (file)
--- 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);
 }
 
index 25db7d45cd8b7190be391840d8b92674881ef18e..aa9166e98d48e5e9a9b155a205b5651a9f28f3c2 100644 (file)
--- 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.
  *
index 4d4f7f58b7688f7b2a9db0b2b18631a9355bf18e..26c9ab371384a8d9c6bf4ef9065a6bf66544e10d 100644 (file)
--- 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