summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2005-10-26 09:35:32 +0000
committerespie <espie@openbsd.org>2005-10-26 09:35:32 +0000
commitfd31a552bd3210c92cb3f556a2aeae371d01e86d (patch)
treeb2888fec8579e55f323456b82ba1d9464434489e
parentAdapt art(4) to the new link state handling done by sppp(4). (diff)
downloadwireguard-openbsd-fd31a552bd3210c92cb3f556a2aeae371d01e86d.tar.xz
wireguard-openbsd-fd31a552bd3210c92cb3f556a2aeae371d01e86d.zip
minor clean-up, unhardcode test for type, use a table instead.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Ustar.pm33
1 files changed, 16 insertions, 17 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
index d409894b2da..9a683be9c8f 100644
--- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Ustar.pm,v 1.38 2005/09/24 12:07:38 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.39 2005/10/26 09:35:32 espie Exp $
#
# Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org>
#
@@ -75,6 +75,17 @@ sub skip
$self->{swallow} = 0;
}
+my $types = {
+ DIR , 'OpenBSD::Ustar::Dir',
+ HARDLINK , 'OpenBSD::Ustar::HardLink',
+ SOFTLINK , 'OpenBSD::Ustar::SoftLink',
+ FILE , 'OpenBSD::Ustar::File',
+ FILE1 , 'OpenBSD::Ustar::File',
+ FIFO , 'OpenBSD::Ustar::Fifo',
+ CHARDEVICE , 'OpenBSD::Ustar::CharDevice',
+ BLOCKDEVICE , 'OpenBSD::Ustar::BlockDevice',
+};
+
sub next
{
my $self = shift;
@@ -134,23 +145,11 @@ sub next
minor => $minor,
archive => $self,
destdir => $self->{destdir}
- };
- if ($type eq DIR) {
- bless $result, 'OpenBSD::Ustar::Dir';
- } elsif ($type eq HARDLINK) {
- bless $result, 'OpenBSD::Ustar::HardLink';
- } elsif ($type eq SOFTLINK) {
- bless $result, 'OpenBSD::Ustar::SoftLink';
- } elsif ($type eq FILE || $type eq FILE1) {
- bless $result, 'OpenBSD::Ustar::File';
- } elsif ($type eq FIFO) {
- bless $result, 'OpenBSD::Ustar::Fifo';
- } elsif ($type eq CHARDEVICE) {
- bless $result, 'OpenBSD::Ustar::CharDevice';
- } elsif ($type eq BLOCKDEVICE) {
- bless $result, 'OpenBSD::Ustar::BlockDevice';
+ };
+ if (defined $types->{$type}) {
+ bless $result, $types->{$type};
} else {
- die "Unsupported type";
+ die "Unsupported type $type";
}
if (!$result->isFile()) {
if ($size != 0) {