diff options
author | Karl Berry <karl@freefriends.org> | 2019-03-10 21:56:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-03-10 21:56:14 +0000 |
commit | e0a2a718e89f9700d627f1e6a8eea8f21d2fbeb8 (patch) | |
tree | 39972f65008b0d70f306a5f976494d29411bc41e /Master/tlpkg/tlperl/lib/Getopt/Long.pm | |
parent | b206fdc77d81ed1600949062f08de5690a4bf66f (diff) |
tl19 perl 5.28.1 for Windows, from Siep
git-svn-id: svn://tug.org/texlive/trunk@50322 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Getopt/Long.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/Getopt/Long.pm | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/Master/tlpkg/tlperl/lib/Getopt/Long.pm b/Master/tlpkg/tlperl/lib/Getopt/Long.pm index 5e1834f3caf..664c8b63c91 100644 --- a/Master/tlpkg/tlperl/lib/Getopt/Long.pm +++ b/Master/tlpkg/tlperl/lib/Getopt/Long.pm @@ -4,23 +4,24 @@ # Author : Johan Vromans # Created On : Tue Sep 11 15:00:12 1990 # Last Modified By: Johan Vromans -# Last Modified On: Thu Jun 9 14:50:37 2016 -# Update Count : 1699 +# Last Modified On: Sat May 27 12:11:39 2017 +# Update Count : 1715 # Status : Released ################ Module Preamble ################ -package Getopt::Long; - use 5.004; use strict; +use warnings; + +package Getopt::Long; use vars qw($VERSION); -$VERSION = 2.49; +$VERSION = 2.50; # For testing versions only. use vars qw($VERSION_STRING); -$VERSION_STRING = "2.49"; +$VERSION_STRING = "2.50"; use Exporter; use vars qw(@ISA @EXPORT @EXPORT_OK); @@ -1045,7 +1046,8 @@ sub FindOption ($$$$$) { # Complete the option name, if appropriate. if ( @hits == 1 && $hits[0] ne $opt ) { $tryopt = $hits[0]; - $tryopt = lc ($tryopt) if $ignorecase; + $tryopt = lc ($tryopt) + if $ignorecase > (($bundling && length($tryopt) == 1) ? 1 : 0); print STDERR ("=> option \"$opt\" -> \"$tryopt\"\n") if $debug; } @@ -1110,10 +1112,23 @@ sub FindOption ($$$$$) { # Check if there is an option argument available. if ( $gnu_compat ) { - my $optargtype = 0; # 0 = none, 1 = empty, 2 = nonempty - $optargtype = ( !defined($optarg) ? 0 : ( (length($optarg) == 0) ? 1 : 2 ) ); - return (1, $opt, $ctl, defined($ctl->[CTL_DEFAULT]) ? $ctl->[CTL_DEFAULT] : undef) - if (($optargtype == 0) && !$mand); + my $optargtype = 0; # none, 1 = empty, 2 = nonempty, 3 = aux + if ( defined($optarg) ) { + $optargtype = (length($optarg) == 0) ? 1 : 2; + } + elsif ( defined $rest || @$argv > 0 ) { + # GNU getopt_long() does not accept the (optional) + # argument to be passed to the option without = sign. + # We do, since not doing so breaks existing scripts. + $optargtype = 3; + } + if(($optargtype == 0) && !$mand) { + my $val + = defined($ctl->[CTL_DEFAULT]) ? $ctl->[CTL_DEFAULT] + : $type eq 's' ? '' + : 0; + return (1, $opt, $ctl, $val); + } return (1, $opt, $ctl, $type eq 's' ? '' : 0) if $optargtype == 1; # --foo= -> return nothing } @@ -1753,12 +1768,12 @@ destination for the option: GetOptions ("library=s" => \@libfiles); Alternatively, you can specify that the option can have multiple -values by adding a "@", and pass a scalar reference as the +values by adding a "@", and pass a reference to a scalar as the destination: GetOptions ("library=s@" => \$libfiles); -Used with the example above, C<@libfiles> (or C<@$libfiles>) would +Used with the example above, C<@libfiles> c.q. C<@$libfiles> would contain two strings upon completion: C<"lib/stdlib"> and C<"lib/extlib">, in that order. It is also possible to specify that only integer or floating point numbers are acceptable values. @@ -2322,11 +2337,14 @@ do. Without C<gnu_compat>, C<--opt=> gives an error. With C<gnu_compat>, C<--opt=> will give option C<opt> and empty value. This is the way GNU getopt_long() does it. +Note that C<--opt value> is still accepted, even though GNU +getopt_long() doesn't. + =item gnu_getopt This is a short way of setting C<gnu_compat> C<bundling> C<permute> C<no_getopt_compat>. With C<gnu_getopt>, command line handling should be -fully compatible with GNU getopt_long(). +reasonably compatible with GNU getopt_long(). =item require_order |