diff options
author | Guido van Rossum <guido@python.org> | 1998-06-27 21:53:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-06-27 21:53:17 (GMT) |
commit | a5e1b008a97f7c3c0ecf94543f1c3306d6c0e7e8 (patch) | |
tree | 212c796caf94a39984d3985f58528a11bfe7363f /Python/importdl.c | |
parent | 0ef577b9668db07fadcf555ee596955261b8591a (diff) | |
download | cpython-a5e1b008a97f7c3c0ecf94543f1c3306d6c0e7e8.zip cpython-a5e1b008a97f7c3c0ecf94543f1c3306d6c0e7e8.tar.gz cpython-a5e1b008a97f7c3c0ecf94543f1c3306d6c0e7e8.tar.bz2 |
Windows-specific hack to make sure that when LoadLibrary() is called,
the filename contains at least a rudimentary pathname.
(The bad part is that we need to call getcwd() because only a prefix
of ".\\" is not enough -- we prefix the drive letter.)
Diffstat (limited to 'Python/importdl.c')
-rw-r--r-- | Python/importdl.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index fe025c0..5d78bab 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -104,6 +104,7 @@ typedef int (* APIENTRY dl_funcptr)(); #ifdef MS_WINDOWS /* i.e. MS_WIN32 or MS_WIN16 */ #define DYNAMIC_LINK #include <windows.h> +#include <direct.h> typedef FARPROC dl_funcptr; #define _DL_FUNCPTR_DEFINED #ifdef _DEBUG @@ -419,6 +420,19 @@ _PyImport_LoadDynamicModule(name, pathname, fp) #ifdef MS_WIN32 { HINSTANCE hDLL; + char pathbuf[260]; + if (strchr(pathname, SEP) == NULL && + strchr(pathname, ALTSEP) == NULL) + { + /* Prefix bare filename with ".\" */ + char *p = pathbuf; + *p = '\0'; + _getcwd(pathbuf, sizeof pathbuf); + if (*p != '\0' && p[1] == ':') + p += 2; + sprintf(p, ".\\%-.255s", pathname); + pathname = pathbuf; + } hDLL = LoadLibrary(pathname); if (hDLL==NULL){ char errBuf[256]; @@ -471,6 +485,14 @@ _PyImport_LoadDynamicModule(name, pathname, fp) #ifdef MS_WIN16 { HINSTANCE hDLL; + char pathbuf[16]; + if (strchr(pathname, SEP) == NULL && + strchr(pathname, ALTSEP) == NULL) + { + /* Prefix bare filename with ".\" */ + sprintf(pathbuf, ".\\%-.13s", pathname); + pathname = pathbuf; + } hDLL = LoadLibrary(pathname); if (hDLL < HINSTANCE_ERROR){ char errBuf[256]; |