Commit 71924aaa authored by unknown's avatar unknown

Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-4.0

into a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.0

parents 3170761e 57ec8b2e
...@@ -47,6 +47,7 @@ hf@genie.(none) ...@@ -47,6 +47,7 @@ hf@genie.(none)
igor@hundin.mysql.fi igor@hundin.mysql.fi
igor@rurik.mysql.com igor@rurik.mysql.com
ingo@mysql.com ingo@mysql.com
jani@a193-229-222-105.elisa-laajakaista.fi
jani@a80-186-24-72.elisa-laajakaista.fi jani@a80-186-24-72.elisa-laajakaista.fi
jani@a80-186-41-201.elisa-laajakaista.fi jani@a80-186-41-201.elisa-laajakaista.fi
jani@dsl-jkl1657.dial.inet.fi jani@dsl-jkl1657.dial.inet.fi
......
...@@ -60,11 +60,7 @@ DATADIR, ...@@ -60,11 +60,7 @@ DATADIR,
NullS, NullS,
}; };
#define default_ext ".cnf" /* extension for config file */ static const char *f_extensions[]= { ".ini", ".cnf", 0 };
#ifdef __WIN__
#include <winbase.h>
#define windows_ext ".ini"
#endif
static int search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc, static int search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc,
const char *dir, const char *config_file, const char *dir, const char *config_file,
...@@ -115,7 +111,8 @@ int load_defaults(const char *conf_file, const char **groups, ...@@ -115,7 +111,8 @@ int load_defaults(const char *conf_file, const char **groups,
uint args_used=0; uint args_used=0;
int error= 0; int error= 0;
MEM_ROOT alloc; MEM_ROOT alloc;
char *ptr,**res; char *ptr, **res, **ext;
DBUG_ENTER("load_defaults"); DBUG_ENTER("load_defaults");
init_alloc_root(&alloc,512,0); init_alloc_root(&alloc,512,0);
...@@ -169,38 +166,43 @@ int load_defaults(const char *conf_file, const char **groups, ...@@ -169,38 +166,43 @@ int load_defaults(const char *conf_file, const char **groups,
} }
else if (dirname_length(conf_file)) else if (dirname_length(conf_file))
{ {
if ((error= search_default_file(&args, &alloc, NullS, conf_file, for (ext= (char**) f_extensions; *ext; *ext++)
default_ext, &group)) < 0) if ((error= search_default_file(&args, &alloc, NullS, conf_file,
goto err; *ext, &group)) < 0)
goto err;
} }
else else
{ {
#ifdef __WIN__ #ifdef __WIN__
char system_dir[FN_REFLEN]; char system_dir[FN_REFLEN];
GetWindowsDirectory(system_dir,sizeof(system_dir)); GetWindowsDirectory(system_dir,sizeof(system_dir));
if ((search_default_file(&args, &alloc, system_dir, conf_file, for (ext= (char**) f_extensions; *ext; *ext++)
windows_ext, &group))) if ((search_default_file(&args, &alloc, system_dir, conf_file,
goto err; *ext, &group)))
goto err;
#endif #endif
#if defined(__EMX__) || defined(OS2) #if defined(__EMX__) || defined(OS2)
if (getenv("ETC") && for (ext= (char**) f_extensions; *ext; *ext++)
(search_default_file(&args, &alloc, getenv("ETC"), conf_file, if (getenv("ETC") &&
default_ext, &group)) < 0) (search_default_file(&args, &alloc, getenv("ETC"), conf_file,
goto err; *ext, &group)) < 0)
goto err;
#endif #endif
for (dirs=default_directories ; *dirs; dirs++) for (dirs=default_directories ; *dirs; dirs++)
{ {
if (**dirs) if (**dirs)
{ {
if (search_default_file(&args, &alloc, *dirs, conf_file, for (ext= (char**) f_extensions; *ext; *ext++)
default_ext, &group) < 0) if (search_default_file(&args, &alloc, *dirs, conf_file,
goto err; *ext, &group) < 0)
goto err;
} }
else if (defaults_extra_file) else if (defaults_extra_file)
{ {
if (search_default_file(&args, &alloc, NullS, defaults_extra_file, for (ext= (char**) f_extensions; ext; ext++)
default_ext, &group) < 0) if (search_default_file(&args, &alloc, NullS, defaults_extra_file,
goto err; /* Fatal error */ *ext, &group) < 0)
goto err; /* Fatal error */
} }
} }
} }
...@@ -478,8 +480,9 @@ void print_defaults(const char *conf_file, const char **groups) ...@@ -478,8 +480,9 @@ void print_defaults(const char *conf_file, const char **groups)
#ifdef __WIN__ #ifdef __WIN__
bool have_ext=fn_ext(conf_file)[0] != 0; bool have_ext=fn_ext(conf_file)[0] != 0;
#endif #endif
char name[FN_REFLEN]; char name[FN_REFLEN], **ext;
const char **dirs; const char **dirs;
puts("\nDefault options are read from the following files in the given order:"); puts("\nDefault options are read from the following files in the given order:");
if (dirname_length(conf_file)) if (dirname_length(conf_file))
...@@ -488,27 +491,35 @@ void print_defaults(const char *conf_file, const char **groups) ...@@ -488,27 +491,35 @@ void print_defaults(const char *conf_file, const char **groups)
{ {
#ifdef __WIN__ #ifdef __WIN__
GetWindowsDirectory(name,sizeof(name)); GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext); if (have_ext)
for (ext= (char**) f_extensions; *ext; *ext++)
printf("%s\\%s%s ", name, conf_file, *ext);
else
printf("%s\\%s ", name, conf_file);
#endif #endif
#if defined(__EMX__) || defined(OS2) #if defined(__EMX__) || defined(OS2)
if (getenv("ETC")) for (ext= (char**) f_extensions; *ext; *ext++)
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext); if (getenv("ETC"))
printf("%s\\%s%s ", getenv("ETC"), conf_file, *ext);
#endif #endif
for (dirs=default_directories ; *dirs; dirs++) for (dirs=default_directories ; *dirs; dirs++)
{ {
const char *pos; for (ext= (char**) f_extensions; *ext; *ext++)
char *end; {
if (**dirs) const char *pos;
pos= *dirs; char *end;
else if (defaults_extra_file) if (**dirs)
pos= defaults_extra_file; pos= *dirs;
else else if (defaults_extra_file)
continue; pos= defaults_extra_file;
end=convert_dirname(name, pos, NullS); else
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */ continue;
*end++='.'; end= convert_dirname(name, pos, NullS);
strxmov(end,conf_file,default_ext," ",NullS); if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
fputs(name,stdout); *end++='.';
strxmov(end, conf_file, *ext, " ", NullS);
fputs(name,stdout);
}
} }
puts(""); puts("");
} }
......
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