From b6e2dd03f588656c5d853aca37cf75916e2d6b2e Mon Sep 17 00:00:00 2001 From: Anthony Mallet Date: Sun, 31 Jul 2011 23:01:00 +0200 Subject: [PATCH 2/3] [pkgtools/pkg_install] Do not reinvent pkg_match() for matching a pkg basename Packages may be given by basename (i.e. without version) on the pkg_info et al. command line. In this case, the operation is performed on any installed package matching the given basename. Instead of reinventing the matching algorithm, use pkg_match() on the result of the new pkgaddwildcard() function. --- pkgtools/pkg_install/files/lib/iterate.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git pkgtools/pkg_install/files/lib/iterate.c pkgtools/pkg_install/files/lib/iterate.c index 36778a0..c767ace 100644 --- pkgtools/pkg_install/files/lib/iterate.c +++ pkgtools/pkg_install/files/lib/iterate.c @@ -171,17 +171,14 @@ static int match_by_basename(const char *pkg, void *cookie) { const char *target = cookie; - const char *pkg_version; + char *target_pattern; + int match; - if ((pkg_version = strrchr(pkg, '-')) == NULL) { - warnx("Entry %s in pkgdb is not a valid package name", pkg); - return 0; - } - if (strncmp(pkg, target, pkg_version - pkg) == 0 && - pkg + strlen(target) == pkg_version) - return 1; - else - return 0; + target_pattern = addpkgwildcard(target); + match = pkg_match(target_pattern, pkg); + free(target_pattern); + + return match; } static int -- 1.8.5.1