* dcrt0.cc (build_argv): Strip quotes from argv[0] since it should never be
globified.
This commit is contained in:
parent
c77c441991
commit
01e6597b1c
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Jul 16 00:32:58 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* dcrt0.cc (build_argv): Strip quotes from argv[0] since it should
|
||||||
|
never be globified.
|
||||||
|
|
||||||
Sat Jul 15 00:32:41 2000 Christopher Faylor <cgf@cygnus.com>
|
Sat Jul 15 00:32:41 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* dll_init.cc (dll_list::alloc): Round correctly. Use VirtualAlloc
|
* dll_init.cc (dll_list::alloc): Round correctly. Use VirtualAlloc
|
||||||
|
|
|
@ -439,7 +439,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell)
|
||||||
/* Skip over characters until the closing quote */
|
/* Skip over characters until the closing quote */
|
||||||
{
|
{
|
||||||
sawquote = cmd;
|
sawquote = cmd;
|
||||||
cmd = quoted (cmd, winshell);
|
cmd = quoted (cmd, argc > 0 && winshell);
|
||||||
}
|
}
|
||||||
if (issep (*cmd)) // End of argument if space
|
if (issep (*cmd)) // End of argument if space
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,13 +16,8 @@ details. */
|
||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
#include "dll_init.h"
|
#include "dll_init.h"
|
||||||
|
|
||||||
#ifdef _MT_SAFE
|
|
||||||
#define _dl_error _reent_winsup()->_dl_error
|
#define _dl_error _reent_winsup()->_dl_error
|
||||||
#define _dl_buffer _reent_winsup()->_dl_buffer
|
#define _dl_buffer _reent_winsup()->_dl_buffer
|
||||||
#else
|
|
||||||
static int _dl_error = 0;
|
|
||||||
static char _dl_buffer[256];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
set_dl_error (const char *str)
|
set_dl_error (const char *str)
|
||||||
|
@ -31,11 +26,9 @@ set_dl_error (const char *str)
|
||||||
_dl_error = 1;
|
_dl_error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Check for existence of a file specified by the directory
|
||||||
// this function checks for existence of a file specified by the
|
and name components. If successful, return a pointer the
|
||||||
// directory and name components. If successful, return a pointer
|
full pathname (static buffer), else return 0. */
|
||||||
// the full pathname (static buffer), or else return 0.
|
|
||||||
//
|
|
||||||
static const char * __stdcall
|
static const char * __stdcall
|
||||||
check_access (const char *dir, const char *name)
|
check_access (const char *dir, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -52,11 +45,9 @@ check_access (const char *dir, const char *name)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Look for an executable file given the name and the environment
|
||||||
// this function looks for an executable file given the name and the
|
variable to use for searching (eg., PATH); returns the full
|
||||||
// environment variable to use for searching (eg., PATH); returns
|
pathname (static buffer) if found or NULL if not. */
|
||||||
// the full pathname (static buffer) if found or NULL if not.
|
|
||||||
//
|
|
||||||
static const char * __stdcall
|
static const char * __stdcall
|
||||||
check_path_access (const char *mywinenv, const char *name)
|
check_path_access (const char *mywinenv, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -64,22 +55,20 @@ check_path_access (const char *mywinenv, const char *name)
|
||||||
return find_exec (name, buf, mywinenv, TRUE);
|
return find_exec (name, buf, mywinenv, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/* Simulate the same search as LoadLibary + check environment
|
||||||
// This function simulates the same search as LoadLibary + check
|
variable LD_LIBRARY_PATH. If found, return the full pathname
|
||||||
// environment variable LD_LIBRARY_PATH. If found, return the full
|
(static buffer); if illegal, return the input string unchanged
|
||||||
// pathname (static buffer); if illegal, return the input string
|
and let the caller deal with it; return NULL otherwise.
|
||||||
// unchanged and let the caller deal with it; return NULL otherwise.
|
|
||||||
//
|
Note that this should never be called with a NULL string, since
|
||||||
// Note that this should never be called with a NULL string, since
|
that is the introspective case, and the caller should not call
|
||||||
// that is the introspective case, and the caller should not call
|
this function at all. */
|
||||||
// this function at all.
|
|
||||||
//
|
|
||||||
static const char * __stdcall
|
static const char * __stdcall
|
||||||
get_full_path_of_dll (const char* str)
|
get_full_path_of_dll (const char* str)
|
||||||
{
|
{
|
||||||
int len = (str) ? strlen (str) : 0;
|
int len = (str) ? strlen (str) : 0;
|
||||||
|
|
||||||
// NULL or empty string or too long to be legal win32 pathname?
|
/* NULL or empty string or too long to be legal win32 pathname? */
|
||||||
if (len == 0 || len >= MAX_PATH - 1)
|
if (len == 0 || len >= MAX_PATH - 1)
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
|
@ -89,29 +78,27 @@ get_full_path_of_dll (const char* str)
|
||||||
|
|
||||||
strcpy (name, str);
|
strcpy (name, str);
|
||||||
|
|
||||||
// add extension if necessary, but leave a trailing '.', if any, alone.
|
/* Add extension if necessary, but leave a trailing '.', if any, alone.
|
||||||
// Files with trailing '.'s are handled differently by win32 API.
|
Files with trailing '.'s are handled differently by win32 API. */
|
||||||
if (str[len - 1] != '.')
|
if (str[len - 1] != '.')
|
||||||
{
|
{
|
||||||
// add .dll only if no extension provided. Handle various cases:
|
/* Add .dll only if no extension provided. Handle various cases:
|
||||||
//
|
./shlib --> ./shlib.dll
|
||||||
// ./shlib --> ./shlib.dll
|
./dir/shlib.so --> ./dir/shlib.so
|
||||||
// ./dir/shlib.so --> ./dir/shlib.so
|
shlib --> shlib.dll
|
||||||
// shlib --> shlib.dll
|
shlib.dll --> shlib.dll
|
||||||
// shlib.dll --> shlib.dll
|
shlib.so --> shlib.so */
|
||||||
// shlib.so --> shlib.so
|
|
||||||
//
|
|
||||||
const char *p = strrchr (str, '.');
|
const char *p = strrchr (str, '.');
|
||||||
if (!p || isdirsep (p[1]))
|
if (!p || isdirsep (p[1]))
|
||||||
strcat (name, ".dll");
|
strcat (name, ".dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
// deal with fully qualified filename right away. Do the actual
|
/* Deal with fully qualified filename right away. Do the actual
|
||||||
// conversion to win32 filename just before returning however.
|
conversion to win32 filename just before returning however. */
|
||||||
if (isabspath (str))
|
if (isabspath (str))
|
||||||
ret = name;
|
ret = name;
|
||||||
|
|
||||||
// current directory
|
/* current directory */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
if (GetCurrentDirectory (MAX_PATH, buf) == 0)
|
if (GetCurrentDirectory (MAX_PATH, buf) == 0)
|
||||||
|
@ -120,29 +107,28 @@ get_full_path_of_dll (const char* str)
|
||||||
ret = check_access (buf, name);
|
ret = check_access (buf, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LD_LIBRARY_PATH
|
/* LD_LIBRARY_PATH */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = check_path_access ("LD_LIBRARY_PATH=", name);
|
ret = check_path_access ("LD_LIBRARY_PATH=", name);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
// system directory
|
|
||||||
if (GetSystemDirectory (buf, MAX_PATH) == 0)
|
if (GetSystemDirectory (buf, MAX_PATH) == 0)
|
||||||
small_printf ("WARNING: get_full_path_of_dll can't get system directory win32 %E\n");
|
small_printf ("WARNING: get_full_path_of_dll can't get system directory win32 %E\n");
|
||||||
else
|
else
|
||||||
ret = check_access (buf, name);
|
ret = check_access (buf, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 16 bits system directory
|
/* 16 bits system directory */
|
||||||
if (!ret && (os_being_run == winNT))
|
if (!ret && (os_being_run == winNT))
|
||||||
{
|
{
|
||||||
// we assume last dir was xxxxx\SYSTEM32, so we remove 32
|
/* we assume last dir was xxxxx\SYSTEM32, so we remove 32 */
|
||||||
len = strlen (buf);
|
len = strlen (buf);
|
||||||
buf[len - 2] = 0;
|
buf[len - 2] = 0;
|
||||||
ret = check_access (buf, name);
|
ret = check_access (buf, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// windows directory
|
/* windows directory */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
if (GetWindowsDirectory (buf, MAX_PATH) == 0)
|
if (GetWindowsDirectory (buf, MAX_PATH) == 0)
|
||||||
|
@ -151,14 +137,12 @@ get_full_path_of_dll (const char* str)
|
||||||
ret = check_access (buf, name);
|
ret = check_access (buf, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATH
|
/* PATH */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = check_path_access ("PATH=", name);
|
ret = check_path_access ("PATH=", name);
|
||||||
|
|
||||||
//
|
/* Now do a final conversion to win32 pathname. This step is necessary
|
||||||
// now do a final conversion to win32 pathname. This step is necessary
|
to resolve symlinks etc so that win32 API finds the underlying file. */
|
||||||
// to resolve symlinks etc so that win32 API finds the underlying file.
|
|
||||||
//
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
path_conv real_filename (ret, SYMLINK_FOLLOW, 1);
|
path_conv real_filename (ret, SYMLINK_FOLLOW, 1);
|
||||||
|
@ -182,12 +166,12 @@ dlopen (const char *name, int)
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
// handle for the current module
|
/* handle for the current module */
|
||||||
ret = (void *) GetModuleHandle (NULL);
|
ret = (void *) GetModuleHandle (NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// handle for the named library
|
/* handle for the named library */
|
||||||
const char *fullpath = get_full_path_of_dll (name);
|
const char *fullpath = get_full_path_of_dll (name);
|
||||||
ret = (void *) LoadLibrary (fullpath);
|
ret = (void *) LoadLibrary (fullpath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue