libpkgconf: dependency: allow dependency nodes to be colored with traits

feature/tap-sh
William Pitcock 2018-03-18 18:01:59 -05:00
parent 9a53290d8a
commit ad65bc4a71
4 changed files with 26 additions and 17 deletions

View File

@ -1016,7 +1016,7 @@ main(int argc, char *argv[])
while (argv[pkg_optind]) while (argv[pkg_optind])
{ {
pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind]); pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind], 0);
pkg_optind++; pkg_optind++;
} }
@ -1046,7 +1046,7 @@ main(int argc, char *argv[])
while (argv[pkg_optind]) while (argv[pkg_optind])
{ {
pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind]); pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind], 0);
pkg_optind++; pkg_optind++;
} }
@ -1076,7 +1076,7 @@ main(int argc, char *argv[])
while (argv[pkg_optind]) while (argv[pkg_optind])
{ {
pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind]); pkgconf_dependency_parse_str(&pkg_client, &deplist, argv[pkg_optind], 0);
pkg_optind++; pkg_optind++;
} }

View File

@ -53,7 +53,7 @@ dependency_to_str(const pkgconf_dependency_t *dep, char *buf, size_t buflen)
} }
static inline pkgconf_dependency_t * static inline pkgconf_dependency_t *
pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare) pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare, unsigned int flags)
{ {
pkgconf_dependency_t *dep; pkgconf_dependency_t *dep;
char depbuf[PKGCONF_ITEM_SIZE]; char depbuf[PKGCONF_ITEM_SIZE];
@ -65,8 +65,9 @@ pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list,
dep->version = pkgconf_strndup(version, version_sz); dep->version = pkgconf_strndup(version, version_sz);
dep->compare = compare; dep->compare = compare;
dep->flags = flags;
PKGCONF_TRACE(client, "added dependency [%s] to list @%p", dependency_to_str(dep, depbuf, sizeof depbuf), list); PKGCONF_TRACE(client, "added dependency [%s] to list @%p; flags=%x", dependency_to_str(dep, depbuf, sizeof depbuf), list, dep->flags);
pkgconf_node_insert_tail(&dep->iter, dep, list); pkgconf_node_insert_tail(&dep->iter, dep, list);
return dep; return dep;
@ -84,16 +85,17 @@ pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list,
* :param char* package: The package `atom` to set on the dependency node. * :param char* package: The package `atom` to set on the dependency node.
* :param char* version: The package `version` to set on the dependency node. * :param char* version: The package `version` to set on the dependency node.
* :param pkgconf_pkg_comparator_t compare: The comparison operator to set on the dependency node. * :param pkgconf_pkg_comparator_t compare: The comparison operator to set on the dependency node.
* :param uint flags: Any flags to attach to the dependency node.
* :return: A dependency node. * :return: A dependency node.
* :rtype: pkgconf_dependency_t * * :rtype: pkgconf_dependency_t *
*/ */
pkgconf_dependency_t * pkgconf_dependency_t *
pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare) pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare, unsigned int flags)
{ {
if (version != NULL) if (version != NULL)
return pkgconf_dependency_addraw(client, list, package, strlen(package), version, strlen(version), compare); return pkgconf_dependency_addraw(client, list, package, strlen(package), version, strlen(version), compare, flags);
return pkgconf_dependency_addraw(client, list, package, strlen(package), NULL, 0, compare); return pkgconf_dependency_addraw(client, list, package, strlen(package), NULL, 0, compare, flags);
} }
/* /*
@ -157,10 +159,11 @@ pkgconf_dependency_free(pkgconf_list_t *list)
* :param pkgconf_client_t* client: The client object that owns the package this dependency list belongs to. * :param pkgconf_client_t* client: The client object that owns the package this dependency list belongs to.
* :param pkgconf_list_t* deplist_head: The dependency list to populate with dependency nodes. * :param pkgconf_list_t* deplist_head: The dependency list to populate with dependency nodes.
* :param char* depends: The dependency data to parse. * :param char* depends: The dependency data to parse.
* :param uint flags: Any flags to attach to the dependency nodes.
* :return: nothing * :return: nothing
*/ */
void void
pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends) pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags)
{ {
parse_state_t state = OUTSIDE_MODULE; parse_state_t state = OUTSIDE_MODULE;
pkgconf_pkg_comparator_t compare = PKGCONF_CMP_ANY; pkgconf_pkg_comparator_t compare = PKGCONF_CMP_ANY;
@ -227,7 +230,7 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep
if (state == OUTSIDE_MODULE) if (state == OUTSIDE_MODULE)
{ {
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, NULL, 0, compare); pkgconf_dependency_addraw(client, deplist_head, package, package_sz, NULL, 0, compare, flags);
compare = PKGCONF_CMP_ANY; compare = PKGCONF_CMP_ANY;
package_sz = 0; package_sz = 0;
@ -270,7 +273,7 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep
version_sz = ptr - vstart; version_sz = ptr - vstart;
state = OUTSIDE_MODULE; state = OUTSIDE_MODULE;
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, version, version_sz, compare); pkgconf_dependency_addraw(client, deplist_head, package, package_sz, version, version_sz, compare, flags);
compare = PKGCONF_CMP_ANY; compare = PKGCONF_CMP_ANY;
cnameptr = cmpname; cnameptr = cmpname;
@ -300,13 +303,14 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep
* :param pkgconf_pkg_t* pkg: The package object that owns this dependency list. * :param pkgconf_pkg_t* pkg: The package object that owns this dependency list.
* :param pkgconf_list_t* deplist: The dependency list to populate with dependency nodes. * :param pkgconf_list_t* deplist: The dependency list to populate with dependency nodes.
* :param char* depends: The dependency data to parse. * :param char* depends: The dependency data to parse.
* :param uint flags: Any flags to attach to the dependency nodes.
* :return: nothing * :return: nothing
*/ */
void void
pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends) pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends, unsigned int flags)
{ {
char *kvdepends = pkgconf_tuple_parse(client, &pkg->vars, depends); char *kvdepends = pkgconf_tuple_parse(client, &pkg->vars, depends);
pkgconf_dependency_parse_str(client, deplist, kvdepends); pkgconf_dependency_parse_str(client, deplist, kvdepends, flags);
free(kvdepends); free(kvdepends);
} }

