pkg: allow pkg_cflags() and pkg_libs() utility functions to have a user-provided list pointer.

Also chase this change in the frontend.
pull/36/head
William Pitcock 2012-08-08 11:04:07 -05:00
parent 80ad957788
commit 84ea074fbe
3 changed files with 13 additions and 15 deletions

8
main.c
View File

@ -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;

16
pkg.c
View File

@ -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;
}

4
pkg.h
View File

@ -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);