summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2009-09-08 00:50:10 +0400
committerSergey Petrunya <psergey@askmonty.org>2009-09-08 00:50:10 +0400
commit29f0dcb56337a3e352ad7a70dcff6b25bb605325 (patch)
tree84935c21dc958724ae7dcbeeca0c0f08986fc430 /mysys/my_getopt.c
parent915a624cbcb58a10a2cfb2e2e4fd5029191fa86a (diff)
parent8a2454f8e9fce648272577fcf8006ae6e6806cf9 (diff)
downloadmariadb-git-29f0dcb56337a3e352ad7a70dcff6b25bb605325.tar.gz
Merge MySQL->MariaDB
* Finished Monty and Jani's merge * Some InnoDB tests still fail (because it's old xtradb code run against newer testsuite). They are expected to go after mergning with the latest xtradb.
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 0de80b01c4f..e57c1d71a13 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -20,6 +20,7 @@
#include <mysys_err.h>
#include <my_getopt.h>
#include <errno.h>
+#include <m_string.h>
typedef void (*init_func_p)(const struct my_option *option, uchar* *variable,
longlong value);
@@ -409,7 +410,8 @@ invalid value '%s'",
argument= optend;
}
else if (optp->arg_type == OPT_ARG &&
- (optp->var_type & GET_TYPE_MASK) == GET_BOOL)
+ (((optp->var_type & GET_TYPE_MASK) == GET_BOOL) ||
+ (optp->var_type & GET_TYPE_MASK) == GET_ENUM))
{
if (optend == disabled_my_option)
*((my_bool*) value)= (my_bool) 0;
@@ -647,8 +649,18 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument,
return EXIT_OUT_OF_MEMORY;
break;
case GET_ENUM:
- if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
- return EXIT_ARGUMENT_INVALID;
+ if (((*(ulong *)result_pos)=
+ find_type(argument, opts->typelib, 2) - 1) < 0)
+ {
+ /*
+ Accept an integer representation of the enumerated item.
+ */
+ char *endptr;
+ unsigned int arg= (unsigned int) strtol(argument, &endptr, 10);
+ if (*endptr || arg >= opts->typelib->count)
+ return EXIT_ARGUMENT_INVALID;
+ *(int*)result_pos= arg;
+ }
break;
case GET_SET:
*((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err);