summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2007-10-14 23:24:24 +0000
committerrillig <rillig@pkgsrc.org>2007-10-14 23:24:24 +0000
commit9d0009f173aff9a090c264886c77ea6d36567cb9 (patch)
tree3ceb259cb89d70ecaf9f0afb4d5b3b5cf382e531 /pkgtools
parentd73cd46a60a95b6f40ac45b086ed1349b7b5d334 (diff)
downloadpkgsrc-9d0009f173aff9a090c264886c77ea6d36567cb9.tar.gz
Fixed the problem with package name matching that Klaus Heinz discovered
in http://mail-index.netbsd.org/tech-pkg/2007/10/14/0004.html The pattern "pkg_install" matched "pkg-install-20070828", but "pkg*all" didn't. Now it does.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/lib/opattern.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/pkgtools/pkg_install/files/lib/opattern.c b/pkgtools/pkg_install/files/lib/opattern.c
index c63d7eada6f..cd0bb186119 100644
--- a/pkgtools/pkg_install/files/lib/opattern.c
+++ b/pkgtools/pkg_install/files/lib/opattern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: opattern.c,v 1.3 2007/08/12 16:47:18 joerg Exp $ */
+/* $NetBSD: opattern.c,v 1.4 2007/10/14 23:24:24 rillig Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +11,7 @@
#if 0
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
#else
-__RCSID("$NetBSD: opattern.c,v 1.3 2007/08/12 16:47:18 joerg Exp $");
+__RCSID("$NetBSD: opattern.c,v 1.4 2007/10/14 23:24:24 rillig Exp $");
#endif
#endif
@@ -139,11 +139,27 @@ pkg_match(const char *pattern, const char *pkg)
}
if (strpbrk(pattern, "*?[]") != (char *) NULL) {
/* glob match */
- return glob_match(pattern, pkg);
+ if (glob_match(pattern, pkg))
+ return 1;
}
-
+
/* no alternate, dewey or glob match -> simple compare */
- return simple_match(pattern, pkg);
+ if (simple_match(pattern, pkg))
+ return 1;
+
+ /* globbing patterns and simple matches may be specified with or
+ * without the version number, so check for both cases. */
+
+ {
+ char *pattern_ver;
+ int retval;
+
+ if (asprintf(&pattern_ver, "%s-[0-9]*", pattern) == -1)
+ errx(EXIT_FAILURE, "Out of memory");
+ retval = glob_match(pattern_ver, pkg);
+ free(pattern_ver);
+ return retval;
+ }
}
int