pkg: make PKG_CONFIG_PATH parsing more robust

feature/tap-sh
William Pitcock 2012-05-01 01:27:19 +00:00
parent 5190715da0
commit 2d738c2c40
1 changed files with 6 additions and 2 deletions

8
pkg.c
View File

@ -58,20 +58,24 @@ pkg_find(const char *name)
int count = 0, pcount = 0;
FILE *f;
bzero(path, BUFSIZ);
env_path = pkg_get_pkgconfig_path();
while (env_path[count] != '\0')
{
if (env_path[count] != ':')
if (env_path[count] && env_path[count] != ':')
{
path[pcount] = env_path[count];
pcount++;
}
else
{
path[pcount] = '\0';
snprintf(locbuf, sizeof locbuf, "%s/%s.pc", path, name);
if (f = fopen(locbuf, "r"))
return parse_file(locbuf, f);
path[0] = '\0';
bzero(path, BUFSIZ);
pcount = 0;
}