lt_user_data data = loader->dlloader_data;
cur->module = loader->module_open (data, filename);
+
if (cur->module != 0)
{
break;
const char *saved_error = last_error;
char *canonical = 0, *basename = 0, *dir = 0, *name = 0;
+ /* dlopen self? */
if (!filename)
{
handle = (lt_dlhandle) lt_dlmalloc (sizeof (struct lt_dlhandle));
return 0;
}
+ /* If the canonical module name is a path (relative or absolute)
+ then split it into a directory part and a name part. */
basename = strrchr (canonical, '/');
if (basename)
{
name[ext - basename] = '\0';
- /* now try to open the .la file */
- file = fopen (filename, LT_READTEXT_MODE);
- if (!file)
+ /* Now try to open the .la file. If there is no directory name
+ component, try to find it first in user_search_path and then other
+ prescribed paths. Otherwise (or in any case if the module was not
+ yet found) try opening just the module name as passed. */
+ if (!dir)
{
- last_error = LT_DLSTRERROR (FILE_NOT_FOUND);
- }
- if (!file && !dir)
- {
- /* try other directories */
file = (FILE*) find_file(basename, user_search_path, &dir, 0);
if (!file)
{
}
#endif
}
+ if (!file)
+ {
+ file = fopen (filename, LT_READTEXT_MODE);
+ }
+ if (!file)
+ {
+ last_error = LT_DLSTRERROR (FILE_NOT_FOUND);
+ }
if (!file)
{
handle->deplibs = 0;
newhandle = handle;
- if (tryall_dlopen (&newhandle, filename)
- && (dir || (!find_file (basename, user_search_path, 0, &newhandle)
+ /* If the module has no directory name component, try to find it
+ first in user_search_path and then other prescribed paths.
+ Otherwise (or in any case if the module was not yet found) try
+ opening just the module name as passed. */
+ if ((dir || (!find_file (basename, user_search_path, 0, &newhandle)
&& !find_file (basename, getenv ("LTDL_LIBRARY_PATH"),
0, &newhandle)
#ifdef LTDL_SHLIBPATH_VAR
#ifdef LTDL_SYSSEARCHPATH
&& !find_file (basename, sys_search_path, 0, &newhandle)
#endif
- )))
+ )) && tryall_dlopen (&newhandle, filename))
{
lt_dlfree (handle);
handle = 0;
return 0;
}
- /* try the normal file name */
- handle = lt_dlopen (filename);
- if (handle)
- {
- return handle;
- }
-
/* try "filename.la" */
tmp = (char*) lt_dlmalloc (len+4);
if (!tmp)
}
#endif
+ /* try the normal file name */
+ handle = lt_dlopen (filename);
+ if (handle)
+ {
+ return handle;
+ }
+
last_error = LT_DLSTRERROR (FILE_NOT_FOUND);
lt_dlfree (tmp);
return 0;