summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorjani@rhols221.adsl.netsonic.fi <>2003-06-30 15:49:29 +0300
committerjani@rhols221.adsl.netsonic.fi <>2003-06-30 15:49:29 +0300
commit1c38e1790aa107049708f35db5ecb892650e6296 (patch)
tree860a354bb1010a2a183e753d817fa2878ec62eb9 /mysys/my_getopt.c
parent7c799b17b6e8d29ed095c4371302b315e958ad7e (diff)
downloadmariadb-git-1c38e1790aa107049708f35db5ecb892650e6296.tar.gz
Made check for structured option handling more robust and faster.
Earlier it could have failed in some special cases.
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 07f4f306198..83ba8b98843 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -458,17 +458,19 @@ int handle_options(int *argc, char ***argv,
static char *check_struct_option(char *cur_arg, char *key_name)
{
- char *ptr, *ptr2;
+ char *ptr, *end;
- ptr= strcend(cur_arg, '.');
- ptr2= strcend(cur_arg, '=');
+ ptr= strcend(cur_arg + 1, '.'); // Skip the first character
+ end= strcend(cur_arg, '=');
/*
- Minimum length for a struct option is 3 (--a.b)
- If the (first) dot is after an equal sign, then it is part
+ If the first dot is after an equal sign, then it is part
of a variable value and the option is not a struct option.
+ Also, if the last character in the string before the ending
+ NULL, or the character right before equal sign is the first
+ dot found, the option is not a struct option.
*/
- if (strlen(ptr) >= 3 && ptr2 - ptr > 0)
+ if (end - ptr > 1)
{
uint len= ptr - cur_arg;
strnmov(key_name, cur_arg, len);