Skip to content

Commit 867a740

Browse files
sciuriusjkeenan
authored andcommitted
cpan/Getopt-Long - Update to version 2.57
Changes in version 2.57 ----------------------- * Adapt tests for perl core, thanks to James Keenan. Packaging changes only, no functional changes. Changes in version 2.56 ----------------------- * Do not use Getopt::Long to establish Getopt::Long::Parser version. Packaging changes only, no functional changes. Changes in version 2.55 ----------------------- * Move Getopt::Long::Parser to a separate module and add documentation. Note that Getopt::Long uses Getopt::Long::Parser, so programs that use Getopt::Long and call the oo interface will still work. * Allow periods in option names, e.g. to indicate levels in a hierarchical configuration. Since periods in option names have never been valid, they are now allowed by default unless pass_through is enabled. * Fix long standing bug that duplicate options were not detected when the options differ in case while ignore_case is in effect. This will now yield a warning and become a fatal error in a future release. Committer: Reflect changes in makefiles due to Getopt-Long reorganization. In the course of synching Getopt-Long-2.57 into blead there were changes to MANIFEST et al. which led to regeneration of metadata. Committer: Accommodate 'use base' during build on Win32. Per recommendation by Tony Cook in Perl#21629 (comment).
1 parent 09bf96e commit 867a740

File tree

12 files changed

+305
-133
lines changed

12 files changed

+305
-133
lines changed

MANIFEST

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,15 @@ cpan/Filter-Util-Call/t/call.t See if Filter::Util::Call works
11501150
cpan/Filter-Util-Call/t/rt_101033.pm
11511151
cpan/Filter-Util-Call/t/rt_101033.t
11521152
cpan/Filter-Util-Call/t/rt_54452-rebless.t
1153-
cpan/Getopt-Long/lib/Getopt/Long.pm Fetch command options (GetOptions)
1154-
cpan/Getopt-Long/t/gol-basic.t See if Getopt::Long works
1155-
cpan/Getopt-Long/t/gol-linkage.t See if Getopt::Long works
1156-
cpan/Getopt-Long/t/gol-oo.t See if Getopt::Long works
1157-
cpan/Getopt-Long/t/gol-xargv.t See if Getopt::Long works
1158-
cpan/Getopt-Long/t/gol-xstring.t See if Getopt::Long works
1153+
cpan/Getopt-Long/lib/Getopt/Long.pm Fetch command options (GetOptions)
1154+
cpan/Getopt-Long/lib/Getopt/Long/Parser.pm Getopt-Long
1155+
cpan/Getopt-Long/t/gol-basic.t See if Getopt::Long works
1156+
cpan/Getopt-Long/t/gol-linkage.t See if Getopt::Long works
1157+
cpan/Getopt-Long/t/gol-load1.t Getopt-Long
1158+
cpan/Getopt-Long/t/gol-load2.t Getopt-Long
1159+
cpan/Getopt-Long/t/gol-oo.t See if Getopt::Long works
1160+
cpan/Getopt-Long/t/gol-xargv.t See if Getopt::Long works
1161+
cpan/Getopt-Long/t/gol-xstring.t See if Getopt::Long works
11591162
cpan/HTTP-Tiny/corpus/auth-01.txt Test file related to HTTP::Tiny
11601163
cpan/HTTP-Tiny/corpus/auth-02.txt Test file related to HTTP::Tiny
11611164
cpan/HTTP-Tiny/corpus/auth-03.txt Test file related to HTTP::Tiny

Makefile.SH

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,8 +1441,8 @@ _cleaner2:
14411441
-rmdir lib/IO/Compress/Zlib lib/IO/Compress/Zip lib/IO/Compress/Gzip
14421442
-rmdir lib/IO/Compress/Base lib/IO/Compress/Adapter lib/IO/Compress
14431443
-rmdir lib/IO lib/I18N/LangTags lib/I18N lib/Hash/Util lib/Hash
1444-
-rmdir lib/HTTP lib/Filter/Util lib/Filter lib/File/Spec
1445-
-rmdir lib/ExtUtils/Typemaps lib/ExtUtils/ParseXS
1444+
-rmdir lib/HTTP lib/Getopt/Long lib/Filter/Util lib/Filter
1445+
-rmdir lib/File/Spec lib/ExtUtils/Typemaps lib/ExtUtils/ParseXS
14461446
-rmdir lib/ExtUtils/MakeMaker/version lib/ExtUtils/MakeMaker
14471447
-rmdir lib/ExtUtils/Liblist lib/ExtUtils/Constant lib/ExtUtils/Command
14481448
-rmdir lib/ExtUtils/CBuilder/Platform/Windows

