diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-10-11 14:11:43 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-10-11 14:11:43 +0000 |
commit | 8c187667526f0b92c160389dc487070b374f04bb (patch) | |
tree | 24e90e81973a8c11156b34cb13fc990fd80628a8 /usr.sbin | |
parent | d8172283289fd503a4f62261a7b1ebc2af32ca7a (diff) |
better visitor, that allows for revisits later.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index 152a0874c0a..2592731fa09 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.26 2004/09/24 08:49:27 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.27 2004/10/11 14:11:42 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -146,34 +146,6 @@ sub write } } -sub visit -{ - my ($self, $method, @l) = @_; - - if (defined $self->{cvstags}) { - for my $item (@{$self->{cvstags}}) { - $item->$method(@l); - } - } - - for my $special (OpenBSD::PackageInfo::info_names()) { - $self->{$special}->$method(@l, 0) if defined $self->{$special}; - } - - for my $unique_item (qw(name no-default-conflict manual-installation extrainfo arch)) { - $self->{$unique_item}->$method(@l) if defined $self->{$unique_item}; - } - for my $listname (qw(modules pkgcfl conflict pkgdep newdepend libdepend groups users items)) { - if (defined $self->{$listname}) { - for my $item (@{$self->{$listname}}) { - $item->$method(@l); - } - } - } - for my $special (OpenBSD::PackageInfo::info_names()) { - $self->{$special}->$method(@l, 1) if defined $self->{$special}; - } -} sub fromfile { @@ -240,4 +212,55 @@ sub pkgbase($) } } + +{ + package OpenBSD::PackingList::Visitor; + sub new + { + my $class = shift; + bless {list=>[], pass=>1}, $class; + } + + sub revisit + { + my ($self, $item) = @_; + push(@{$self->{list}}, $item); + } +} + +sub visit +{ + my ($self, $method, @l) = @_; + + my $visitor = new OpenBSD::PackingList::Visitor; + + push(@l, $visitor); + + if (defined $self->{cvstags}) { + for my $item (@{$self->{cvstags}}) { + $item->$method(@l); + } + } + + for my $unique_item (qw(name no-default-conflict manual-installation extrainfo arch)) { + $self->{$unique_item}->$method(@l) if defined $self->{$unique_item}; + } + + for my $special (OpenBSD::PackageInfo::info_names()) { + $self->{$special}->$method(@l) if defined $self->{$special}; + } + + for my $listname (qw(modules pkgcfl conflict pkgdep newdepend libdepend groups users items)) { + if (defined $self->{$listname}) { + for my $item (@{$self->{$listname}}) { + $item->$method(@l); + } + } + } + $visitor->{pass} = 2; + while (my $item = shift @{$visitor->{list}}) { + $item->method(@l); + } +} + 1; |