From 36a5b7acbd30970b6d3bd03e2ea4bc7978aa8308 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 14 Jan 2019 13:48:02 -0600 Subject: [PATCH] libpkgconf: fragment: add pkgconf_fragment_copy_list() --- libpkgconf/fragment.c | 26 ++++++++++++++++++++++++++ libpkgconf/libpkgconf.h | 1 + 2 files changed, 27 insertions(+) diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index 5b686f5..b431694 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -358,6 +358,32 @@ pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, cons pkgconf_node_insert_tail(&frag->iter, frag, list); } +/* + * !doc + * + * .. c:function:: void pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base) + * + * Copies a `fragment list` to another `fragment list`, possibly removing a previous copy of the fragments + * in a process known as `mergeback`. + * + * :param pkgconf_client_t* client: The pkgconf client being accessed. + * :param pkgconf_list_t* list: The list the fragments are being added to. + * :param pkgconf_list_t* base: The list the fragments are being copied from. + * :return: nothing + */ +void +pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base) +{ + pkgconf_node_t *node; + + PKGCONF_FOREACH_LIST_ENTRY(base->head, node) + { + pkgconf_fragment_t *frag = node->data; + + pkgconf_fragment_copy(client, list, frag, true); + } +} + /* * !doc * diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 3e8db08..7169235 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -319,6 +319,7 @@ typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, c PKGCONF_API bool pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value); PKGCONF_API void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string); PKGCONF_API void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private); +PKGCONF_API void pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base); PKGCONF_API void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node); PKGCONF_API void pkgconf_fragment_free(pkgconf_list_t *list); PKGCONF_API void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data);