Porting/Maintainers.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ package Maintainers;
612612
},
613613

614614
'Getopt::Long' => {
615-
'DISTRIBUTION' => 'JV/Getopt-Long-2.54.tar.gz',
615+
'DISTRIBUTION' => 'JV/Getopt-Long-2.57.tar.gz',
616+
'SYNCINFO' => 'jkeenan on Sat Nov 11 13:09:21 2023',
616617
'FILES' => q[cpan/Getopt-Long],
617618
'EXCLUDED' => [
618619
qr{^examples/},

cpan/Getopt-Long/lib/Getopt/Long.pm

Lines changed: 44 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,24 @@
33
# Getopt::Long.pm -- Universal options parsing
44
# Author : Johan Vromans
55
# Created On : Tue Sep 11 15:00:12 1990
6-
# Last Modified By: Johan Vromans
7-
# Last Modified On: Thu Nov 17 17:45:27 2022
8-
# Update Count : 1777
6+
# Last Modified On: Sat Nov 11 17:48:41 2023
7+
# Update Count : 1808
98
# Status : Released
109

1110
################ Module Preamble ################
1211

13-
# There are no CPAN testers for very old versions of Perl.
14-
# Getopt::Long is reported to run under 5.8.
15-
use 5.004;
12+
# Getopt::Long is reported to run under 5.6.1. Thanks Tux!
13+
use 5.006001;
1614

1715
use strict;
1816
use warnings;
1917

2018
package Getopt::Long;
2119

22-
use vars qw($VERSION);
23-
$VERSION = 2.54;
24-
# For testing versions only.
25-
use vars qw($VERSION_STRING);
26-
$VERSION_STRING = "2.54";
20+
our $VERSION = 2.57;
2721

2822
use Exporter;
29-
use vars qw(@ISA @EXPORT @EXPORT_OK);
30-
@ISA = qw(Exporter);
23+
use base qw(Exporter);
3124

3225
# Exported subroutines.
3326
sub GetOptions(@); # always
@@ -37,21 +30,24 @@ sub Configure(@); # on demand
3730
sub HelpMessage(@); # on demand
3831
sub VersionMessage(@); # in demand
3932

33+
our @EXPORT;
34+
our @EXPORT_OK;
35+
# Values for $order. See GNU getopt.c for details.
36+
our ($REQUIRE_ORDER, $PERMUTE, $RETURN_IN_ORDER);
4037
BEGIN {
41-
# Init immediately so their contents can be used in the 'use vars' below.
38+
($REQUIRE_ORDER, $PERMUTE, $RETURN_IN_ORDER) = (0..2);
4239
@EXPORT = qw(&GetOptions $REQUIRE_ORDER $PERMUTE $RETURN_IN_ORDER);
4340
@EXPORT_OK = qw(&HelpMessage &VersionMessage &Configure
4441
&GetOptionsFromArray &GetOptionsFromString);
4542
}
4643

4744
# User visible variables.
48-
use vars @EXPORT, @EXPORT_OK;
49-
use vars qw($error $debug $major_version $minor_version);
45+
our ($error, $debug, $major_version, $minor_version);
5046
# Deprecated visible variables.
51-
use vars qw($autoabbrev $getopt_compat $ignorecase $bundling $order
52-
$passthrough);
47+
our ($autoabbrev, $getopt_compat, $ignorecase, $bundling, $order,
48+
$passthrough);
5349
# Official invisible variables.
54-
use vars qw($genprefix $caller $gnu_compat $auto_help $auto_version $longprefix);
50+
our ($genprefix, $caller, $gnu_compat, $auto_help, $auto_version, $longprefix);
5551

5652
# Really invisible variables.
5753
my $bundling_values;
@@ -125,97 +121,29 @@ sub import {
125121

126122
################ Initialization ################
127123

128-
# Values for $order. See GNU getopt.c for details.
129-
($REQUIRE_ORDER, $PERMUTE, $RETURN_IN_ORDER) = (0..2);
130124
# Version major/minor numbers.
131125
($major_version, $minor_version) = $VERSION =~ /^(\d+)\.(\d+)/;
132126

133127
ConfigDefaults();
134128

135-
################ OO Interface ################
136-
137-
package Getopt::Long::Parser;
138-
139129
# Store a copy of the default configuration. Since ConfigDefaults has
140130
# just been called, what we get from Configure is the default.
141131
my $default_config = do {
142132
Getopt::Long::Configure ()
143133
};
144134

145-
sub new {
146-
my $that = shift;
147-
my $class = ref($that) || $that;
148-
my %atts = @_;
149-
150-
# Register the callers package.
151-
my $self = { caller_pkg => (caller)[0] };
152-
153-
bless ($self, $class);
154-
155-
# Process config attributes.
156-
if ( defined $atts{config} ) {
157-
my $save = Getopt::Long::Configure ($default_config, @{$atts{config}});
158-
$self->{settings} = Getopt::Long::Configure ($save);
159-
delete ($atts{config});
160-
}
161-
# Else use default config.
162-
else {
163-
$self->{settings} = $default_config;
164-
}
165-
166-
if ( %atts ) { # Oops
167-
die(__PACKAGE__.": unhandled attributes: ".
168-
join(" ", sort(keys(%atts)))."\n");
169-
}
135+
# For the parser only.
136+
sub _default_config { $default_config }
170137

171-
$self;
172-
}
173-
174-
sub configure {
175-
my ($self) = shift;
176-
177-
# Restore settings, merge new settings in.
178-
my $save = Getopt::Long::Configure ($self->{settings}, @_);
179-
180-
# Restore orig config and save the new config.
181-
$self->{settings} = Getopt::Long::Configure ($save);
182-
}
183-
184-
sub getoptions {
185-
my ($self) = shift;
186-
187-
return $self->getoptionsfromarray(\@ARGV, @_);
188-
}
189-
190-
sub getoptionsfromarray {
191-
my ($self) = shift;
192-
193-
# Restore config settings.
194-
my $save = Getopt::Long::Configure ($self->{settings});
195-
196-
# Call main routine.
197-
my $ret = 0;
198-
$Getopt::Long::caller = $self->{caller_pkg};
138+
################ Back to Normal ################
199139

200-
eval {
201-
# Locally set exception handler to default, otherwise it will
202-
# be called implicitly here, and again explicitly when we try
203-
# to deliver the messages.
204-
local ($SIG{__DIE__}) = 'DEFAULT';
205-
$ret = Getopt::Long::GetOptionsFromArray (@_);
206-
};
207-
208-
# Restore saved settings.
209-
Getopt::Long::Configure ($save);
210-
211-
# Handle errors and return value.
212-
die ($@) if $@;
213-
return $ret;
140+
# The ooparser was traditionally part of the main package.
141+
no warnings 'redefine';
142+
sub Getopt::Long::Parser::new {
143+
require Getopt::Long::Parser;
144+
goto &Getopt::Long::Parser::new;
214145
}
215-
216-
package Getopt::Long;
217-
218-
################ Back to Normal ################
146+
use warnings 'redefine';
219147

220148
# Indices in option control info.
221149
# Note that ParseOptions uses the fields directly. Search for 'hard-wired'.
@@ -305,7 +233,7 @@ sub GetOptionsFromArray(@) {
305233
# Avoid some warnings if debugging.
306234
local ($^W) = 0;
307235
print STDERR
308-
("Getopt::Long $Getopt::Long::VERSION_STRING ",
236+
("Getopt::Long $VERSION ",
309237
"called from package \"$pkg\".",
310238
"\n ",
311239
"argv: ",
@@ -806,11 +734,15 @@ sub OptCtl ($) {
806734
sub ParseOptionSpec ($$) {
807735
my ($opt, $opctl) = @_;
808736

737+
# Allow period in option name unless passing through,
738+
my $op = $passthrough
739+
? qr/(?: \w+[-\w]* )/x : qr/(?: \w+[-.\w]* )/x;
740+
809741
# Match option spec.
810742
if ( $opt !~ m;^
811743
(
812744
# Option name
813-
(?: \w+[-\w]* )
745+
$op
814746
# Aliases
815747
(?: \| (?: . [^|!+=:]* )? )*
816748
)?
@@ -929,7 +861,8 @@ sub ParseOptionSpec ($$) {
929861
}
930862
}
931863

932-
if ( $dups && $^W ) {
864+
if ( $dups ) {
865+
# Warn now. Will become fatal in a future release.
933866
foreach ( split(/\n+/, $dups) ) {
934867
warn($_."\n");
935868
}
@@ -1495,9 +1428,7 @@ sub VersionMessage(@) {
14951428
$0, defined $v ? " version $v" : (),
14961429
"\n",
14971430
"(", __PACKAGE__, "::", "GetOptions",
1498-
" version ",
1499-
defined($Getopt::Long::VERSION_STRING)
1500-
? $Getopt::Long::VERSION_STRING : $VERSION, ";",
1431+
" version $VERSION,",
15011432
" Perl version ",
15021433
$] >= 5.006 ? sprintf("%vd", $^V) : $],
15031434
")\n");
@@ -1515,7 +1446,7 @@ sub VersionMessage(@) {
15151446
sub HelpMessage(@) {
15161447
eval {
15171448
require Pod::Usage;
1518-
import Pod::Usage;
1449+
Pod::Usage->import;
15191450
1;
15201451
} || die("Cannot provide help: cannot load Pod::Usage\n");
15211452

@@ -1941,7 +1872,9 @@ and the argument specification.
19411872
19421873
The name specification contains the name of the option, optionally
19431874
followed by a list of alternative names separated by vertical bar
1944-
characters.
1875+
characters. The name is made up of alphanumeric characters, hyphens,
1876+
underscores. If C<pass_through> is disabled, a period is also allowed in
1877+
option names.
19451878
19461879
length option name is "length"
19471880
length|size|l name is "length", aliases are "size" and "l"
@@ -2048,18 +1981,7 @@ option will be incremented.
20481981
20491982
=head2 Object oriented interface
20501983
2051-
Getopt::Long can be used in an object oriented way as well:
2052-
2053-
use Getopt::Long;
2054-
$p = Getopt::Long::Parser->new;
2055-
$p->configure(...configuration options...);
2056-
if ($p->getoptions(...options descriptions...)) ...
2057-
if ($p->getoptionsfromarray( \@array, ...options descriptions...)) ...
2058-
2059-
Configuration options can be passed to the constructor:
2060-
2061-
$p = new Getopt::Long::Parser
2062-
config => [...configuration options...];
1984+
See L<Getopt::Long::Parser>.
20631985
20641986
=head2 Callback object
20651987
@@ -2389,11 +2311,12 @@ POSIXLY_CORRECT has been set, in which case C<getopt_compat> is disabled.
23892311
23902312
C<gnu_compat> controls whether C<--opt=> is allowed, and what it should
23912313
do. Without C<gnu_compat>, C<--opt=> gives an error. With C<gnu_compat>,
2392-
C<--opt=> will give option C<opt> and empty value.
2314+
C<--opt=> will give option C<opt> an empty value.
23932315
This is the way GNU getopt_long() does it.
23942316
2395-
Note that C<--opt value> is still accepted, even though GNU
2396-
getopt_long() doesn't.
2317+
Note that for options with optional arguments, C<--opt value> is still
2318+
accepted, even though GNU getopt_long() requires writing C<--opt=value>
2319+
in this case.
23972320
23982321
=item gnu_getopt
23992322
@@ -2677,7 +2600,7 @@ When no destination is specified for an option, GetOptions will store
26772600
the resultant value in a global variable named C<opt_>I<XXX>, where
26782601
I<XXX> is the primary name of this option. When a program executes
26792602
under C<use strict> (recommended), these variables must be
2680-
pre-declared with our() or C<use vars>.
2603+
pre-declared with our().
26812604
26822605
our $opt_length = 0;
26832606
GetOptions ('length=i'); # will store in $opt_length
@@ -2805,7 +2728,7 @@ Johan Vromans <[email protected]>
28052728
28062729
=head1 COPYRIGHT AND DISCLAIMER
28072730
2808-
This program is Copyright 1990,2015 by Johan Vromans.
2731+
This program is Copyright 1990,2015,2023 by Johan Vromans.
28092732
This program is free software; you can redistribute it and/or
28102733
modify it under the terms of the Perl Artistic License or the
28112734
GNU General Public License as published by the Free Software

0 commit comments

Comments
 (0)