]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/ltdl.c (sys_wll_open): libltdl expects this function to
authorGary V. Vaughan <gary@gnu.org>
Wed, 16 Jun 1999 14:58:45 +0000 (14:58 +0000)
committerGary V. Vaughan <gary@gnu.org>
Wed, 16 Jun 1999 14:58:45 +0000 (14:58 +0000)
fail if it is unable to physically load the library.  Sadly,
LoadLibrary will search the loaded libraries for a match and
return one of them if the path search load fails.  Simulate a
failure in this case for compatibility with the other APIs.
Also, LoadLibrary takes the liberty of adding `.dll' to library
names passed without an extension, we now add a trailing `.' to
prevent this from happening.

ChangeLog
libltdl/ltdl.c

index 851713b620b2801bb1dbb3b76301e48542bc5112..a9e1382d6288ce9e2d947ff7efea2955c805c73d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,20 @@
+1999-06-16  Gary V. Vaughan  <gary@oranda.demon.co.uk>
+       * libltdl/ltdl.c (sys_wll_open): libltdl expects this function to
+       fail if it is unable to physically load the library.  Sadly,
+       LoadLibrary will search the loaded libraries for a match and
+       return one of them if the path search load fails.  Simulate a
+       failure in this case for compatibility with the other APIs.
+       Also, LoadLibrary takes the liberty of adding `.dll' to library
+       names passed without an extension, we now add a trailing `.' to
+       prevent this from happening.
 1999-06-15  Gary V. Vaughan  <gary@oranda.demon.co.uk>
 
        * libltdl/ltdl.c (sys_wll_close): Strangely enough, Microsoft have
        decided that LoadLibrary returns `0' for success, yet FreeLibrary
        returns `0' for failure!  The FreeLibrary call used to interpret
-       `0' as success for both functions.
+       `0' as success.
 
 1999-06-14  Thomas Tanner  <tanner@ffii.org>
 
index dbee31cb70b6396a33137de1bc311dad17bf3291..119dcd71c3510a2279c024590e60462b3971506b 100644 (file)
@@ -514,16 +514,56 @@ sys_wll_exit LTDL_PARAMS((void))
        return 0;
 }
 
+/* Forward declaration; required to implement handle search below. */
+static lt_dlhandle handles;
+
 static int
 sys_wll_open (handle, filename)
        lt_dlhandle handle;
        const char *filename;
 {
-       handle->handle = LoadLibrary(filename);
-       if (!handle->handle) {
+       lt_dlhandle cur;
+       char *searchname = NULL;
+       char *ext = strrchr(filename, '.');
+
+       if (ext) {
+               /* FILENAME already has an extension. */
+               searchname = strdup(filename);
+       } else {
+               /* Append a `.' to stop Windows from adding an
+                  implicit `.dll' extension. */
+               searchname = (char*)lt_dlmalloc(2+ strlen(filename));
+               strcpy(searchname, filename);
+               strcat(searchname, ".");
+       }
+    
+       handle->handle = LoadLibrary(searchname);
+       lt_dlfree(searchname);
+       
+       /* libltdl expects this function to fail if it is unable
+          to physically load the library.  Sadly, LoadLibrary
+          will search the loaded libraries for a match and return
+          one of them if the path search load fails.
+
+          We check whether LoadLibrary is returning a handle to
+          an already loaded module, and simulate failure if we
+          find one. */
+       cur = handles;
+       while (cur) {
+               if (!cur->handle) {
+                       cur = 0;
+                       break;
+               }
+               if (cur->handle == handle->handle)
+                       break;
+               cur = cur->next;
+       }
+
+       if (cur || !handle->handle) {
                last_error = cannot_open_error;
                return 1;
        }
+
        return 0;
 }