dependency: add pkg_dependency_parse_str() for breaking out a dependency list that has already been substituted.

feature/tap-sh
William Pitcock 2012-07-01 21:44:30 -05:00
parent fc923cb97a
commit 4edd04b16b
2 changed files with 15 additions and 5 deletions

View File

@ -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;
}

1
pkg.h
View File

@ -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);