From a300787cef60b8706c9d84a88acb0973a4af5a17 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 1 Dec 2016 15:17:23 -0600 Subject: [PATCH] libpkgconf: do not implicitly build the dir list, instead explicitly do it --- libpkgconf/libpkgconf.h | 2 +- libpkgconf/pkg.c | 6 +----- main.c | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 9018641..ebd148f 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -202,7 +202,7 @@ pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name) pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name); int pkgconf_compare_version(const char *a, const char *b); -pkgconf_pkg_t *pkgconf_scan_all(pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func); +pkgconf_pkg_t *pkgconf_scan_all(const pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func); void pkgconf_pkg_dir_list_build(pkgconf_client_t *client, unsigned int flags); /* parse.c */ diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 085ad26..71bebea 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -392,13 +392,11 @@ out: } pkgconf_pkg_t * -pkgconf_scan_all(pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func) +pkgconf_scan_all(const pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func) { pkgconf_node_t *n; pkgconf_pkg_t *pkg; - pkgconf_pkg_dir_list_build(client, 0); - PKGCONF_FOREACH_LIST_ENTRY(client->dir_list.head, n) { pkgconf_path_t *pnode = n->data; @@ -455,8 +453,6 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags) pkgconf_node_t *n; FILE *f; - pkgconf_pkg_dir_list_build(client, flags); - /* name might actually be a filename. */ if (str_has_suffix(name, PKG_CONFIG_EXT)) { diff --git a/main.c b/main.c index 38901c1..17c6990 100644 --- a/main.c +++ b/main.c @@ -824,6 +824,9 @@ main(int argc, char *argv[]) else pkgconf_tuple_add_global(&pkg_client, "pc_sysrootdir", "/"); + /* at this point, global_traverse_flags should be set, so build the dir list */ + pkgconf_pkg_dir_list_build(&pkg_client, global_traverse_flags); + if (required_pkgconfig_version != NULL) { if (pkgconf_compare_version(PACKAGE_VERSION, required_pkgconfig_version) >= 0)