From 4edd04b16be44dbd94b73866ad53b2a16608110c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 1 Jul 2012 21:44:30 -0500 Subject: [PATCH] dependency: add pkg_dependency_parse_str() for breaking out a dependency list that has already been substituted. --- dependency.c | 19 ++++++++++++++----- pkg.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dependency.c b/dependency.c index 75b1f48..1854dd0 100644 --- a/dependency.c +++ b/dependency.c @@ -107,22 +107,19 @@ pkg_dependency_free(pkg_dependency_t *head) } pkg_dependency_t * -pkg_dependency_parse(pkg_t *pkg, const char *depends) +pkg_dependency_parse_str(pkg_dependency_t *deplist_head, const char *depends) { parse_state_t state = OUTSIDE_MODULE; pkg_dependency_t *deplist = NULL; - pkg_dependency_t *deplist_head = NULL; pkg_comparator_t compare = PKG_ANY; char buf[BUFSIZ]; - char *kvdepends = pkg_tuple_parse(pkg->vars, depends); char *start = buf; char *ptr = buf; char *vstart = NULL; char *package = NULL, *version = NULL; - strlcpy(buf, kvdepends, sizeof buf); + strlcpy(buf, depends, sizeof buf); strlcat(buf, " ", sizeof buf); - free(kvdepends); while (*ptr) { @@ -294,3 +291,15 @@ pkg_dependency_parse(pkg_t *pkg, const char *depends) return deplist_head; } + +pkg_dependency_t * +pkg_dependency_parse(pkg_t *pkg, const char *depends) +{ + pkg_dependency_t *list = NULL; + char *kvdepends = pkg_tuple_parse(pkg->vars, depends); + + list = pkg_dependency_parse_str(list, kvdepends); + free(kvdepends); + + return list; +} diff --git a/pkg.h b/pkg.h index b71e6e8..4f15b58 100644 --- a/pkg.h +++ b/pkg.h @@ -139,6 +139,7 @@ pkg_fragment_t *pkg_libs(pkg_t *root, int maxdepth, unsigned int flags); /* parse.c */ pkg_t *pkg_new_from_file(const char *path, FILE *f); +pkg_dependency_t *pkg_dependency_parse_str(pkg_dependency_t *deplist_head, const char *depends); pkg_dependency_t *pkg_dependency_parse(pkg_t *pkg, const char *depends); pkg_dependency_t *pkg_dependency_append(pkg_dependency_t *head, pkg_dependency_t *tail); void pkg_dependency_free(pkg_dependency_t *head);