Commit f7d41925 authored by unknown's avatar unknown

Merge ramayana.hindu.god:/home/tsmith/m/bk/build/b20748/50

into  ramayana.hindu.god:/home/tsmith/m/bk/build/b20748/51


libmysql/Makefile.shared:
  Auto merged
mysys/CMakeLists.txt:
  Auto merged
mysys/Makefile.am:
  Auto merged
include/my_sys.h:
  Manual merge
mysys/default.c:
  Manual merge:
  
  - We don't support OS/2 in MySQL 5.1
  - On Unix, we search /etc/mysql/ in MySQL 5.1
parents 8680f86e 707f42a6
...@@ -691,6 +691,8 @@ extern WF_PACK *wf_comp(char * str); ...@@ -691,6 +691,8 @@ extern WF_PACK *wf_comp(char * str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name); extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer); extern void wf_end(struct wild_file_pack *buffer);
extern size_t strip_sp(char * str); extern size_t strip_sp(char * str);
extern my_bool array_append_string_unique(const char *str,
const char **array, size_t size);
extern void get_date(char * to,int timeflag,time_t use_time); extern void get_date(char * to,int timeflag,time_t use_time);
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr, extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
pbool remove_garbage); pbool remove_garbage);
......
...@@ -59,7 +59,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ ...@@ -59,7 +59,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
mf_pack.lo my_messnc.lo mf_dirname.lo mf_fn_ext.lo\ mf_pack.lo my_messnc.lo mf_dirname.lo mf_fn_ext.lo\
mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \ mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \ mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
my_symlink.lo my_fstream.lo \ my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \ mf_loadpath.lo my_pthread.lo my_thr_init.lo \
thr_mutex.lo mulalloc.lo string.lo \ thr_mutex.lo mulalloc.lo string.lo \
default.lo default_modify.lo \ default.lo default_modify.lo \
......
...@@ -29,7 +29,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_ ...@@ -29,7 +29,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_tempdir.c mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_arr_appstr.c mf_tempdir.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
......
...@@ -35,7 +35,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ ...@@ -35,7 +35,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_error.c errors.c my_div.c my_messnc.c \ my_error.c errors.c my_div.c my_messnc.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \ mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \ my_symlink.c my_symlink2.c \
mf_pack.c mf_unixpath.c mf_strip.c \ mf_pack.c mf_unixpath.c mf_strip.c mf_arr_appstr.c \
mf_wcomp.c mf_wfile.c my_gethwaddr.c \ mf_wcomp.c mf_wfile.c my_gethwaddr.c \
mf_qsort.c mf_qsort2.c mf_sort.c \ mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c my_getncpus.c \ ptr_cmp.c mf_radix.c queues.c my_getncpus.c \
......
...@@ -47,7 +47,7 @@ char *my_defaults_extra_file=0; ...@@ -47,7 +47,7 @@ char *my_defaults_extra_file=0;
/* Which directories are searched for options (and in which order) */ /* Which directories are searched for options (and in which order) */
#define MAX_DEFAULT_DIRS 7 #define MAX_DEFAULT_DIRS 6
const char *default_directories[MAX_DEFAULT_DIRS + 1]; const char *default_directories[MAX_DEFAULT_DIRS + 1];
#ifdef __WIN__ #ifdef __WIN__
...@@ -83,7 +83,22 @@ static int search_default_file_with_ext(Process_option_func func, ...@@ -83,7 +83,22 @@ static int search_default_file_with_ext(Process_option_func func,
void *func_ctx, void *func_ctx,
const char *dir, const char *ext, const char *dir, const char *ext,
const char *config_file, int recursion_level); const char *config_file, int recursion_level);
static void init_default_directories();
/**
Create the list of default directories.
@details
On all systems, if a directory is already in the list, it will be moved
to the end of the list. This avoids reading defaults files multiple times,
while ensuring the correct precedence.
@return void
*/
static void (*init_default_directories)();
static char *remove_end_comment(char *ptr); static char *remove_end_comment(char *ptr);
...@@ -922,6 +937,25 @@ void print_defaults(const char *conf_file, const char **groups) ...@@ -922,6 +937,25 @@ void print_defaults(const char *conf_file, const char **groups)
#include <help_end.h> #include <help_end.h>
#define ADD_DIRECTORY(DIR) \
do { \
my_bool rc= \
array_append_string_unique((DIR), default_directories, \
array_elements(default_directories)); \
DBUG_ASSERT(rc == FALSE); /* Success */ \
} while (0)
#define ADD_COMMON_DIRECTORIES() \
do { \
char *env; \
if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV)))) \
ADD_DIRECTORY(env); \
/* Placeholder for --defaults-extra-file=<path> */ \
ADD_DIRECTORY(""); \
} while (0)
#ifdef __WIN__ #ifdef __WIN__
/* /*
This wrapper for GetSystemWindowsDirectory() will dynamically bind to the This wrapper for GetSystemWindowsDirectory() will dynamically bind to the
...@@ -956,71 +990,33 @@ static size_t my_get_system_windows_directory(char *buffer, size_t size) ...@@ -956,71 +990,33 @@ static size_t my_get_system_windows_directory(char *buffer, size_t size)
} }
return count; return count;
} }
#endif
/* /**
Create the list of default directories. Initialize default directories for Microsoft Windows
On Microsoft Windows, this is: @details
1. C:/ 1. GetSystemWindowsDirectory()
2. GetWindowsDirectory() 2. GetWindowsDirectory()
3. GetSystemWindowsDirectory() 3. C:/
4. getenv(DEFAULT_HOME_ENV) 4. Directory above where the executable is located
5. Directory above where the executable is located 5. getenv(DEFAULT_HOME_ENV)
6. "" 6. --defaults-extra-file=<path> (run-time option)
7. --sysconfdir=<path> */
On Novell NetWare, this is:
1. sys:/etc/
2. getenv(DEFAULT_HOME_ENV)
3. ""
4. --sysconfdir=<path>
On OS/2, this is:
1. getenv(ETC)
2. /etc/
3. getenv(DEFAULT_HOME_ENV)
4. ""
5. "~/"
6. --sysconfdir=<path>
Everywhere else, this is:
1. /etc/
2. /etc/mysql/
3. getenv(DEFAULT_HOME_ENV)
4. ""
5. "~/"
6. --sysconfdir=<path>
*/
static void init_default_directories() static void init_default_directories_win()
{ {
const char *env, **ptr= default_directories; bzero(default_directories, sizeof(default_directories));
#ifdef __WIN__ if (my_get_system_windows_directory(shared_system_dir,
*ptr++= "C:/"; sizeof(shared_system_dir)))
ADD_DIRECTORY(&shared_system_dir);
if (GetWindowsDirectory(system_dir,sizeof(system_dir))) if (GetWindowsDirectory(system_dir,sizeof(system_dir)))
*ptr++= (char*)&system_dir; ADD_DIRECTORY(&system_dir);
if (my_get_system_windows_directory(shared_system_dir,
sizeof(shared_system_dir)) && ADD_DIRECTORY("C:/");
strcmp(system_dir, shared_system_dir))
*ptr++= (char *)&shared_system_dir;
#elif defined(__NETWARE__)
*ptr++= "sys:/etc/";
#else
*ptr++= "/etc/";
*ptr++= "/etc/mysql/";
#endif
if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV))))
*ptr++= env;
*ptr++= ""; /* Place for defaults_extra_file */
#if !defined(__WIN__) && !defined(__NETWARE__)
*ptr++= "~/";;
#elif defined(__WIN__)
if (GetModuleFileName(NULL, config_dir, sizeof(config_dir))) if (GetModuleFileName(NULL, config_dir, sizeof(config_dir)))
{ {
char *last= NULL, *end= strend(config_dir); char *last= NULL, *end= strend(config_dir);
...@@ -1050,12 +1046,61 @@ static void init_default_directories() ...@@ -1050,12 +1046,61 @@ static void init_default_directories()
last= end; last= end;
} }
} }
*ptr++= (char *)&config_dir; ADD_DIRECTORY(&config_dir);
} }
#endif
ADD_COMMON_DIRECTORIES();
}
static void (*init_default_directories)()= init_default_directories_win;
#elif defined(__NETWARE__)
/**
Initialize default directories for Novell Netware
@details
1. sys:/etc/
2. getenv(DEFAULT_HOME_ENV)
3. --defaults-extra-file=<path> (run-time option)
*/
static void init_default_directories_netware()
{
bzero(default_directories, sizeof(default_directories));
ADD_DIRECTORY("sys:/etc/");
ADD_COMMON_DIRECTORIES();
}
static void (*init_default_directories)()= init_default_directories_netware;
#else
/**
Initialize default directories for Unix
@details
1. /etc/
2. /etc/mysql/
3. --sysconfdir=<path> (compile-time option)
4. getenv(DEFAULT_HOME_ENV)
5. --defaults-extra-file=<path> (run-time option)
6. "~/"
*/
static void init_default_directories_unix()
{
bzero(default_directories, sizeof(default_directories));
ADD_DIRECTORY("/etc/");
ADD_DIRECTORY("/etc/mysql/");
#ifdef DEFAULT_SYSCONFDIR #ifdef DEFAULT_SYSCONFDIR
if (DEFAULT_SYSCONFDIR != "") if (DEFAULT_SYSCONFDIR != "")
*ptr++= DEFAULT_SYSCONFDIR; ADD_DIRECTORY(DEFAULT_SYSCONFDIR);
#endif #endif
*ptr= 0; /* end marker */ ADD_COMMON_DIRECTORIES();
ADD_DIRECTORY("~/");
} }
static void (*init_default_directories)()= init_default_directories_unix;
#endif
/* Copyright (C) 2007 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysys_priv.h"
#include <m_string.h> /* strcmp() */
/**
Append str to array, or move to the end if it already exists
@param str String to be appended
@param array The array, terminated by a NULL element, all unused elements
pre-initialized to NULL
@param size Size of the array; array must be terminated by a NULL
pointer, so can hold size - 1 elements
@retval FALSE Success
@retval TRUE Failure, array is full
*/
my_bool array_append_string_unique(const char *str,
const char **array, size_t size)
{
const char **p;
/* end points at the terminating NULL element */
const char **end= array + size - 1;
DBUG_ASSERT(*end == NULL);
for (p= array; *p; ++p)
{
if (strcmp(*p, str) == 0)
break;
}
if (p >= end)
return TRUE; /* Array is full */
DBUG_ASSERT(*p == NULL || strcmp(*p, str) == 0);
while (*(p + 1))
{
*p= *(p + 1);
++p;
}
DBUG_ASSERT(p < end);
*p= str;
return FALSE; /* Success */
}
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