summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig>2007-10-14 23:24:24 +0000
committerrillig <rillig>2007-10-14 23:24:24 +0000
commitefd0aa0b61db85704764d03f0c2c388fc393963d (patch)
tree3ceb259cb89d70ecaf9f0afb4d5b3b5cf382e531 /pkgtools
parent97dff1f0fb05bd73efc310edae2a2d3f47ee7395 (diff)
downloadpkgsrc-efd0aa0b61db85704764d03f0c2c388fc393963d.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