From: Kristofer Pettersson Date: October 25 2010 12:30pm Subject: bzr commit into mysql-5.5-bugteam branch (kristofer.pettersson:3095) Bug#54569 List-Archive: http://lists.mysql.com/commits/121804 X-Bug: 54569 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1755588179536801029==" --===============1755588179536801029== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/thek/bzr/mysql-5.5-bugteam/ based on revid:bar@stripped 3095 Kristofer Pettersson 2010-10-25 Bug#54569 Some options are not allowed to take argument when passed with loose- prefix Boolean options cause parsing failures when they are given with prefix loose- and an argument, either in the command line or in configuration file. The reason was a faulty logic which forced the parsing to throw an error when an argument of type NO_ARG was used together with an argument which has been identified as a key-value pair. Despite the attribute NO_ARG these options actually take arguments if they are of type BOOL. @ include/my_getopt.h * More comments to help future refactoring @ mysys/my_getopt.c * removed if-statement which prevented logic for handling boolean types with arguments to be executed. * Added comments to aid in future refactoring. modified: include/my_getopt.h mysys/my_getopt.c === modified file 'include/my_getopt.h' --- a/include/my_getopt.h 2010-06-11 01:30:49 +0000 +++ b/include/my_getopt.h 2010-10-25 12:30:07 +0000 @@ -39,6 +39,13 @@ C_MODE_START #define GET_ASK_ADDR 128 #define GET_TYPE_MASK 127 +/** + Enumeration of the my_option::arg_type attributes. + It should be noted that for historical reasons variables with the combination + arg_type=NO_ARG, my_option::var_type=GET_BOOL still accepts + arguments. This is someone counter intuitive and care should be taken + if the code is refactored. +*/ enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; struct st_typelib; === modified file 'mysys/my_getopt.c' --- a/mysys/my_getopt.c 2010-09-28 15:15:58 +0000 +++ b/mysys/my_getopt.c 2010-10-25 12:30:07 +0000 @@ -360,14 +360,6 @@ int handle_options(int *argc, char ***ar } return EXIT_OPTION_DISABLED; } - if (must_be_var && optp->arg_type == NO_ARG) - { - if (my_getopt_print_errors) - my_getopt_error_reporter(ERROR_LEVEL, - "%s: option '%s' cannot take an argument", - my_progname, optp->name); - return EXIT_NO_ARGUMENT_ALLOWED; - } error= 0; value= optp->var_type & GET_ASK_ADDR ? (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) : @@ -377,6 +369,11 @@ int handle_options(int *argc, char ***ar if (optp->arg_type == NO_ARG) { + /* + Due to historical reasons GET_BOOL var_types still accepts arguments + despite the NO_ARG arg_type attribute. This can seems a bit unintuitive + and care should be taken when refactoring this code. + */ if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL) { if (my_getopt_print_errors) @@ -391,7 +388,7 @@ int handle_options(int *argc, char ***ar Set bool to 1 if no argument or if the user has used --enable-'option-name'. *optend was set to '0' if one used --disable-option - */ + */ (*argc)--; if (!optend || *optend == '1' || !my_strcasecmp(&my_charset_latin1, optend, "true")) @@ -418,10 +415,9 @@ int handle_options(int *argc, char ***ar else if (optp->arg_type == REQUIRED_ARG && !optend) { /* Check if there are more arguments after this one, - - Note: options loaded from config file that requires value - should always be in the form '--option=value'. - */ + Note: options loaded from config file that requires value + should always be in the form '--option=value'. + */ if (!is_cmdline_arg || !*++pos) { if (my_getopt_print_errors) --===============1755588179536801029== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/kristofer.pettersson@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kristofer.pettersson@stripped\ # by58sn2aouyqrjj2 # target_branch: file:///home/thek/bzr/mysql-5.5-bugteam/ # testament_sha1: 56363eeff8307cfeeabc5c5735e1ce1a6780b389 # timestamp: 2010-10-25 14:30:09 +0200 # base_revision_id: bar@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWRO0MqoAAs5fgEgwWPf/93av 3AC////wYAevvD3c9UNZ7tK57t3u7t1zHZbU6ThJKNJp6mEaGIA1PST000am9INQDTQAJJAhppMj E1TJ6mg2pkwQaMgAZG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