summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-05-05 17:05:24 +0300
committerunknown <monty@mysql.com>2004-05-05 17:05:24 +0300
commitcd21f7ce40ac4c7d415544a5b2aa07b1278419ac (patch)
tree3238bd16530e02dbfef96513749a73b7294880f8 /mysys/my_getopt.c
parent575541b9f755425eaeb07babfa07b6fd30f6d5d1 (diff)
parent7d918f213e64df4af4b00d0798fadf9ed1a872fb (diff)
downloadmariadb-git-cd21f7ce40ac4c7d415544a5b2aa07b1278419ac.tar.gz
Merge with 4.0.19
BitKeeper/etc/logging_ok: auto-union VC++Files/client/mysqlclient.dsp: Auto merged VC++Files/mysql.dsw: Auto merged extra/perror.c: Auto merged extra/replace.c: Auto merged innobase/configure.in: Auto merged innobase/include/lock0lock.h: Auto merged innobase/include/row0mysql.h: Auto merged innobase/include/sync0sync.h: Auto merged innobase/lock/lock0lock.c: Auto merged ltmain.sh: Auto merged BitKeeper/deleted/.del-libmysqld.def~8edf7b8780ce943c: Auto merged innobase/os/os0file.c: Auto merged innobase/pars/lexyy.c: Auto merged innobase/row/row0mysql.c: Auto merged innobase/srv/srv0srv.c: Auto merged innobase/srv/srv0start.c: Auto merged innobase/sync/sync0arr.c: Auto merged innobase/sync/sync0sync.c: Auto merged innobase/trx/trx0trx.c: Auto merged mysql-test/r/alias.result: Auto merged mysql-test/t/system_mysql_db_fix-master.opt: Auto merged mysql-test/r/func_time.result: Automatic merge mysql-test/r/innodb.result: Automatic merge mysql-test/t/alias.test: Automatic merge mysql-test/t/create.test: Automatic merge mysql-test/t/func_time.test: Automatic merge sql/ha_innodb.cc: Automatic merge sql/mysql_priv.h: Automatic merge mysql-test/r/rpl_multi_update.result: Automatic merge mysql-test/t/rpl_error_ignored_table.test: Automatic merge mysql-test/t/rpl_multi_update.test: Automatic merge sql/slave.h: Automatic merge sql/sql_base.cc: Automatic merge sql/sql_db.cc: Automatic merge sql/sql_insert.cc: Automatic merge sql/structs.h: Automatic merge sql/table.cc: Automatic merge strings/longlong2str-x86.s: Automatic merge strings/strings-x86.s: Automatic merge support-files/my-medium.cnf.sh: Automatic merge
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 8a1f6db6f8a..efd5789968c 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -342,8 +342,8 @@ int handle_options(int *argc, char ***argv,
{
if (!optend) /* No argument -> enable option */
*((my_bool*) value)= (my_bool) 1;
- else /* If argument differs from 0, enable option, else disable */
- *((my_bool*) value)= (my_bool) atoi(optend) != 0;
+ else
+ argument= optend;
}
}
else if (optp->arg_type == REQUIRED_ARG && !optend)
@@ -398,18 +398,25 @@ int handle_options(int *argc, char ***argv,
/* This is in effect a jump out of the outer loop */
optend= (char*) " ";
}
- else if (optp->arg_type == REQUIRED_ARG)
+ else
{
+ if (optp->arg_type == OPT_ARG)
+ {
+ if (optp->var_type == GET_BOOL)
+ *((my_bool*) optp->value)= (my_bool) 1;
+ get_one_option(optp->id, optp, argument);
+ continue;
+ }
/* Check if there are more arguments after this one */
- if (!*++pos)
+ if (!pos[1])
{
- if (my_getopt_print_errors)
- fprintf(stderr,
- "%s: option '-%c' requires an argument\n",
- my_progname, optp->id);
- return EXIT_ARGUMENT_REQUIRED;
+ if (my_getopt_print_errors)
+ fprintf(stderr,
+ "%s: option '-%c' requires an argument\n",
+ my_progname, optp->id);
+ return EXIT_ARGUMENT_REQUIRED;
}
- argument= *pos;
+ argument= *++pos;
(*argc)--;
/* the other loop will break, because *optend + 1 == 0 */
}
@@ -525,6 +532,9 @@ static int setval(const struct my_option *opts, gptr *value, char *argument,
return EXIT_NO_PTR_TO_VARIABLE;
switch ((opts->var_type & GET_TYPE_MASK)) {
+ case GET_BOOL: /* If argument differs from 0, enable option, else disable */
+ *((my_bool*) result_pos)= (my_bool) atoi(argument) != 0;
+ break;
case GET_INT:
case GET_UINT: /* fall through */
*((int*) result_pos)= (int) getopt_ll(argument, opts, &err);