mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
- 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.
This commit is contained in:
@ -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));
|
||||
|
Reference in New Issue
Block a user