[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Further cleanup of user_search_path handling
From: |
Ralf Wildenhues |
Subject: |
Further cleanup of user_search_path handling |
Date: |
Fri, 8 Oct 2004 17:27:30 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello there,
The lt_dlpath_insertdir() function has so far been inconsequent in that
it created a canonicalized version of the given directory, but added the
uncanonicalized version to the given path (user_search_path, that is).
So lt_dladdsearchdir() and lt_dlinsertsearchdir() ended up adding
uncanonicalized stuff, while lt_dlsetsearchpath() properly
canonicalizes its argument.
So while I fixed that, two things sprung up:
First, this is an interface change, the previous behaviour did not seem
intended (a comment in lt_dlpath_insertdir even claims the fixed
behavior).
Second, the fixed lt_dlpath_insertdir() can also add whole paths to a
path. So it can be used for all the other functions that manipulate
user_search_path, allowing for some cleanup.
OK to apply to HEAD? If so, I could add a documentation update about
the new functionality (and also a warning that the path will be
canonicalized).
Regards,
Ralf
2004-10-08 Ralf Wildenhues <address@hidden>
* libltdl/ltdl.c (lt_dlpath_insertdir): Actually add the canonicalized
dir instead of the user-provided one to the path. Since this allows
us to add whole paths at once ..
(lt_dladdsearchdir, lt_dlinsertsearchdir, lt_dlsetsearchpath,
lt_dlgetsearchpath): .. make use of it and simplify.
libltdl/ltdl.h: Change variable names but not the interface to reflect
this.
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.220
diff -u -r1.220 ltdl.c
--- libltdl/ltdl.c 8 Oct 2004 14:10:33 -0000 1.220
+++ libltdl/ltdl.c 8 Oct 2004 14:59:40 -0000
@@ -1831,7 +1831,7 @@
size_t argz_len = 0;
assert (ppath);
- assert (dir && *dir);
+ assert (dir && *dir); /* Without DIR, don't call this
function! */
if (canonicalize_path (dir, &canonical) != 0)
{
@@ -1845,9 +1845,8 @@
if (*ppath == 0)
{
assert (!before); /* BEFORE cannot be set without PPATH.
*/
- assert (dir); /* Without DIR, don't call this function! */
- *ppath = lt__strdup (dir);
+ *ppath = lt__strdup (canonical);
if (*ppath == 0)
++errors;
@@ -1875,7 +1874,7 @@
before = before - *ppath + argz;
}
- if (lt_argz_insert (&argz, &argz_len, before, dir) != 0)
+ if (lt_argz_insert (&argz, &argz_len, before, canonical) != 0)
{
++errors;
goto cleanup;
@@ -1892,21 +1891,13 @@
}
int
-lt_dladdsearchdir (const char *search_dir)
+lt_dladdsearchdir (const char *search_path)
{
- int errors = 0;
-
- if (search_dir && *search_dir)
- {
- if (lt_dlpath_insertdir (&user_search_path, 0, search_dir) != 0)
- ++errors;
- }
-
- return errors;
+ return lt_dlinsertsearchdir (NULL, search_path);
}
int
-lt_dlinsertsearchdir (const char *before, const char *search_dir)
+lt_dlinsertsearchdir (const char *before, const char *search_path)
{
int errors = 0;
@@ -1920,10 +1911,10 @@
}
}
- if (search_dir && *search_dir)
+ if (search_path && *search_path)
{
if (lt_dlpath_insertdir (&user_search_path,
- (char *) before, search_dir) != 0)
+ (char *) before, search_path) != 0)
{
++errors;
}
@@ -1935,29 +1926,15 @@
int
lt_dlsetsearchpath (const char *search_path)
{
- int errors = 0;
-
FREE (user_search_path);
- if (!search_path || !LT_STRLEN (search_path))
- {
- return errors;
- }
-
- if (canonicalize_path (search_path, &user_search_path) != 0)
- ++errors;
-
- return errors;
+ return lt_dlinsertsearchdir(NULL, search_path);
}
const char *
lt_dlgetsearchpath (void)
{
- const char *saved_path;
-
- saved_path = user_search_path;
-
- return saved_path;
+ return user_search_path;
}
int
Index: libltdl/ltdl.h
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.h,v
retrieving revision 1.74
diff -u -r1.74 ltdl.h
--- libltdl/ltdl.h 1 Sep 2004 01:22:26 -0000 1.74
+++ libltdl/ltdl.h 8 Oct 2004 14:59:40 -0000
@@ -52,9 +52,9 @@
LT_SCOPE int lt_dlexit (void);
/* Module search path manipulation. */
-LT_SCOPE int lt_dladdsearchdir (const char *search_dir);
+LT_SCOPE int lt_dladdsearchdir (const char *search_path);
LT_SCOPE int lt_dlinsertsearchdir (const char *before,
- const char *search_dir);
+ const char *search_path);
LT_SCOPE int lt_dlsetsearchpath (const char *search_path);
LT_SCOPE const char *lt_dlgetsearchpath (void);
LT_SCOPE int lt_dlforeachfile (
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Further cleanup of user_search_path handling,
Ralf Wildenhues <=