summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2005-09-06 20:19:49 +0300
committerunknown <jani@ua141d10.elisa.omakaista.fi>2005-09-06 20:19:49 +0300
commit87544d67ccb11f163db3ec2d729bc73d5d36c6a1 (patch)
treee43ab1c5f7166bf25b567a6c988201fe1aa7a94a /mysys/my_getopt.c
parent94c98b516aab22f13f2c5fb4a86546edd201eeba (diff)
downloadmariadb-git-87544d67ccb11f163db3ec2d729bc73d5d36c6a1.tar.gz
Added possibility to use string values 'true' and 'false' case
insensitively with boolean options. Added a warning if given value is invalid and skips the option handling in that case.
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 68bf65b2abe..e9e20fe4024 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -342,11 +342,23 @@ int handle_options(int *argc, char ***argv,
--enable-'option-name'.
*optend was set to '0' if one used --disable-option
*/
- my_bool tmp= (my_bool) (!optend || *optend == '1');
- *((my_bool*) value)= tmp;
(*argc)--;
+ if (!optend || *optend == '1' ||
+ !my_strcasecmp(&my_charset_latin1, optend, "true"))
+ *((my_bool*) value)= (my_bool) 1;
+ else if (*optend == '0' ||
+ !my_strcasecmp(&my_charset_latin1, optend, "false"))
+ *((my_bool*) value)= (my_bool) 0;
+ else
+ {
+ my_getopt_error_reporter(WARNING_LEVEL,
+ "%s: ignoring option '--%s' due to \
+invalid value '%s'\n",
+ my_progname, optp->name, optend);
+ continue;
+ }
get_one_option(optp->id, optp,
- tmp ? (char*) "1" : disabled_my_option);
+ value ? (char*) "1" : disabled_my_option);
continue;
}
argument= optend;