diff options
author | unknown <jani@rhols221.adsl.netsonic.fi> | 2002-05-14 21:41:55 +0300 |
---|---|---|
committer | unknown <jani@rhols221.adsl.netsonic.fi> | 2002-05-14 21:41:55 +0300 |
commit | 21c1e5be444f61c96351ff7d27e955356a65c7d6 (patch) | |
tree | 4ab693251c296105301806199ac0d1ee72bdf62f /mysys/my_getopt.c | |
parent | f20dda3ea9c36589955b85abcff5bea5bb534330 (diff) | |
download | mariadb-git-21c1e5be444f61c96351ff7d27e955356a65c7d6.tar.gz |
- Added new type GET_STRALC to my_getopt.
- Fixed some bugs, wrongly freed pointers, in some clients.
- Removed unneccessary code.
- Fixed some other minor bugs and added some options into
variables category, which had accidently been left out earlier.
client/mysql.cc:
Fixed some wrong freed pointers. Removed unneccessary code.
Changed some types from GET_STR to GET_STRALC.
client/mysqladmin.c:
Fixed some wrong freed pointers. Removed unneccessary code.
Changed some types from GET_STR to GET_STRALC.
client/mysqlcheck.c:
Fixed some wrong freed pointers. Removed unneccessary code.
Changed some types from GET_STR to GET_STRALC.
client/mysqldump.c:
Fixed some wrong freed pointers. Removed unneccessary code.
Changed some types from GET_STR to GET_STRALC.
client/mysqlimport.c:
Removed unneccessary code.
Fixed a bug in option --ignore-lines
client/mysqlshow.c:
Removed unneccessary code.
include/my_getopt.h:
Added new type, GET_STRALC. The name stands for GET STRING ALLOC,
which means that the struct member value and u_max_value are
strings that must be alloced and freed when used.
The normal GET_STR works similarly otherwise, except that it's
arguments are just pointers to strings, not alloced ones.
mysys/my_getopt.c:
Added support for GET_STRALC
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r-- | mysys/my_getopt.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 9b516559936..d6aebbe4f75 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -19,6 +19,7 @@ #include <stdlib.h> #include <my_getopt.h> #include <assert.h> +#include <my_sys.h> static int findopt (char *optpat, uint length, const struct my_option **opt_res, @@ -423,6 +424,12 @@ static int setval (const struct my_option *opts, char *argument, *((ulonglong*) result_pos)= getopt_ull(argument, opts, &err); else if (opts->var_type == GET_STR) *((char**) result_pos)= argument; + else if (opts->var_type == GET_STRALC) + { + if ((*((char**) result_pos))) + my_free((*(char**) result_pos), MYF(MY_ALLOW_ZERO_PTR)); + *((char**) result_pos)= my_strdup(argument, MYF(MY_WME)); + } if (err) return ERR_UNKNOWN_SUFFIX; } @@ -627,7 +634,7 @@ void my_print_help(const struct my_option *options) } printf("--%s", optp->name); col+= 2 + strlen(optp->name); - if (optp->var_type == GET_STR) + if (optp->var_type == GET_STR || optp->var_type == GET_STRALC) { printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "", optp->arg_type == OPT_ARG ? "]" : ""); @@ -694,7 +701,7 @@ void my_print_variables(const struct my_option *options) length= strlen(optp->name); for (; length < name_space; length++) putchar(' '); - if (optp->var_type == GET_STR) + if (optp->var_type == GET_STR || optp->var_type == GET_STRALC) { if (*((char**) optp->value)) printf("%s\n", *((char**) optp->value)); |