summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2021-11-24 16:51:09 +0000
committerMarc Espie <espie@cvs.openbsd.org>2021-11-24 16:51:09 +0000
commitb2694f44308fc90bfc2050c1448a3c43c78c72d1 (patch)
treea61160c7c9b373bb47827041d9cfdeeac08c4263 /usr.sbin
parent0fc180c98d62fd9b9c7d168f02bd0440407fa8d4 (diff)
preliminary work: have the compiled_stemlist be case independent.
This has not useful repercussions so far, as the actual package name comparison is done with case dependent regexps, but this will allow searching for "user specs" as case independent in the future, allowing stuff like pkg_add graphicsmagick to work.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageName.pm22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm
index f4036deb1ce..3225c662d56 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.54 2020/03/26 19:31:39 jca Exp $
+# $OpenBSD: PackageName.pm,v 1.55 2021/11/24 16:51:08 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -81,6 +81,13 @@ sub splitstem
}
}
+sub pkg2stem
+{
+ my $s = splitstem(shift);
+ $s =~ tr/A-Z/a-z/;
+ return $s;
+
+}
sub is_stem
{
my $s = shift;
@@ -95,9 +102,7 @@ sub compile_stemlist
{
my $hash = {};
for my $n (@_) {
- my $stem = splitstem($n);
- $hash->{$stem} = {} unless defined $hash->{$stem};
- $hash->{$stem}{$n} = 1;
+ $hash->{pkg2stem($n)}{$n} = 1;
}
bless $hash, "OpenBSD::PackageLocator::_compiled_stemlist";
}
@@ -105,7 +110,7 @@ sub compile_stemlist
sub avail2stems
{
my @avail = @_;
- return OpenBSD::PackageName::compile_stemlist(@avail);
+ return compile_stemlist(@avail);
}
package OpenBSD::PackageLocator::_compiled_stemlist;
@@ -119,15 +124,14 @@ sub find
sub add
{
my ($self, $pkgname) = @_;
- my $stem = OpenBSD::PackageName::splitstem($pkgname);
- $self->{$stem}->{$pkgname} = 1;
+ $self->{OpenBSD::PackageName::pkg2stem($pkgname)}{$pkgname} = 1;
}
sub delete
{
my ($self, $pkgname) = @_;
- my $stem = OpenBSD::PackageName::splitstem($pkgname);
- delete $self->{$stem}->{$pkgname};
+ my $stem = OpenBSD::PackageName::pkg2stem($pkgname);
+ delete $self->{$stem}{$pkgname};
if(keys %{$self->{$stem}} == 0) {
delete $self->{$stem};
}