forked from ariadne/pkgconf
Fix PKG_CONFIG_PATH precedence, simplify.
PKG_CONFIG_PATH paths must take precedence over the default path. Otherwise, we would be unable to override default .pc files. And while I'm at it, simplify the whole code. It is pointless to introduce another buffer and a lot of string mangling for one additional path.feature/tap-sh
parent
ee62bedd59
commit
3707ccd221
31
pkg.c
31
pkg.c
|
@ -36,28 +36,6 @@
|
||||||
#define PKG_CONFIG_PATH_SEP ':'
|
#define PKG_CONFIG_PATH_SEP ':'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline const char *
|
|
||||||
pkg_get_pkgconfig_path(void)
|
|
||||||
{
|
|
||||||
static bool computed = false;
|
|
||||||
static char path[PKG_CONFIG_PATH_SZ];
|
|
||||||
char *env_path;
|
|
||||||
|
|
||||||
if (computed)
|
|
||||||
return path;
|
|
||||||
|
|
||||||
strlcpy(path, PKG_DEFAULT_PATH, sizeof path);
|
|
||||||
|
|
||||||
env_path = getenv("PKG_CONFIG_PATH");
|
|
||||||
if (env_path != NULL)
|
|
||||||
{
|
|
||||||
strlcat(path, PKG_CONFIG_PATH_SEP_S, sizeof path);
|
|
||||||
strlcat(path, env_path, sizeof path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg_t *
|
pkg_t *
|
||||||
pkg_find(const char *name)
|
pkg_find(const char *name)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +45,10 @@ pkg_find(const char *name)
|
||||||
int count = 0, pcount = 0;
|
int count = 0, pcount = 0;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
env_path = pkg_get_pkgconfig_path();
|
/* PKG_CONFIG_PATH has to take precedence */
|
||||||
|
env_path = getenv("PKG_CONFIG_PATH");
|
||||||
|
if (env_path)
|
||||||
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (env_path[count] && env_path[count] != PKG_CONFIG_PATH_SEP)
|
if (env_path[count] && env_path[count] != PKG_CONFIG_PATH_SEP)
|
||||||
|
@ -92,7 +73,11 @@ pkg_find(const char *name)
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(locbuf, sizeof locbuf, "%s/%s.pc", PKG_DEFAULT_PATH, name);
|
||||||
|
if (f = fopen(locbuf, "r"))
|
||||||
|
return parse_file(locbuf, f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue