diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-10-19 15:58:35 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-10-19 15:58:35 +0200 |
commit | 745cc74c3301f193c7b82c31d11c3bf0c842be9e (patch) | |
tree | 4aa6101c051c91607d2623eed26fb41527fd0bd3 /mysys/my_getopt.c | |
parent | f0c6576b85a57ec82fd911f73cce7c99683b378c (diff) | |
parent | cc6d22f5356e0969d8d5d1046edc69cb17ea19fb (diff) | |
download | mariadb-git-745cc74c3301f193c7b82c31d11c3bf0c842be9e.tar.gz |
5.1.51 merge
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r-- | mysys/my_getopt.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 80b355ea69a..f9a2c17ae7c 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -658,18 +658,21 @@ static int setval(const struct my_option *opts, void *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - pos= find_type(argument, opts->typelib, 2) - 1; - (*(ulong *)result_pos)= pos; - if (pos < 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; + int type= find_type(argument, opts->typelib, 2); + if (type < 1) + { + /* + Accept an integer representation of the enumerated item. + */ + char *endptr; + ulong arg= strtoul(argument, &endptr, 10); + if (*endptr || arg >= opts->typelib->count) + return EXIT_ARGUMENT_INVALID; + *((ulong*) result_pos)= arg; + } + else + *((ulong*) result_pos)= type - 1; } break; case GET_SET: @@ -1006,7 +1009,7 @@ static void init_one_value(const struct my_option *option, void *variable, *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; case GET_ENUM: - *((ulong*) variable)= (uint) value; + *((ulong*) variable)= (ulong) value; break; case GET_UINT: *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); |