summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2009-12-11 12:39:38 +0300
committerAlexander Nozdrin <alik@sun.com>2009-12-11 12:39:38 +0300
commit69cfd5c8ecd20bca0e651efcbb8b5affc24c1af4 (patch)
tree965519a5b0af3f33624c7e16fd61b58d15f42372 /mysys/my_getopt.c
parent713ed2d2438dd0e5aecf8ea5138d0ca97c3bc519 (diff)
parent2757eab5444982e9375f77d9bca52992f55cc565 (diff)
downloadmariadb-git-69cfd5c8ecd20bca0e651efcbb8b5affc24c1af4.tar.gz
Manual merge from mysql-trunk.
Conflicts: - client/mysqltest.cc - mysql-test/collections/default.experimental - mysql-test/suite/rpl/t/disabled.def - sql/mysqld.cc - sql/opt_range.cc - sql/sp.cc - sql/sql_acl.cc - sql/sql_partition.cc - sql/sql_table.cc
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index e561d74f4d1..d24f328cdf0 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -121,6 +121,7 @@ int handle_options(int *argc, char ***argv,
const struct my_option *optp;
uchar* *value;
int error, i;
+ my_bool is_cmdline_arg= 1;
LINT_INIT(opt_found);
/* handle_options() assumes arg0 (program name) always exists */
@@ -130,10 +131,34 @@ int handle_options(int *argc, char ***argv,
(*argv)++; /* --- || ---- */
init_variables(longopts, init_one_value);
+ /*
+ Search for args_separator, if found, then the first part of the
+ arguments are loaded from configs
+ */
+ for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
+ {
+ if (*pos == args_separator)
+ {
+ is_cmdline_arg= 0;
+ break;
+ }
+ }
+
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
{
char **first= pos;
char *cur_arg= *pos;
+ if (!is_cmdline_arg && (cur_arg == args_separator))
+ {
+ is_cmdline_arg= 1;
+
+ /* save the separator too if skip unkown options */
+ if (my_getopt_skip_unknown)
+ (*argv)[argvpos++]= cur_arg;
+ else
+ (*argc)--;
+ continue;
+ }
if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */
{
char *argument= 0;
@@ -426,8 +451,12 @@ invalid value '%s'",
}
else if (optp->arg_type == REQUIRED_ARG && !optend)
{
- /* Check if there are more arguments after this one */
- if (!*++pos)
+ /* 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'.
+ */
+ if (!is_cmdline_arg || !*++pos)
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,