[vlc-commits] posix: compute relocated libdir rather than pkglibdir
Rémi Denis-Courmont
git at videolan.org
Tue Mar 6 20:17:31 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 5 22:41:52 2018 +0200| [2d062f70943eae3acdb5cc2d0cc9d4599c8d45f4] | committer: Rémi Denis-Courmont
posix: compute relocated libdir rather than pkglibdir
This is actually simpler.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d062f70943eae3acdb5cc2d0cc9d4599c8d45f4
---
src/Makefile.am | 1 +
src/linux/dirs.c | 7 +++----
src/posix/dirs.c | 28 ++++++++++++++--------------
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 90011eedbc..61c93df705 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -169,6 +169,7 @@ lib_LTLIBRARIES = libvlccore.la
AM_CPPFLAGS = $(INCICONV) $(IDN_CFLAGS) \
-DMODULE_STRING=\"core\" \
+ -DLIBDIR=\"$(libdir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DPKGDATADIR=\"$(pkgdatadir)\" \
-DPKGLIBDIR=\"$(pkglibdir)\"
diff --git a/src/linux/dirs.c b/src/linux/dirs.c
index 32e138d866..f5dbdaaf2c 100644
--- a/src/linux/dirs.c
+++ b/src/linux/dirs.c
@@ -65,8 +65,7 @@ static char *config_GetLibDirRaw(void)
continue;
*file = '\0';
- if (asprintf (&path, "%s/"PACKAGE, dir) == -1)
- path = NULL;
+ path = strdup(dir);
break;
}
@@ -74,11 +73,11 @@ static char *config_GetLibDirRaw(void)
fclose (maps);
error:
if (path == NULL)
- path = strdup(PKGLIBDIR);
+ path = strdup(LIBDIR);
return path;
}
-static char cached_path[PATH_MAX] = PKGLIBDIR;
+static char cached_path[PATH_MAX] = LIBDIR;
static void config_GetLibDirOnce(void)
{
diff --git a/src/posix/dirs.c b/src/posix/dirs.c
index 03f77582ca..ee1c94cb27 100644
--- a/src/posix/dirs.c
+++ b/src/posix/dirs.c
@@ -42,7 +42,7 @@
*/
VLC_WEAK char *config_GetLibDir(void)
{
- return strdup(PKGLIBDIR);
+ return strdup(LIBDIR);
}
char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
@@ -61,8 +61,8 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
}
}
- char *pkglibdir = config_GetLibDir();
- if (pkglibdir == NULL)
+ char *libdir = config_GetLibDir();
+ if (libdir == NULL)
return NULL; /* OOM */
static const char *const dirs[] = {
@@ -74,30 +74,30 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
const char *dir_static = dirs[type];
/* Look for common static prefix. */
size_t prefix_len = 0;
- while (prefix_len < strlen(PKGLIBDIR)
- && PKGLIBDIR[prefix_len] == dir_static[prefix_len])
+ while (prefix_len < strlen(LIBDIR)
+ && LIBDIR[prefix_len] == dir_static[prefix_len])
prefix_len++;
/* Check that suffix matches between static and dynamic libdir paths. */
char *filepath = NULL;
- size_t suffix_len = strlen(PKGLIBDIR) - prefix_len;
- size_t pkglibdir_len = strlen(pkglibdir);
+ size_t suffix_len = strlen(LIBDIR) - prefix_len;
+ size_t libdir_len = strlen(libdir);
- if (suffix_len > pkglibdir_len
- || memcmp(PKGLIBDIR + prefix_len,
- pkglibdir + (pkglibdir_len - suffix_len), suffix_len)) {
- suffix_len = pkglibdir_len;
+ if (suffix_len > libdir_len
+ || memcmp(LIBDIR + prefix_len, libdir + (libdir_len - suffix_len),
+ suffix_len)) {
+ suffix_len = libdir_len;
prefix_len = 0;
}
/* Graft non-common static suffix to dynamically computed common prefix. */
const char *fmt = (filename != NULL) ? "%.*s%s/%s" : "%.*s%s";
- if (unlikely(asprintf(&filepath, fmt, (int)(pkglibdir_len - suffix_len),
- pkglibdir, dir_static + prefix_len, filename) == -1))
+ if (unlikely(asprintf(&filepath, fmt, (int)(libdir_len - suffix_len),
+ libdir, dir_static + prefix_len, filename) == -1))
filepath = NULL;
- free(pkglibdir);
+ free(libdir);
return filepath;
}
More information about the vlc-commits
mailing list