pkg: split pkgconf_pkg_traverse into a serial-modifying version

master
Ariadne Conill 2022-06-26 06:05:40 +00:00
parent ffa0805d58
commit 6ae17bd0ef
1 changed files with 25 additions and 6 deletions

View File

@ -37,6 +37,14 @@
#define PKG_CONFIG_EXT ".pc" #define PKG_CONFIG_EXT ".pc"
static unsigned int
pkgconf_pkg_traverse_main(pkgconf_client_t *client,
pkgconf_pkg_t *root,
pkgconf_pkg_traverse_func_t func,
void *data,
int maxdepth,
unsigned int skip_flags);
static inline bool static inline bool
str_has_suffix(const char *str, const char *suffix) str_has_suffix(const char *str, const char *suffix)
{ {
@ -1478,7 +1486,7 @@ pkgconf_pkg_walk_list(pkgconf_client_t *client,
pkgconf_audit_log_dependency(client, pkgdep, depnode); pkgconf_audit_log_dependency(client, pkgdep, depnode);
pkgdep->serial = client->serial; pkgdep->serial = client->serial;
eflags |= pkgconf_pkg_traverse(client, pkgdep, func, data, depth - 1, skip_flags); eflags |= pkgconf_pkg_traverse_main(client, pkgdep, func, data, depth - 1, skip_flags);
pkgconf_pkg_unref(client, pkgdep); pkgconf_pkg_unref(client, pkgdep);
} }
@ -1548,8 +1556,8 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_client_t *client,
* :return: ``PKGCONF_PKG_ERRF_OK`` on success, else an error code. * :return: ``PKGCONF_PKG_ERRF_OK`` on success, else an error code.
* :rtype: unsigned int * :rtype: unsigned int
*/ */
unsigned int static unsigned int
pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_traverse_main(pkgconf_client_t *client,
pkgconf_pkg_t *root, pkgconf_pkg_t *root,
pkgconf_pkg_traverse_func_t func, pkgconf_pkg_traverse_func_t func,
void *data, void *data,
@ -1561,9 +1569,7 @@ pkgconf_pkg_traverse(pkgconf_client_t *client,
if (maxdepth == 0) if (maxdepth == 0)
return eflags; return eflags;
++client->serial; PKGCONF_TRACE(client, "%s: level %d, serial %lu", root->id, maxdepth, client->serial);
PKGCONF_TRACE(client, "%s: level %d", root->id, maxdepth);
if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (client->flags & PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) != PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (client->flags & PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) != PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL)
{ {
@ -1599,6 +1605,19 @@ pkgconf_pkg_traverse(pkgconf_client_t *client,
return eflags; return eflags;
} }
unsigned int
pkgconf_pkg_traverse(pkgconf_client_t *client,
pkgconf_pkg_t *root,
pkgconf_pkg_traverse_func_t func,
void *data,
int maxdepth,
unsigned int skip_flags)
{
client->serial++;
return pkgconf_pkg_traverse_main(client, root, func, data, maxdepth, skip_flags);
}
static void static void
pkgconf_pkg_cflags_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data) pkgconf_pkg_cflags_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data)
{ {