diff options
author | unknown <jani@rhols221.adsl.netsonic.fi> | 2004-01-14 04:58:37 +0200 |
---|---|---|
committer | unknown <jani@rhols221.adsl.netsonic.fi> | 2004-01-14 04:58:37 +0200 |
commit | 7eea262321ed50eba83fa3369c9071f48a1e4757 (patch) | |
tree | 073ae6869c6c4398cc8f0ca203208a182a0dd736 /mysys/my_getopt.c | |
parent | 38a87d0eea0559101c683907db267d5cc1c7ef04 (diff) | |
download | mariadb-git-7eea262321ed50eba83fa3369c9071f48a1e4757.tar.gz |
- Added missing documentation to some mysql.cc options.
- Fixed Bug#2346
- Fixed Bug#2378
- Fixed bug in pager (no Bug#ID (?))
- Added support for new special situations option type, GET_DISABLED.
See handling of --debug in mysql.cc. compiled wihtout debugging, as an
example.
client/mysql.cc:
- Added missing documentation to some options.
- Fixed a bug in pager (no Bug#ID found (?)), but reported on internals list
with subject "[PATCH] Fix pager problems in mysql client"
- Fixed Bug#2346, "unique prefix is enough" option behaviour can be confusing with --debug
include/my_getopt.h:
Added new option type, GET_DISABLED.
include/mysys_err.h:
New exit code for my_getopt.
mysys/my_getopt.c:
- Added handling for GET_DISABLED option type (Fix for Bug#2346)
- Fixed Bug#2378, "Problem with option abbreviation"
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r-- | mysys/my_getopt.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 76f8f6bf852..b278eaa36e1 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -285,6 +285,19 @@ int handle_options(int *argc, char ***argv, return EXIT_AMBIGUOUS_OPTION; } } + if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) + { + if (my_getopt_print_errors) + fprintf(stderr, + "%s: %s: Option '%s' used, but is disabled\n", my_progname, + option_is_loose ? "WARNING" : "ERROR", opt_str); + if (option_is_loose) + { + (*argc)--; + continue; + } + return EXIT_OPTION_DISABLED; + } if (must_be_var && (optp->var_type & GET_TYPE_MASK) == GET_NO_ARG) { if (my_getopt_print_errors) @@ -358,6 +371,14 @@ int handle_options(int *argc, char ***argv, { /* Option recognized. Find next what to do with it */ opt_found= 1; + if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED) + { + if (my_getopt_print_errors) + fprintf(stderr, + "%s: ERROR: Option '-%c' used, but is disabled\n", + my_progname, optp->id); + return EXIT_OPTION_DISABLED; + } if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL && optp->arg_type == NO_ARG) { @@ -550,7 +571,7 @@ static int findopt(char *optpat, uint length, const struct my_option **opt_res, char **ffname) { - int count; + uint count; struct my_option *opt= (struct my_option *) *opt_res; for (count= 0; opt->name; opt++) @@ -562,7 +583,8 @@ static int findopt(char *optpat, uint length, *ffname= (char *) opt->name; /* We only need to know one prev */ if (!opt->name[length]) /* Exact match */ return 1; - count++; + if (!count || strcmp(*ffname, opt->name)) /* Don't count synonyms */ + count++; } } return count; @@ -882,7 +904,8 @@ void my_print_variables(const struct my_option *options) longlong2str(*((ulonglong*) value), buff, 10); printf("%s\n", buff); break; - default: /* dummy default to avoid compiler warnings */ + default: + printf("(Disabled)\n"); break; } } |