summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-03-17 20:44:02 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-03-17 20:44:02 +0000
commit71120e9fe8b2420d042106880e298b4a8b95eeb6 (patch)
tree196ce64054938a29b7da61e90d74a2d9ba5c52dd /usr.sbin/pkg_add/OpenBSD
parent448a82ab7cc02488af3f31d7f24fbb2bebc5c534 (diff)
un-special case old constructs: make them inherit from the same class,
and remove any special code from Factory. As it's simpler remove local variables.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm22
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingOld.pm30
2 files changed, 26 insertions, 26 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 71c827b8173..e64c5a90810 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.81 2006/03/05 13:08:05 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.82 2006/03/17 20:44:01 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -27,22 +27,15 @@ require 5.008_000;
# It does provide base methods for stuff under it, though.
package OpenBSD::PackingElement;
our %keyword;
-our %oldkeyword;
sub Factory
{
local $_ = shift;
- if (m/^\@(\S+)\s*/) {
- my $cmd = $1;
- my $args = $';
-
- if (defined $keyword{$cmd}) {
- $keyword{$cmd}->add(@_, $args);
- } elsif (defined $oldkeyword{$cmd}) {
- $oldkeyword{$cmd}->add(@_, $args);
- print STDERR "Warning: obsolete construct: \@$cmd $args\n";
+ if (m/^\@(\S+)\s*(.*)$/) {
+ if (defined $keyword{$1}) {
+ $keyword{$1}->add(@_, $2);
} else {
- print STDERR "Unknown element: \@$cmd $args\n";
+ print STDERR "Unknown element: $_\n";
exit(1);
}
} else {
@@ -56,11 +49,6 @@ sub setKeyword
$keyword{$k} = $class;
}
-sub setOldKeyword {
- my ($class, $k) = @_;
- $oldkeyword{$k} = $class;
-}
-
sub category() { 'items' }
sub new
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingOld.pm b/usr.sbin/pkg_add/OpenBSD/PackingOld.pm
index fcef0195509..0391ea6fdb4 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingOld.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingOld.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingOld.pm,v 1.5 2004/11/08 18:47:35 espie Exp $
+# $OpenBSD: PackingOld.pm,v 1.6 2006/03/17 20:44:01 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -19,31 +19,43 @@ use strict;
use warnings;
use OpenBSD::PackingElement;
-package OpenBSD::PackingElement::Src;
+package OpenBSD::PackingElement::Old;
our @ISA=qw(OpenBSD::PackingElement);
-__PACKAGE__->setOldKeyword('src');
+sub add
+{
+ my ($class, $plist, @args) = @_;
+
+ my $self = $class->new(@args);
+ print STDERR "Warning: obsolete construct: ", $self->fullstring(), "\n";
+ return $self->add_object($plist);
+}
+
+package OpenBSD::PackingElement::Src;
+our @ISA=qw(OpenBSD::PackingElement::Old);
+
+__PACKAGE__->setKeyword('src');
sub keyword() { 'src' }
package OpenBSD::PackingElement::Display;
-our @ISA=qw(OpenBSD::PackingElement);
+our @ISA=qw(OpenBSD::PackingElement::Old);
-__PACKAGE__->setOldKeyword('display');
+__PACKAGE__->setKeyword('display');
sub keyword() { 'display' }
package OpenBSD::PackingElement::Mtree;
-our @ISA=qw(OpenBSD::PackingElement);
+our @ISA=qw(OpenBSD::PackingElement::Old);
-__PACKAGE__->setOldKeyword('mtree');
+__PACKAGE__->setKeyword('mtree');
sub keyword() { 'mtree' }
package OpenBSD::PackingElement::ignore_inst;
-our @ISA=qw(OpenBSD::PackingElement);
+our @ISA=qw(OpenBSD::PackingElement::Old);
-__PACKAGE__->setOldKeyword('ignore_inst');
+__PACKAGE__->setKeyword('ignore_inst');
sub keyword() { 'ignore_inst' }