summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-13 10:10:36 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-13 10:10:36 +0000
commitea569d48a6e6544e4441046846859f19a9f1c3e4 (patch)
treefc861d8632ce62a5e9ec04c368728d373929ebb6 /usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
parent7e4f94da6b49e42d5429fab9b97e960c5627c075 (diff)
tweak _first_of so it can take an extra $filter routine, so that we
get the first set of results that are non empty after filtering properly.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
index 7ea26baaa3b..e74a19db8d5 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageRepositoryList.pm,v 1.6 2007/05/13 09:31:24 espie Exp $
+# $OpenBSD: PackageRepositoryList.pm,v 1.7 2007/05/13 10:10:35 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -103,9 +103,12 @@ sub available
sub _first_of
{
- my ($self, $method, @args) = @_;
+ my ($self, $method, $filter, @args) = @_;
for my $repo (@{$self->{list}}) {
my @l = $repo->$method(@args);
+ if (defined $filter) {
+ @l = &$filter(@l);
+ }
if (@l > 0) {
return @l;
}
@@ -115,20 +118,20 @@ sub _first_of
sub find_partialstem
{
- my ($self, $partial) = @_;
- return $self->_first_of('find_partialstem', $partial);
+ my ($self, $partial, $filter) = @_;
+ return $self->_first_of('find_partialstem', $filter, $partial);
}
sub findstem
{
- my ($self, $stem) = @_;
- return $self->_first_of('findstem', $stem);
+ my ($self, $stem, $filter) = @_;
+ return $self->_first_of('findstem', $filter, $stem);
}
sub match_spec
{
- my ($self, $spec) = @_;
- return $self->_first_of('match_spec', $spec);
+ my ($self, $spec, $filter) = @_;
+ return $self->_first_of('match_spec', $filter, $spec);
}
sub cleanup