diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-07-09 17:53:16 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-07-09 17:53:16 +0000 |
commit | ed9f4ce03ac493ab133ff1849f45a52ef03d1f1b (patch) | |
tree | f207289493ca3e027ce681591cd75a47f4183754 /usr.bin/libtool | |
parent | 8ad199f22e945b1c922440d8a2ee710b4fc887a5 (diff) |
finally, also do accessors for short options. Turns out to be useful.
fix the array accessor...
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r-- | usr.bin/libtool/LT/Getopt.pm | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/usr.bin/libtool/LT/Getopt.pm b/usr.bin/libtool/LT/Getopt.pm index 5302811cd8c..82c5fe0a52f 100644 --- a/usr.bin/libtool/LT/Getopt.pm +++ b/usr.bin/libtool/LT/Getopt.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Getopt.pm,v 1.6 2012/07/09 13:37:39 espie Exp $ +# $OpenBSD: Getopt.pm,v 1.7 2012/07/09 17:53:15 espie Exp $ # Copyright (c) 2012 Marc Espie <espie@openbsd.org> # @@ -39,13 +39,16 @@ sub new bless \$v, $class; } -package Option::Short; -our @ISA = qw(Option); sub setup { - # short options don't make accessors + my ($self, $opts, $isarray) = @_; + $opts->add_option_accessor($$self, $isarray); + return $self; } +package Option::Short; +our @ISA = qw(Option); + sub match { my ($self, $_, $opts, $canonical, $code) = @_; @@ -81,13 +84,6 @@ sub match package Option::Long; our @ISA = qw(Option); -sub setup -{ - my ($self, $opts, $isarray) = @_; - $opts->add_option_accessor($$self, $isarray); - return $self; -} - sub match { my ($self, $_, $opts, $canonical, $code) = @_; @@ -132,8 +128,8 @@ sub new sub setup { - my ($self, $allopts) = @_; - $self->{alt}[0]->setup($allopts); + my ($self, $allopts, $isarray) = @_; + $self->{alt}[0]->setup($allopts, $isarray); return $self; } @@ -167,6 +163,7 @@ sub add_option_accessor my $actual = $isarray ? sub { my $self = shift; + $self->{opt}{$option} //= []; if (wantarray) { return @{$self->{opt}{$option}}; } else { |