diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-07-08 11:17:13 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-07-08 11:17:13 +0000 |
commit | d07cf4fdf63f2cf32c2a4e440e97ba8d7218f10e (patch) | |
tree | c9bf724e6dfc76d6eaf5a7095a02d74a00a579c1 /usr.bin/libtool | |
parent | 7e600d1014ea72a86281ce125b56a1c12068140d (diff) |
preparation for handling permuted options
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r-- | usr.bin/libtool/LT/Getopt.pm | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/usr.bin/libtool/LT/Getopt.pm b/usr.bin/libtool/LT/Getopt.pm index 92b8be47bae..48068a47428 100644 --- a/usr.bin/libtool/LT/Getopt.pm +++ b/usr.bin/libtool/LT/Getopt.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Getopt.pm,v 1.3 2012/07/08 10:42:25 espie Exp $ +# $OpenBSD: Getopt.pm,v 1.4 2012/07/08 11:17:12 espie Exp $ # Copyright (c) 2012 Marc Espie <espie@openbsd.org> # @@ -175,10 +175,9 @@ sub add_option_accessor } } -sub handle_options +sub create_options { my ($self, @l) = @_; - my @options = (); # first pass creates accessors while (my $opt = shift @l) { @@ -201,6 +200,14 @@ sub handle_options } push(@options, Options->new($opt, $code)->setup($self)); } + return @options; +} + +sub handle_options +{ + my ($self, @l) = @_; + + my @options = $self->create_options(@l); MAINLOOP: while (@main::ARGV > 0) { @@ -222,6 +229,31 @@ MAINLOOP: } } +sub handle_permuted_options +{ + my ($self, @l) = @_; + + my @options = $self->create_options(@l); + + my @kept = (); +MAINLOOP2: + while (@main::ARGV > 0) { + my $_ = shift @main::ARGV; + if (m/^\-\-$/) { + next; # XXX ? + } + if (m/^\-/) { + for my $opt (@options) { + if ($opt->match($_, $self)) { + next MAINLOOP2; + } + } + } + push(@kept, $_); + } + @main::ARGV = @kept; +} + sub new { my $class = shift; |