Skip to content

Commit

Permalink
Improve --help and remove not-free warnings for mysql_tzinfo_to_sql
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi committed Jan 20, 2022
1 parent 9d4c0a6 commit d3143ef
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions sql/tztime.cc
Expand Up @@ -2630,24 +2630,33 @@ static struct my_option my_long_options[] =
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit",
{"debug", '#', "This is a non-debug version. Catch this and exit.",
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"leap", 'l', "Print the leap second information from the given time zone file. By convention, when --leap is used the next argument is the timezonefile",
{"leap", 'l', "Print the leap second information from the given time zone file. By convention, when --leap is used the next argument is the timezonefile.",
&opt_leap, &opt_leap, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Write non critical warnings",
{"verbose", 'v', "Write non critical warnings.",
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster",
{"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster.",
&opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};


static char **default_argv;

static void free_allocated_data()
{
free_defaults(default_argv);
my_end(0);
}


C_MODE_START
static my_bool get_one_option(int optid, const struct my_option *,
char *argument);
Expand All @@ -2659,11 +2668,21 @@ static void print_version(void)
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}

static const char *default_timezone_dir= "/usr/share/zoneinfo/";


static void print_usage(void)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, " %s [options] timezonedir\n", my_progname);
fprintf(stderr, " %s [options] timezonefile timezonename\n", my_progname);
fprintf(stdout, "Create SQL commands for loading system timezeone data for "
"MariaDB\n\n");
fprintf(stdout, "Usage:\n");
fprintf(stdout, " %s [options] timezonedir\n", my_progname);
fprintf(stdout, "or\n");
fprintf(stdout, " %s [options] timezonefile timezonename\n", my_progname);

fprintf(stdout, "\nA typical place for the system timezone directory is "
"\"%s\"\n", default_timezone_dir);

print_defaults("my",load_default_groups);
puts("");
my_print_help(my_long_options);
Expand All @@ -2684,9 +2703,11 @@ get_one_option(int optid, const struct my_option *opt, char *argument)
print_version();
puts("");
print_usage();
free_allocated_data();
exit(0);
case 'V':
print_version();
free_allocated_data();
exit(0);
}
return 0;
Expand All @@ -2696,7 +2717,6 @@ get_one_option(int optid, const struct my_option *opt, char *argument)
int
main(int argc, char **argv)
{
char **default_argv;
MY_INIT(argv[0]);

load_defaults_or_exit("my", load_default_groups, &argc, &argv);
Expand All @@ -2708,7 +2728,7 @@ main(int argc, char **argv)
if ((argc != 1 && argc != 2) || (opt_leap && argc != 1))
{
print_usage();
free_defaults(default_argv);
free_allocated_data();
return 1;
}

Expand Down

0 comments on commit d3143ef

Please sign in to comment.