Below is the list of changes that have just been committed into a local
5.0 repository of jwinstead. When jwinstead does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1904 05/05/24 04:49:04 jimw@stripped +1 -0
Look in the directory above the executable for the my.cnf/ini, on Windows, as
the new installer and GUI tools expect. (Bug #10419) Also, dynamically bind to
GetSystemWindowsDirectory() so that it works on all platforms. (Bug #5354)
mysys/default.c
1.71 05/05/24 04:46:43 jimw@stripped +77 -7
Dynamically bind to GetSystemWindowsDirectory() or emulate it, and also look
in directory above the executable to find my.cnf/ini on Windows.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jimw
# Host: bk-internal.mysql.com
# Root: /users/jwinstead/my/mysql-5.0-10419
--- 1.70/mysys/default.c 2005-05-19 02:13:30 +02:00
+++ 1.71/mysys/default.c 2005-05-24 04:46:43 +02:00
@@ -45,13 +45,14 @@
/* Which directories are searched for options (and in which order) */
-#define MAX_DEFAULT_DIRS 5
+#define MAX_DEFAULT_DIRS 6
const char *default_directories[MAX_DEFAULT_DIRS + 1];
#ifdef __WIN__
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
#define NEWLINE "\r\n"
-static char system_dir[FN_REFLEN], shared_system_dir[FN_REFLEN];
+static char system_dir[FN_REFLEN], shared_system_dir[FN_REFLEN],
+ config_dir[FN_REFLEN];
#else
static const char *f_extensions[]= { ".cnf", 0 };
#define NEWLINE "\n"
@@ -812,6 +813,51 @@
#include <help_end.h>
+#ifdef __WIN__
+/*
+ This wrapper for GetSystemWindowsDirectory() will dynamically bind to the
+ function if it is available, emulate it on NT4 Terminal Server by stripping
+ the \SYSTEM32 from the end of the results of GetSystemDirectory(), or just
+ return GetSystemDirectory().
+ */
+
+typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(
+ LPVOID lpThreadParameter
+);
+
+typedef UINT (WINAPI *GET_SYSTEM_WINDOWS_DIRECTORY)(LPSTR, UINT);
+
+static UINT my_GetSystemWindowsDirectory(LPTSTR lpBuffer, UINT uSize)
+{
+ GET_SYSTEM_WINDOWS_DIRECTORY
+ pGetSystemWindowsDirectory= (GET_SYSTEM_WINDOWS_DIRECTORY)
+ GetProcAddress(GetModuleHandle("kernel32.dll"),
+ "GetSystemWindowsDirectoryA");
+
+ if (pGetSystemWindowsDirectory)
+ {
+ return pGetSystemWindowsDirectory(lpBuffer, uSize);
+ }
+ else
+ {
+ /*
+ Windows NT 4.0 Terminal Server Edition:
+ To retrieve the shared Windows directory, call GetSystemDirectory and
+ trim the "System32" element from the end of the returned path.
+ */
+ UINT count= GetSystemDirectory(lpBuffer, uSize);
+
+ if (stricmp(lpBuffer+(count-8), "\\System32") == 0)
+ {
+ count-= 8;
+ lpBuffer[count] = '\0';
+ }
+ return count;
+ }
+}
+#endif
+
+
/*
Create the list of default directories.
@@ -820,7 +866,8 @@
2. GetWindowsDirectory()
3. GetSystemWindowsDirectory()
4. getenv(DEFAULT_HOME_ENV)
- 5. ""
+ 5. Direcotry above where the executable is located
+ 6. ""
On Novell NetWare, this is:
1. sys:/etc/
@@ -851,13 +898,11 @@
if (GetWindowsDirectory(system_dir,sizeof(system_dir)))
*ptr++= &system_dir;
-#if defined(_MSC_VER) && (_MSC_VER >= 1300)
- /* Only VC7 and up */
/* Only add shared system directory if different from default. */
- if (GetSystemWindowsDirectory(shared_system_dir,sizeof(shared_system_dir)) &&
+ if (my_GetSystemWindowsDirectory(shared_system_dir,
+ sizeof(shared_system_dir)) &&
strcmp(system_dir, shared_system_dir))
*ptr++= &shared_system_dir;
-#endif
#elif defined(__NETWARE__)
*ptr++= "sys:/etc/";
@@ -873,6 +918,31 @@
*ptr++= ""; /* Place for defaults_extra_file */
#if !defined(__WIN__) && !defined(__NETWARE__)
*ptr++= "~/";;
+#elif define(__WIN__)
+ if (GetModuleFileName(NULL, config_dir, sizeof(config_dir)))
+ {
+ char *last= NULL, *end= strend(config_dir);
+ /*
+ Look for the second-to-last \ in the filename, but hang on
+ to a pointer after the last \ in case we're in the root of
+ a drive.
+ */
+ for ( ; end > config_dir; end--)
+ if (*end == '\\')
+ if (last)
+ break;
+ else
+ last= end;
+
+ if (last && end - config_dir == 2) /* Ended up with D:\ */
+ *(end+1)= 0;
+ if (last && end - config_dir > 2)
+ *end= 0;
+ else if (last)
+ *(last+1)= 0;
+
+ *ptr++= &config_dir;
+ }
#endif
*ptr= 0; /* end marker */
}
| Thread |
|---|
| • bk commit into 5.0 tree (jimw:1.1904) BUG#5354 | Jim Winstead | 24 May |