pkg: make PKG_CONFIG_PATH parsing more robust
parent
5190715da0
commit
2d738c2c40
8
pkg.c
8
pkg.c
|
@ -58,20 +58,24 @@ pkg_find(const char *name)
|
||||||
int count = 0, pcount = 0;
|
int count = 0, pcount = 0;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
bzero(path, BUFSIZ);
|
||||||
|
|
||||||
env_path = pkg_get_pkgconfig_path();
|
env_path = pkg_get_pkgconfig_path();
|
||||||
while (env_path[count] != '\0')
|
while (env_path[count] != '\0')
|
||||||
{
|
{
|
||||||
if (env_path[count] != ':')
|
if (env_path[count] && env_path[count] != ':')
|
||||||
{
|
{
|
||||||
path[pcount] = env_path[count];
|
path[pcount] = env_path[count];
|
||||||
pcount++;
|
pcount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
path[pcount] = '\0';
|
||||||
snprintf(locbuf, sizeof locbuf, "%s/%s.pc", path, name);
|
snprintf(locbuf, sizeof locbuf, "%s/%s.pc", path, name);
|
||||||
if (f = fopen(locbuf, "r"))
|
if (f = fopen(locbuf, "r"))
|
||||||
return parse_file(locbuf, f);
|
return parse_file(locbuf, f);
|
||||||
path[0] = '\0';
|
|
||||||
|
bzero(path, BUFSIZ);
|
||||||
pcount = 0;
|
pcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue