on Windows, LoadLibrary() could load an extension DLL multiple
Gurusamy Sarathy [Mon, 9 Oct 2000 18:30:09 +0000 (18:30 +0000)]
times if forward slashes are used in the path

p4raw-id: //depot/perl@7171

win32/win32.c

index 67e8952..65d5f66 100644 (file)
@@ -3564,6 +3564,25 @@ win32_dynaload(const char* filename)
 {
     dTHXo;
     HMODULE hModule;
+    char buf[MAX_PATH+1];
+    char *first;
+
+    /* LoadLibrary() doesn't recognize forward slashes correctly,
+     * so turn 'em back. */
+    first = strchr(filename, '/');
+    if (first) {
+       STRLEN len = strlen(filename);
+       if (len <= MAX_PATH) {
+           strcpy(buf, filename);
+           filename = &buf[first - filename];
+           while (*filename) {
+               if (*filename == '/')
+                   *(char*)filename = '\\';
+               ++filename;
+           }
+           filename = buf;
+       }
+    }
     if (USING_WIDE()) {
        WCHAR wfilename[MAX_PATH+1];
        A2WHELPER(filename, wfilename, sizeof(wfilename));