diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-09 18:22:43 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-09 18:22:43 +0000 |
commit | 95140b9803ddf95b050f1d52936f19393a6b541c (patch) | |
tree | dd96b69ee89a56ecccc3e001d320f4494464dc71 /win32/win32.c | |
parent | 1b882d32f692ce67c7b4fa7e0684fcc65add31dc (diff) | |
download | perl-95140b9803ddf95b050f1d52936f19393a6b541c.tar.gz |
work around mangled archname on win32 while finding privlib/sitelib;
normalize lib paths to forward slashes internally
p4raw-id: //depot/perl@3345
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/win32/win32.c b/win32/win32.c index 1848e9ba27..b4b208e74d 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -195,16 +195,28 @@ get_emd_part(char *prev_path, char *trailing_path, ...) GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE) ? GetModuleHandle(NULL) : w32_perldll_handle), mod_name, sizeof(mod_name)); - ptr = strrchr(mod_name, '\\'); + /* try to get full path to binary (which may be mangled when perl is + * run from a 16-bit app */ + (void)GetFullPathName(mod_name, sizeof(mod_name), mod_name, &ptr); + ptr = mod_name; + /* normalize to forward slashes */ + while (*ptr) { + if (*ptr == '\\') + *ptr = '/'; + ++ptr; + } + ptr = strrchr(mod_name, '/'); while (ptr && strip) { /* look for directories to skip back */ optr = ptr; *ptr = '\0'; - ptr = strrchr(mod_name, '\\'); + ptr = strrchr(mod_name, '/'); if (!ptr || stricmp(ptr+1, strip) != 0) { - if(!(*strip == '5' && *(ptr+1) == '5' && strncmp(strip, base, 5) == 0 - && strncmp(ptr+1, base, 5) == 0)) { - *optr = '\\'; + if(!(*strip == '5' && *(ptr+1) == '5' + && strncmp(strip, base, 5) == 0 + && strncmp(ptr+1, base, 5) == 0)) + { + *optr = '/'; ptr = optr; } } @@ -213,7 +225,7 @@ get_emd_part(char *prev_path, char *trailing_path, ...) if (!ptr) { ptr = mod_name; *ptr++ = '.'; - *ptr = '\\'; + *ptr = '/'; } va_end(ap); strcpy(++ptr, trailing_path); @@ -273,7 +285,7 @@ win32_get_sitelib(char *pl) /* $sitelib .= * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/site/$]/lib"; */ - sprintf(pathstr, "site\\%s\\lib", pl); + sprintf(pathstr, "site/%s/lib", pl); path1 = get_emd_part(path1, pathstr, ARCHNAME, "bin", pl, Nullch); /* $HKCU{'sitelib'} || $HKLM{'sitelib'} . ---; */ @@ -281,7 +293,7 @@ win32_get_sitelib(char *pl) /* $sitelib .= * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/site/lib"; */ - path2 = get_emd_part(path2, "site\\lib", ARCHNAME, "bin", pl, Nullch); + path2 = get_emd_part(path2, "site/lib", ARCHNAME, "bin", pl, Nullch); if (!path1) return path2; |