diff options
-rw-r--r-- | client/mysqlbinlog.cc | 3 | ||||
-rw-r--r-- | client/mysqlmanager-pwgen.c | 3 | ||||
-rw-r--r-- | client/mysqlmanagerc.c | 4 | ||||
-rw-r--r-- | client/mysqltest.c | 4 | ||||
-rw-r--r-- | myisam/myisamchk.c | 3 | ||||
-rw-r--r-- | mysys/my_getopt.c | 150 |
6 files changed, 79 insertions, 88 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index a213f328cb5..04162faab8f 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -125,7 +125,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 2.0 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 2.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -141,7 +141,6 @@ Dumps a MySQL binary log in a format usable for viewing or for pipeing to\n\ the mysql command line client\n\n"); printf("Usage: %s [options] log-files\n", my_progname); my_print_help(my_long_options); - putchar('\n'); my_print_variables(my_long_options); } diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c index db8436c876c..fef5cdf6661 100644 --- a/client/mysqlmanager-pwgen.c +++ b/client/mysqlmanager-pwgen.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define MANAGER_PWGEN_VERSION "1.1" +#define MANAGER_PWGEN_VERSION "1.2" #include <my_global.h> #include <m_ctype.h> @@ -72,7 +72,6 @@ void usage() printf("Generates a password file to be used by mysqltest.\n\n"); printf("Usage: %s [OPTIONS]\n", my_progname); my_print_help(my_long_options); - putchar('\n'); my_print_variables(my_long_options); } diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c index 4acd33cf18a..82b70ed1b44 100644 --- a/client/mysqlmanagerc.c +++ b/client/mysqlmanagerc.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define MANAGER_CLIENT_VERSION "1.2" +#define MANAGER_CLIENT_VERSION "1.3" #include <my_global.h> #include <mysql.h> @@ -93,7 +93,7 @@ void usage() printf("Command-line client for MySQL manager daemon.\n\n"); printf("Usage: %s [OPTIONS] < command_file\n", my_progname); my_print_help(my_long_options); - printf(" --no-defaults Don't read default options from any options file.\n\n"); + printf(" --no-defaults Don't read default options from any options file.\n"); my_print_variables(my_long_options); } diff --git a/client/mysqltest.c b/client/mysqltest.c index 7c20d9bca7b..513c0add776 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -42,7 +42,7 @@ **********************************************************************/ -#define MTEST_VERSION "1.20" +#define MTEST_VERSION "1.21" #include <my_global.h> #include <mysql_embed.h> @@ -1873,7 +1873,7 @@ void usage() printf("Runs a test against the mysql server and compares output with a results file.\n\n"); printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname); my_print_help(my_long_options); - printf(" --no-defaults Don't read default options from any options file.\n\n"); + printf(" --no-defaults Don't read default options from any options file.\n"); my_print_variables(my_long_options); } diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 952e91e6c6e..0cd3e5f3139 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -292,7 +292,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, + printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -380,7 +380,6 @@ static void usage(void) (It may be VERY slow to do a sort the first time!)"); print_defaults("my", load_default_groups); - putchar('\n'); my_print_variables(my_long_options); } diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index b5b98a8ba9a..11b60c8da36 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -283,7 +283,7 @@ int handle_options(int *argc, char ***argv, */ *((my_bool*) optp->value)= (my_bool) (!optend || *optend == '1'); (*argc)--; - continue; + continue; // For GET_BOOL get_one_option() shouldn't be called } argument= optend; } @@ -330,7 +330,7 @@ int handle_options(int *argc, char ***argv, { *((my_bool*) optp->value)= (my_bool) 1; (*argc)--; - continue; + continue; // For GET_BOOL get_one_option() shouldn't be called } else if (optp->arg_type == REQUIRED_ARG || optp->arg_type == OPT_ARG) @@ -414,23 +414,33 @@ static int setval (const struct my_option *opts, char *argument, if (!result_pos) return ERR_NO_PTR_TO_VARIABLE; - if (opts->var_type == GET_INT || opts->var_type == GET_UINT) + switch (opts->var_type) { + case GET_INT: + case GET_UINT: /* fall through */ *((int*) result_pos)= (int) getopt_ll(argument, opts, &err); - else if (opts->var_type == GET_LONG || opts->var_type == GET_ULONG) + break; + case GET_LONG: + case GET_ULONG: /* fall through */ *((long*) result_pos)= (long) getopt_ll(argument, opts, &err); - else if (opts->var_type == GET_LL) + break; + case GET_LL: *((longlong*) result_pos)= getopt_ll(argument, opts, &err); - else if (opts->var_type == GET_ULL) + break; + case GET_ULL: *((ulonglong*) result_pos)= getopt_ull(argument, opts, &err); - else if (opts->var_type == GET_STR) + break; + case GET_STR: *((char**) result_pos)= argument; - else if (opts->var_type == GET_STR_ALLOC) - { + break; + case GET_STR_ALLOC: if ((*((char**) result_pos))) my_free((*(char**) result_pos), MYF(MY_WME | MY_FAE)); if (!(*((char**) result_pos)= my_strdup(argument, MYF(MY_WME)))) return ERR_OUT_OF_MEMORY; + break; + default: /* dummy default to avoid compiler warnings */ + break; } if (err) return ERR_UNKNOWN_SUFFIX; @@ -587,27 +597,38 @@ static void init_variables(const struct my_option *options) { if (options->value) { - if (options->var_type == GET_INT) + switch (options->var_type) { + case GET_BOOL: + *((my_bool*) options->u_max_value)= *((my_bool*) options->value)= + (my_bool) options->def_value; + break; + case GET_INT: *((int*) options->u_max_value)= *((int*) options->value)= (int) options->def_value; - else if (options->var_type == GET_UINT) + break; + case GET_UINT: *((uint*) options->u_max_value)= *((uint*) options->value)= (uint) options->def_value; - else if (options->var_type == GET_BOOL) - *((my_bool*) options->u_max_value)= *((my_bool*) options->value)= - (my_bool) options->def_value; - else if (options->var_type == GET_LONG) + break; + case GET_LONG: *((long*) options->u_max_value)= *((long*) options->value)= (long) options->def_value; - else if (options->var_type == GET_ULONG) + break; + case GET_ULONG: *((ulong*) options->u_max_value)= *((ulong*) options->value)= (ulong) options->def_value; - else if (options->var_type == GET_LL) + break; + case GET_LL: *((longlong*) options->u_max_value)= *((longlong*) options->value)= (longlong) options->def_value; - else if (options->var_type == GET_ULL) + break; + case GET_ULL: *((ulonglong*) options->u_max_value)= *((ulonglong*) options->value)= (ulonglong) options->def_value; + break; + default: /* dummy default to avoid compiler warnings */ + break; + } } } } @@ -696,8 +717,9 @@ void my_print_variables(const struct my_option *options) char buff[255]; const struct my_option *optp; - printf("Variables (--variable-name=value) Default value\n"); - printf("--------------------------------- -------------\n"); + printf("\nVariables (--variable-name=value)\n"); + printf("and boolean options {FALSE|TRUE} Value (after reading options)\n"); + printf("--------------------------------- -----------------------------\n"); for (optp= options; optp->id; optp++) { if (optp->value) @@ -706,64 +728,36 @@ 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 || optp->var_type == GET_STR_ALLOC) - { - if (*((char**) optp->value)) - printf("%s\n", *((char**) optp->value)); - else - printf("(No default value)\n"); - } - else if (optp->var_type == GET_BOOL) - { - if (!optp->def_value && !*((my_bool*) optp->value)) - printf("(No default value)\n"); - else - printf("%d\n", *((my_bool*) optp->value)); - } - else if (optp->var_type == GET_INT) - { - if (!optp->def_value && !*((int*) optp->value)) - printf("(No default value)\n"); - else - printf("%d\n", *((int*) optp->value)); - } - else if (optp->var_type == GET_UINT) - { - if (!optp->def_value && !*((uint*) optp->value)) - printf("(No default value)\n"); - else - printf("%d\n", *((uint*) optp->value)); - } - else if (optp->var_type == GET_LONG) - { - if (!optp->def_value && !*((long*) optp->value)) - printf("(No default value)\n"); - else - printf("%lu\n", *((long*) optp->value)); - } - else if (optp->var_type == GET_ULONG) - { - if (!optp->def_value && !*((ulong*) optp->value)) - printf("(No default value)\n"); - else - printf("%lu\n", *((ulong*) optp->value)); - } - else if (optp->var_type == GET_LL) - { - if (!optp->def_value && !*((longlong*) optp->value)) - printf("(No default value)\n"); - else - printf("%s\n", llstr(*((longlong*) optp->value), buff)); - } - else if (optp->var_type == GET_ULL) - { - if (!optp->def_value && !*((ulonglong*) optp->value)) - printf("(No default value)\n"); - else - { - longlong2str(*((ulonglong*) optp->value), buff, 10); - printf("%s\n", buff); - } + switch (optp->var_type) { + case GET_STR: + case GET_STR_ALLOC: /* fall through */ + printf("%s\n", *((char**) optp->value) ? *((char**) optp->value) : + "(No default value)"); + break; + case GET_BOOL: + printf("%s\n", *((my_bool*) optp->value) ? "TRUE" : "FALSE"); + break; + case GET_INT: + printf("%d\n", *((int*) optp->value)); + break; + case GET_UINT: + printf("%d\n", *((uint*) optp->value)); + break; + case GET_LONG: + printf("%lu\n", *((long*) optp->value)); + break; + case GET_ULONG: + printf("%lu\n", *((ulong*) optp->value)); + break; + case GET_LL: + printf("%s\n", llstr(*((longlong*) optp->value), buff)); + break; + case GET_ULL: + longlong2str(*((ulonglong*) optp->value), buff, 10); + printf("%s\n", buff); + break; + default: /* dummy default to avoid compiler warnings */ + break; } } } |