View File

@ -90,6 +90,8 @@ struct pkgconf_dependency_ {
char *version; char *version;
pkgconf_pkg_t *parent; pkgconf_pkg_t *parent;
pkgconf_pkg_t *match; pkgconf_pkg_t *match;
unsigned int flags;
}; };
struct pkgconf_tuple_ { struct pkgconf_tuple_ {
@ -214,6 +216,9 @@ PKGCONF_API void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgc
#define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x0400 #define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x0400
#define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x0800 #define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x0800
#define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000 #define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000
#define PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS 0x2000
#define PKGCONF_PKG_DEPF_INTERNAL 0x1
#define PKGCONF_PKG_ERRF_OK 0x0 #define PKGCONF_PKG_ERRF_OK 0x0
#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1
@ -266,11 +271,11 @@ PKGCONF_API void pkgconf_pkg_dir_list_build(pkgconf_client_t *client);
/* parse.c */ /* parse.c */
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *path, FILE *f); PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *path, FILE *f);
PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends); PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags);
PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends); PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags);
PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail); PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list); PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list);
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare); PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare, unsigned int flags);
/* argvsplit.c */ /* argvsplit.c */
PKGCONF_API int pkgconf_argv_split(const char *src, int *argc, char ***argv); PKGCONF_API int pkgconf_argv_split(const char *src, int *argc, char ***argv);

View File

@ -77,7 +77,7 @@ pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_li
pkgconf_queue_t *pkgq; pkgconf_queue_t *pkgq;
pkgq = iter->data; pkgq = iter->data;
pkgconf_dependency_parse(client, world, &world->required, pkgq->package); pkgconf_dependency_parse(client, world, &world->required, pkgq->package, 0);
} }
return (world->required.head != NULL); return (world->required.head != NULL);