summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkgtools/pbulk/Makefile4
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/match.c26
2 files changed, 27 insertions, 3 deletions
diff --git a/pkgtools/pbulk/Makefile b/pkgtools/pbulk/Makefile
index 68d68904f36..f0819fa5441 100644
--- a/pkgtools/pbulk/Makefile
+++ b/pkgtools/pbulk/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.46 2008/09/16 18:21:30 joerg Exp $
+# $NetBSD: Makefile,v 1.47 2008/09/22 11:31:16 joerg Exp $
-DISTNAME= pbulk-0.34
+DISTNAME= pbulk-0.35
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pbulk/files/pbulk/lib/match.c b/pkgtools/pbulk/files/pbulk/lib/match.c
index fdd8af26a77..e68308443b6 100644
--- a/pkgtools/pbulk/files/pbulk/lib/match.c
+++ b/pkgtools/pbulk/files/pbulk/lib/match.c
@@ -1,4 +1,4 @@
-/* $NetBSD: match.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
+/* $NetBSD: match.c,v 1.3 2008/09/22 11:31:16 joerg Exp $ */
/*
* Copyright © 2002 Alistair G. Crooks. All rights reserved.
@@ -456,11 +456,35 @@ simple_match(const char *pattern, const char *pkg)
}
/*
+ * Performs a fast check if pattern can ever match pkg.
+ * Returns 1 if a match is possible and 0 otherwise.
+ */
+static int
+quick_pkg_match(const char *pattern, const char *pkg)
+{
+#define simple(x) (isalnum((unsigned char)(x)) || (x) == '-')
+ if (!simple(pattern[0]))
+ return 1;
+ if (pattern[0] != pkg[0])
+ return 0;
+
+ if (!simple(pattern[1]))
+ return 1;
+ if (pattern[1] != pkg[1])
+ return 0;
+ return 1;
+#undef simple
+}
+
+/*
* Match pkg against pattern, return 1 if matching, 0 else
*/
int
pkg_match(const char *pattern, const char *pkg)
{
+ if (quick_pkg_match(pattern, pkg) == 0)
+ return 0;
+
if (strchr(pattern, '{') != (char *) NULL) {
/* emulate csh-type alternates */
return alternate_match(pattern, pkg);