diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-08-16 11:25:49 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-08-16 11:25:49 +0000 |
commit | 4743ba0489c2dc3b8b32d38608230b94ba67bd6c (patch) | |
tree | d59ffa2b198ecc16526c3e36a2f6102cf7a0d9ce /usr.sbin | |
parent | d9e963e0d81875abf5bb0767337f110b2bbf5ec6 (diff) |
use a hash for compiled stems, to avoid spurious duplicates.
adjust find_updatenames accordingly.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageName.pm | 8 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index e93cecbaa5c..d8ed3bf9fa6 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.7 2005/08/16 10:24:23 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.8 2005/08/16 11:25:48 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -75,8 +75,8 @@ sub compile_stemlist my $hash = {}; for my $n (@_) { my $stem = splitstem($n); - $hash->{$stem} = [] unless defined $hash->{$stem}; - push(@{$hash->{$stem}}, $n); + $hash->{$stem} = {} unless defined $hash->{$stem}; + $hash->{$stem}->{$n} = 1; } bless $hash, "OpenBSD::PackageLocator::_compiled_stemlist"; } @@ -86,7 +86,7 @@ package OpenBSD::PackageLocator::_compiled_stemlist; sub findstem { my ($self, $stem) = @_; - return $self->{$stem}; + return keys %{$self->{$stem}}; } 1; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index c44666f1f82..6244dac7a9b 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.180 2005/08/16 10:28:53 espie Exp $ +# $OpenBSD: pkg_add,v 1.181 2005/08/16 11:25:48 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -537,19 +537,19 @@ sub find_updates } else { $stem = OpenBSD::PackageName::splitstem($pkgname); } - my $l = $hash->findstem($stem); - if (!defined $l) { + my @l = $hash->findstem($stem); + if (@l == 0) { push(@cantupdate, $pkgname); next; } my @l2 = (); - if (@$l == 1 && $state->{forced}->{pkgpath}) { - print "Directly updating $pkgname -> ", $l->[0], "\n"; - push(@$new, $l->[0]); + if (@l == 1 && $state->{forced}->{pkgpath}) { + print "Directly updating $pkgname -> ", $l[0], "\n"; + push(@$new, $l[0]); next; } my $plist = OpenBSD::PackingList->from_installation($pkgname, \&OpenBSD::PackingList::ExtraInfoOnly); - for my $candidate (@$l) { + for my $candidate (@l) { my $handle = OpenBSD::PackageLocator->find($candidate, $state->{arch}); if (!$handle) { next; |