forked from ariadne/pkgconf
pkg: add support for treating package names as files
parent
c0245f54a9
commit
a078249a60
19
pkg.c
19
pkg.c
|
@ -58,6 +58,18 @@ path_split(const char *text, char ***parv)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
str_has_suffix(const char *str, const char *suffix)
|
||||||
|
{
|
||||||
|
size_t str_len = strlen(str);
|
||||||
|
size_t suf_len = strlen(suffix);
|
||||||
|
|
||||||
|
if (str_len < suf_len)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !strncasecmp(str + str_len - suf_len, suffix, suf_len);
|
||||||
|
}
|
||||||
|
|
||||||
pkg_t *
|
pkg_t *
|
||||||
pkg_find(const char *name, unsigned int flags)
|
pkg_find(const char *name, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
@ -68,6 +80,13 @@ pkg_find(const char *name, unsigned int flags)
|
||||||
const char *env_path;
|
const char *env_path;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
/* name might actually be a filename. */
|
||||||
|
if (str_has_suffix(name, PKG_CONFIG_EXT))
|
||||||
|
{
|
||||||
|
if ((f = fopen(name, "r")) != NULL)
|
||||||
|
return parse_file(name, f);
|
||||||
|
}
|
||||||
|
|
||||||
/* PKG_CONFIG_PATH has to take precedence */
|
/* PKG_CONFIG_PATH has to take precedence */
|
||||||
env_path = getenv("PKG_CONFIG_PATH");
|
env_path = getenv("PKG_CONFIG_PATH");
|
||||||
if (env_path)
|
if (env_path)
|
||||||
|
|
Loading…
Reference in New Issue