Subject: | eliminate branches using Pod::Parser |
These commits update Pod::Usage to only use Pod::Simple, so that any reliance on Pod::Parser is
removed, making it easier to remove Pod::Parser from core.
--
rjbs
Subject: | 0003-always-use-Pod-Text-as-default-base-class.patch |
From dc93ed2dafca295e2a34331fc938ed67a0011728 Mon Sep 17 00:00:00 2001
From: Ricardo Signes <rjbs@cpan.org>
Date: Mon, 18 Mar 2013 18:53:54 -0400
Subject: [PATCH 3/4] always use Pod::Text as default base class
---
lib/Pod/Usage.pm | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/Pod/Usage.pm b/lib/Pod/Usage.pm
index b4fe98a..d885fab 100755
--- a/lib/Pod/Usage.pm
+++ b/lib/Pod/Usage.pm
@@ -22,8 +22,7 @@ use File::Spec;
@EXPORT = qw(&pod2usage);
BEGIN {
- $Pod::Usage::Formatter ||=
- ( $] >= 5.005_58 ? 'Pod::Text' : 'Pod::PlainText');
+ $Pod::Usage::Formatter ||= 'Pod::Text';
eval "require $Pod::Usage::Formatter";
die $@ if $@;
@ISA = ( $Pod::Usage::Formatter );
--
1.8.1.3
Subject: | 0004-eliminate-the-branch-in-which-Pod-Parser-would-be-us.patch |
From 14a416acbb35a2711993d0df4d74ac99ca26786d Mon Sep 17 00:00:00 2001
From: Ricardo Signes <rjbs@cpan.org>
Date: Mon, 18 Mar 2013 19:04:04 -0400
Subject: [PATCH 4/4] eliminate the branch in which Pod::Parser would be used
This commit is intended entirely to free Pod::Usage from any
reliance on Pod::Parser.
* Usage.pm now defaults to using Pod::Text, rather than
checking $] to pick.
* $Pod::Select::MAX_HEADING_LEVEL is replaced with a local var
* &Pod::Select::_compile_section_spec is copied into this module
This isn't the most elegant fix, but it's a bit of a ball of mud.
The code is written to let you alter @ISA at runtime to something
that is derived either from Pod::Parser or Pod::Simple. This
should probably be more explicitly limited to Pod::Simple in
future releases.
---
lib/Pod/Usage.pm | 60 ++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 50 insertions(+), 10 deletions(-)
diff --git a/lib/Pod/Usage.pm b/lib/Pod/Usage.pm
index d885fab..7fcdbc8 100755
--- a/lib/Pod/Usage.pm
+++ b/lib/Pod/Usage.pm
@@ -28,7 +28,7 @@ BEGIN {
@ISA = ( $Pod::Usage::Formatter );
}
-require Pod::Select;
+our $MAX_HEADING_LEVEL = 3;
##---------------------------------------------------------------------------
@@ -191,6 +191,48 @@ sub new {
return $self;
}
+# This subroutine was copied in whole-cloth from Pod::Select 1.60 in order to
+# allow the ejection of Pod::Select from the core without breaking Pod::Usage.
+# -- rjbs, 2013-03-18
+sub _compile_section_spec {
+ my ($section_spec) = @_;
+ my (@regexs, $negated);
+
+ ## Compile the spec into a list of regexs
+ local $_ = $section_spec;
+ s{\\\\}{\001}g; ## handle escaped backward slashes
+ s{\\/}{\002}g; ## handle escaped forward slashes
+
+ ## Parse the regexs for the heading titles
+ @regexs = split(/\//, $_, $MAX_HEADING_LEVEL);
+
+ ## Set default regex for ommitted levels
+ for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
+ $regexs[$i] = '.*' unless ((defined $regexs[$i])
+ && (length $regexs[$i]));
+ }
+ ## Modify the regexs as needed and validate their syntax
+ my $bad_regexs = 0;
+ for (@regexs) {
+ $_ .= '.+' if ($_ eq '!');
+ s{\001}{\\\\}g; ## restore escaped backward slashes
+ s{\002}{\\/}g; ## restore escaped forward slashes
+ $negated = s/^\!//; ## check for negation
+ eval "m{$_}"; ## check regex syntax
+ if ($@) {
+ ++$bad_regexs;
+ carp qq{Bad regular expression /$_/ in "$section_spec": $@\n};
+ }
+ else {
+ ## Add the forward and rear anchors (and put the negator back)
+ $_ = '^' . $_ unless (/^\^/);
+ $_ = $_ . '$' unless (/\$$/);
+ $_ = '!' . $_ if ($negated);
+ }
+ }
+ return (! $bad_regexs) ? [ @regexs ] : undef;
+}
+
sub select {
my ($self, @sections) = @_;
if ($ISA[0]->can('select')) {
@@ -208,7 +250,7 @@ sub select {
my $sref = $self->{USAGE_SELECT};
## Compile each spec
for my $spec (@sections) {
- my $cs = Pod::Select::_compile_section_spec($spec);
+ my $cs = _compile_section_spec($spec);
if ( defined $cs ) {
## Store them in our sections array
push(@$sref, $cs);
@@ -245,7 +287,7 @@ sub _handle_element_end {
my @headings = @{$$self{USAGE_HEADINGS}};
for my $section_spec ( @{$$self{USAGE_SELECT}} ) {
my $match = 1;
- for (my $i = 0; $i < $Pod::Select::MAX_HEADING_LEVEL; ++$i) {
+ for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
$headings[$i] = '' unless defined $headings[$i];
my $regex = $section_spec->[$i];
my $negated = ($regex =~ s/^\!//);
@@ -400,8 +442,7 @@ is 1, then the "SYNOPSIS" section, along with any section entitled
corresponding value is 2 or more then the entire manpage is printed.
The special verbosity level 99 requires to also specify the -sections
-parameter; then these sections are extracted (see L<Pod::Select>)
-and printed.
+parameter; then these sections are extracted and printed.
=item C<-sections>
@@ -453,9 +494,8 @@ output the POD.
=head2 Formatting base class
-The default text formatter depends on the Perl version (L<Pod::Text> or
-L<Pod::PlainText> for Perl versions E<lt> 5.005_58). The base class for
-Pod::Usage can be defined by pre-setting C<$Pod::Usage::Formatter> I<before>
+The default text formatter is L<Pod::Text>. The base class for Pod::Usage can
+be defined by pre-setting C<$Pod::Usage::Formatter> I<before>
loading Pod::Usage, e.g.:
BEGIN { $Pod::Usage::Formatter = 'Pod::Text::Termcap'; }
@@ -759,8 +799,8 @@ with re-writing this manpage.
B<Pod::Usage> is now a standalone distribution.
-L<Pod::Parser>, L<Pod::Perldoc>, L<Getopt::Long>, L<Pod::Find>, L<FindBin>,
-L<Pod::Text>, L<Pod::PlainText>, L<Pod::Text::Termcap>
+L<Pod::Perldoc>, L<Getopt::Long>, L<Pod::Find>, L<FindBin>,
+L<Pod::Text>, L<Pod::Text::Termcap>
=cut
--
1.8.1.3
Subject: | 0002-we-will-start-to-require-perl-5.6-from-here-on-out.patch |
From a9062d42c23160c632d7bc1794b5f29679ebce3c Mon Sep 17 00:00:00 2001
From: Ricardo Signes <rjbs@cpan.org>
Date: Mon, 18 Mar 2013 18:50:13 -0400
Subject: [PATCH 2/4] we will start to require perl 5.6 from here on out
---
lib/Pod/Usage.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Pod/Usage.pm b/lib/Pod/Usage.pm
index e09d69e..b4fe98a 100755
--- a/lib/Pod/Usage.pm
+++ b/lib/Pod/Usage.pm
@@ -12,7 +12,7 @@ use strict;
use vars qw($VERSION @ISA @EXPORT);
$VERSION = '1.61'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
+require 5.006; ## requires this Perl version or later
#use diagnostics;
use Carp;
--
1.8.1.3
Subject: | 0001-update-Makefile-strict-INSTALLDIR-5.6.patch |
From 31fd9c55fa9d897f11475c39becd91dc5cc7fef3 Mon Sep 17 00:00:00 2001
From: Ricardo Signes <rjbs@cpan.org>
Date: Mon, 18 Mar 2013 18:49:37 -0400
Subject: [PATCH 1/4] update Makefile: strict, INSTALLDIR, 5.6
---
Makefile.PL | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 87432f3..db8ed38 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,17 +3,19 @@
# This file is part of "Pod-Usage". Pod-Usage is free software;
# you can redistribute it and/or modify it under the same terms
# as Perl itself.
+use 5.006;
+use strict;
use ExtUtils::MakeMaker;
use File::Spec;
-$DISTNAME = "Pod-Usage"; ## The "product" name for this distribution
-$DISTMOD = 'Pod::Usage'; ## The "title" module of this distribution
-@MODULES = ( $DISTMOD, ## Other modules in this distribution
+my $DISTNAME = "Pod-Usage"; ## The "product" name for this distribution
+my $DISTMOD = 'Pod::Usage'; ## The "title" module of this distribution
+my @MODULES = ( $DISTMOD, ## Other modules in this distribution
);
## The executable scripts to be installed
-@SCRIPTS = qw( pod2usage );
+my @SCRIPTS = qw( pod2usage );
sub script($) { File::Spec->catfile ('scripts', @_) }
my @EXE_FILES = ();
if ( $^O eq 'VMS' ) {
@@ -25,7 +27,7 @@ else {
## The test-script to execute regression tests (note that the
## 'xtra' directory might not exist for some installations)
-@TESTPODS = ();
+my @TESTPODS = ();
my $testdir = File::Spec->catfile('t', 'pod');
my $test2dir = File::Spec->catfile($testdir, 'xtra');
my @testdirs = ($testdir);
@@ -41,18 +43,15 @@ my %prereq = (
'Pod::Parser' => 1.60,
'Test::More' => 0.60,
'Cwd' => 0,
- 'File::Basename' => 0
+ 'File::Basename' => 0,
+ 'File::Spec' => 0.82,
);
-if ($] < 5.005) {
- ## Need File::Spec if this is 5.004 or earlier
- $prereq{'File::Spec'} = 0.82;
-}
WriteMakefile(
NAME => $DISTMOD,
DISTNAME => $DISTNAME,
VERSION => '1.61',
- INSTALLDIRS => ($] >= 5.006 ? 'perl' : 'site'),
+ INSTALLDIRS => ($] < 5.012 ? 'perl' : 'site'),
PL_FILES => { map { (script("$_.PL") => script($_)) } @SCRIPTS },
EXE_FILES => [ @EXE_FILES ],
dist => { COMPRESS => 'gzip', SUFFIX => 'gz' },
--
1.8.1.3