From 84ea074fbe79ba8695d175fc8d46e0f2b5d21c26 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 8 Aug 2012 11:04:07 -0500 Subject: [PATCH] pkg: allow pkg_cflags() and pkg_libs() utility functions to have a user-provided list pointer. Also chase this change in the frontend. --- main.c | 8 +++++--- pkg.c | 16 ++++++---------- pkg.h | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index 9acfebf..1663c37 100644 --- a/main.c +++ b/main.c @@ -279,10 +279,11 @@ apply_variable(pkg_t *world, void *variable, int maxdepth, unsigned int flags) static void apply_cflags(pkg_t *world, void *unused, int maxdepth, unsigned int flags) { + pkg_fragment_t *head = NULL; pkg_fragment_t *list; (void) unused; - list = pkg_cflags(world, maxdepth, flags | PKGF_SEARCH_PRIVATE); + list = pkg_cflags(world, &head, maxdepth, flags | PKGF_SEARCH_PRIVATE); print_cflags(list); pkg_fragment_free(list); @@ -291,10 +292,11 @@ apply_cflags(pkg_t *world, void *unused, int maxdepth, unsigned int flags) static void apply_libs(pkg_t *world, void *unused, int maxdepth, unsigned int flags) { + pkg_fragment_t *head = NULL; pkg_fragment_t *list; (void) unused; - list = pkg_libs(world, maxdepth, flags); + list = pkg_libs(world, &head, maxdepth, flags); print_libs(list); pkg_fragment_free(list); @@ -757,7 +759,7 @@ main(int argc, char *argv[]) { want_flags &= ~(PKG_CFLAGS|PKG_LIBS); - if (!pkg_queue_apply(pkgq_head, apply_simulate, maximum_traverse_depth, global_traverse_flags, NULL)) + if (!pkg_queue_apply(pkgq_head, apply_simulate, -1, global_traverse_flags, NULL)) { ret = EXIT_FAILURE; goto out; diff --git a/pkg.c b/pkg.c index 6a8675e..543bedb 100644 --- a/pkg.c +++ b/pkg.c @@ -848,13 +848,11 @@ pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags) } pkg_fragment_t * -pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags) +pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags) { - pkg_fragment_t *head = NULL; + pkg_traverse(root, pkg_cflags_collect, list, maxdepth, flags); - pkg_traverse(root, pkg_cflags_collect, &head, maxdepth, flags); - - return head; + return *list; } static void @@ -874,11 +872,9 @@ pkg_libs_collect(pkg_t *pkg, void *data, unsigned int flags) } pkg_fragment_t * -pkg_libs(pkg_t *root, int maxdepth, unsigned int flags) +pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags) { - pkg_fragment_t *head = NULL; + pkg_traverse(root, pkg_libs_collect, list, maxdepth, flags); - pkg_traverse(root, pkg_libs_collect, &head, maxdepth, flags); - - return head; + return *list; } diff --git a/pkg.h b/pkg.h index 8c32dba..d548e71 100644 --- a/pkg.h +++ b/pkg.h @@ -134,8 +134,8 @@ unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags); int pkg_compare_version(const char *a, const char *b); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); const char *pkg_get_comparator(pkg_dependency_t *pkgdep); -pkg_fragment_t *pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags); -pkg_fragment_t *pkg_libs(pkg_t *root, int maxdepth, unsigned int flags); +pkg_fragment_t *pkg_cflags(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags); +pkg_fragment_t *pkg_libs(pkg_t *root, pkg_fragment_t **list, int maxdepth, unsigned int flags); /* parse.c */ pkg_t *pkg_new_from_file(const char *path, FILE *f);