pkg: add get_pkgconfig_path() for separating out the fallback path logic

pull/29/head
William Pitcock 2012-05-12 02:21:11 -05:00
parent 52dee220ee
commit 6519f6abdc
1 changed files with 15 additions and 4 deletions

19
pkg.c
View File

@ -88,6 +88,18 @@ str_has_suffix(const char *str, const char *suffix)
return !strncasecmp(str + str_len - suf_len, suffix, suf_len);
}
static inline const char *
get_pkgconfig_path(void)
{
const char *env_path;
env_path = getenv("PKG_CONFIG_LIBDIR");
if (env_path != NULL)
return env_path;
return PKG_DEFAULT_PATH;
}
/*
* pkg_new_from_file(filename, file)
*
@ -298,12 +310,11 @@ pkg_find(const char *name, unsigned int flags)
if (pkg != NULL)
goto out;
}
path_free(path, count);
}
env_path = getenv("PKG_CONFIG_LIBDIR");
if (env_path == NULL)
env_path = PKG_DEFAULT_PATH;
env_path = get_pkgconfig_path();
if (!(flags & PKGF_ENV_ONLY))
{
count = path_split(env_path, &path);