Commit 3e569727 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: unify --defaults* option handling

process all --defaults* options uniformly,
get rid of special case for --no-defaults and --print-defaults
use realpath instead of blindly concatenating pwd and relative path.
parent 3ea51b51
...@@ -146,16 +146,14 @@ int main(int argc, char **argv) ...@@ -146,16 +146,14 @@ int main(int argc, char **argv)
int count, error, args_used; int count, error, args_used;
char **load_default_groups= 0, *tmp_arguments[6]; char **load_default_groups= 0, *tmp_arguments[6];
char **argument, **arguments, **org_argv; char **argument, **arguments, **org_argv;
char *defaults, *extra_defaults, *group_suffix;
int nargs, i= 0; int nargs, i= 0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
org_argv= argv; org_argv= argv;
args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults, args_used= get_defaults_options(argv);
&group_suffix);
/* Copy defaults-xxx arguments & program name */ /* Copy defaults-xxx arguments & program name */
count=args_used+1; count=args_used;
arguments= tmp_arguments; arguments= tmp_arguments;
memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv)); memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv));
arguments[count]= 0; arguments[count]= 0;
......
...@@ -26,9 +26,7 @@ extern const char *my_defaults_file; ...@@ -26,9 +26,7 @@ extern const char *my_defaults_file;
extern my_bool my_getopt_use_args_separator; extern my_bool my_getopt_use_args_separator;
extern my_bool my_getopt_is_args_separator(const char* arg); extern my_bool my_getopt_is_args_separator(const char* arg);
extern int get_defaults_options(int argc, char **argv, extern int get_defaults_options(char **argv);
char **defaults, char **extra_defaults,
char **group_suffix);
extern int my_load_defaults(const char *conf_file, const char **groups, extern int my_load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv, const char ***); int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups, extern int load_defaults(const char *conf_file, const char **groups,
......
...@@ -2,11 +2,11 @@ Could not open required defaults file: /path/with/no/extension ...@@ -2,11 +2,11 @@ Could not open required defaults file: /path/with/no/extension
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
Could not open required defaults file: /path/with.ext Could not open required defaults file: /path/with.ext
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
Could not open required defaults file: MYSQL_TEST_DIR/relative/path/with.ext Could not open required defaults file: relative/path/with.ext
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
Could not open required defaults file: MYSQL_TEST_DIR/relative/path/without/extension Could not open required defaults file: relative/path/without/extension
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
Could not open required defaults file: MYSQL_TEST_DIR/with.ext Could not open required defaults file: with.ext
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
Could not open required defaults file: MYSQL_TEST_DIR/no_extension Could not open required defaults file: no_extension
Fatal error in defaults handling. Program aborted Fatal error in defaults handling. Program aborted
...@@ -13,19 +13,15 @@ exec $MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1; ...@@ -13,19 +13,15 @@ exec $MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1;
--error 1 --error 1
exec $MYSQLD --defaults-file=/path/with.ext --print-defaults 2>&1; exec $MYSQLD --defaults-file=/path/with.ext --print-defaults 2>&1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--error 1 --error 1
exec $MYSQLD --defaults-file=relative/path/with.ext --print-defaults 2>&1; exec $MYSQLD --defaults-file=relative/path/with.ext --print-defaults 2>&1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--error 1 --error 1
exec $MYSQLD --defaults-file=relative/path/without/extension --print-defaults 2>&1; exec $MYSQLD --defaults-file=relative/path/without/extension --print-defaults 2>&1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--error 1 --error 1
exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1; exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--error 1 --error 1
exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment