summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-13 10:16:07 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-13 10:16:07 +0000
commitcc0894fe2ef0790d026f9fc0f47212569f752a50 (patch)
treeda28ebb9ac39132d9e003f1b97d31aa2eb96b6fb /usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
parentea569d48a6e6544e4441046846859f19a9f1c3e4 (diff)
allow filtering while calling the Locator.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageLocator.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocator.pm26
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
index 1c7673748eb..2f26d5fd9f4 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocator.pm,v 1.63 2007/05/12 15:00:30 espie Exp $
+# $OpenBSD: PackageLocator.pm,v 1.64 2007/05/13 10:16:06 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -119,18 +119,22 @@ my @avail;
sub match_spec
{
- my ($class, $spec) = @_;
+ my ($class, $spec, $filter) = @_;
if (!@avail) {
@avail = available();
}
- return $spec->match_ref(\@avail);
+ if (defined $filter) {
+ return &$filter($spec->match_ref(\@avail));
+ } else {
+ return $spec->match_ref(\@avail);
+ }
}
my $stemlist;
sub findstem
{
- my ($class, $stem) = @_;
+ my ($class, $stem, $filter) = @_;
if (!@avail) {
@avail = available();
}
@@ -138,12 +142,16 @@ sub findstem
if (!$stemlist) {
$stemlist = OpenBSD::PackageName::avail2stems(@avail);
}
- return $stemlist->findstem($stem);
+ if (defined $filter) {
+ return &$filter($stemlist->findstem($stem));
+ } else {
+ return $stemlist->findstem($stem);
+ }
}
sub find_partialstem
{
- my ($class, $partial) = @_;
+ my ($class, $partial, $filter) = @_;
if (!@avail) {
@avail = available();
}
@@ -151,7 +159,11 @@ sub find_partialstem
if (!$stemlist) {
$stemlist = OpenBSD::PackageName::avail2stems(@avail);
}
- return $stemlist->find_partialstem($partial);
+ if (defined $filter) {
+ return &$filter($stemlist->find_partialstem($partial));
+ } else {
+ return $stemlist->find_partialstem($partial);
+ }
}
1;