libpkgconf: pkg: use pkgconf_fragment_copy_list() to clean up cflags gathering logic (closes #20)

feature/tap-sh
William Pitcock 2019-01-14 13:48:23 -06:00
parent 36a5b7acbd
commit 6854265f28
1 changed files with 11 additions and 7 deletions

View File

@ -1573,18 +1573,22 @@ pkgconf_pkg_cflags(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t
{ {
unsigned int eflag; unsigned int eflag;
unsigned int skip_flags = (client->flags & PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS) == 0 ? PKGCONF_PKG_DEPF_INTERNAL : 0; unsigned int skip_flags = (client->flags & PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS) == 0 ? PKGCONF_PKG_DEPF_INTERNAL : 0;
pkgconf_list_t frags = PKGCONF_LIST_INITIALIZER;
eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_collect, &frags, maxdepth, skip_flags);
if (eflag == PKGCONF_PKG_ERRF_OK && client->flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_private_collect, &frags, maxdepth, skip_flags);
eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_collect, list, maxdepth, skip_flags);
if (eflag != PKGCONF_PKG_ERRF_OK) if (eflag != PKGCONF_PKG_ERRF_OK)
pkgconf_fragment_free(list);
if (client->flags & PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS)
{ {
eflag = pkgconf_pkg_traverse(client, root, pkgconf_pkg_cflags_private_collect, list, maxdepth, skip_flags); pkgconf_fragment_free(&frags);
if (eflag != PKGCONF_PKG_ERRF_OK) return eflag;
pkgconf_fragment_free(list);
} }
pkgconf_fragment_copy_list(client, list, &frags);
pkgconf_fragment_free(&frags);
return eflag; return eflag;
} }