diff --git a/libpkgconf/dependency.c b/libpkgconf/dependency.c index cc20afd..1c7c8ff 100644 --- a/libpkgconf/dependency.c +++ b/libpkgconf/dependency.c @@ -36,7 +36,7 @@ typedef enum { #define DEBUG_PARSE 0 static inline pkgconf_dependency_t * -pkgconf_dependency_add(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(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_t *dep; @@ -53,6 +53,15 @@ pkgconf_dependency_add(pkgconf_list_t *list, const char *package, size_t package return dep; } +pkgconf_dependency_t * +pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare) +{ + if (version != NULL) + return pkgconf_dependency_addraw(list, package, strlen(package), version, strlen(version), compare); + + return pkgconf_dependency_addraw(list, package, strlen(package), NULL, 0, compare); +} + void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail) { @@ -146,7 +155,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends) if (state == OUTSIDE_MODULE) { - pkgconf_dependency_add(deplist_head, package, package_sz, NULL, 0, compare); + pkgconf_dependency_addraw(deplist_head, package, package_sz, NULL, 0, compare); compare = PKGCONF_CMP_ANY; package_sz = 0; @@ -190,7 +199,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends) version_sz = ptr - vstart; state = OUTSIDE_MODULE; - pkgconf_dependency_add(deplist_head, package, package_sz, version, version_sz, compare); + pkgconf_dependency_addraw(deplist_head, package, package_sz, version, version_sz, compare); compare = PKGCONF_CMP_ANY; cnameptr = cmpname; diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index a45ea88..7f740a4 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -168,6 +168,7 @@ void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depe void pkgconf_dependency_parse(pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends); void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail); void pkgconf_dependency_free(pkgconf_list_t *list); +pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare); /* argvsplit.c */ int pkgconf_argv_split(const char *src, int *argc, char ***argv);