Skip Menu |

This queue is for tickets about the Pod-Usage CPAN distribution.

Maintainer(s)' notes

Please use Github for all future tickets, patches and pull requests: https://github.com/Dual-Life/Pod-Usage

Thanks to Nicolas R (ATOOMIC) for setting up everything there!

Report information
The Basics
Id: 84031
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Pod-Usage

People
Owner: Marek.Rouchal [...] gmx.net
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 1.62



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
This final patch removes the final bit of Pod-Parser use from a test! -- rjbs
Subject: 0001-eliminate-older-style-test-thus-eliminating-Pod-Pars.patch
From d8353ba463f76460abedc3287a25e7d055f241a1 Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Tue, 23 Apr 2013 08:59:20 -0400 Subject: [PATCH] eliminate older-style test, thus eliminating Pod::Parser The test t/pod/pod2usage.t is a bit of a dizzying mash-up of files loaded with require and other weirdness. Once I got my head around it, I decided it really didn't do much of anything that isn't done much more simply by its younger sibling, t/pod/pod2usage2.t The older test uses Pod::PlainText to do its job, which is part of Pod-Parser. Eliminating the test eliminates the last of Pod-Usage's use of Pod-Parser, without (I believe) eliminating any useful testing! --- MANIFEST | 3 - Makefile.PL | 2 +- t/pod/pod2usage.t | 18 ----- t/pod/pod2usage.xr | 63 ------------------ t/pod/testp2pt.pl | 192 ----------------------------------------------------- 5 files changed, 1 insertion(+), 277 deletions(-) delete mode 100755 t/pod/pod2usage.t delete mode 100755 t/pod/pod2usage.xr delete mode 100755 t/pod/testp2pt.pl diff --git a/MANIFEST b/MANIFEST index 07a601b..eb766be 100755 --- a/MANIFEST +++ b/MANIFEST @@ -10,10 +10,7 @@ scripts/pod2usage.PL -- Script to print usage from a file's embeded pod docs (a command-line interface to pod2usage()). t/pod/testcmp.pl -- module used to compare output against expected results -t/pod/testp2pt.pl -- module used to test Pod::PlainText for a given file -t/pod/pod2usage.t -- test input file for processing pod2usage.PL t/pod/p2u_data.pl -- test script for POD in __DATA__ section t/pod/pod2usage2.t -- more Pod::Usage tests -t/pod/pod2usage.xr -- expected result from processing pod2usage.PL t/pod/usage.pod -- test POD for pod2usage tests t/pod/usage2.pod -- test POD for pod2usage tests diff --git a/Makefile.PL b/Makefile.PL index db8ed38..55d832c 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -40,7 +40,7 @@ push @testdirs, $test2dir if (-d $test2dir); # needed for new pod2usage2.t my %prereq = ( - 'Pod::Parser' => 1.60, + 'Pod::Simple' => 0, 'Test::More' => 0.60, 'Cwd' => 0, 'File::Basename' => 0, diff --git a/t/pod/pod2usage.t b/t/pod/pod2usage.t deleted file mode 100755 index 98788fc..0000000 --- a/t/pod/pod2usage.t +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN { - use File::Basename; - my $THISDIR = dirname $0; - unshift @INC, $THISDIR; - require "testp2pt.pl"; - import TestPodIncPlainText; -} - -my %options = map { $_ => 1 } @ARGV; ## convert cmdline to options-hash -my $passed = testpodplaintext \%options, $0; -exit( ($passed == 1) ? 0 : -1 ) unless $ENV{HARNESS_ACTIVE}; - - -__END__ - -=include pod2usage.PL - - diff --git a/t/pod/pod2usage.xr b/t/pod/pod2usage.xr deleted file mode 100755 index ceac4f1..0000000 --- a/t/pod/pod2usage.xr +++ /dev/null @@ -1,63 +0,0 @@ -###### begin =include pod2usage.PL ##### -NAME - pod2usage - print usage messages from embedded pod docs in files - -SYNOPSIS - pod2usage [-help] [-man] [-exit *exitval*] [-output *outfile*] - [-verbose *level*] [-pathlist *dirlist*] [-formatter - *module*] *file* - -OPTIONS AND ARGUMENTS - -help Print a brief help message and exit. - - -man Print this command's manual page and exit. - - -exit *exitval* - The exit status value to return. - - -output *outfile* - The output file to print to. If the special names "-" or ">&1" - or ">&STDOUT" are used then standard output is used. If ">&2" or - ">&STDERR" is used then standard error is used. - - -verbose *level* - The desired level of verbosity to use: - - 1 : print SYNOPSIS only - 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections - 3 : print the entire manpage (similar to running pod2text) - - -pathlist *dirlist* - Specifies one or more directories to search for the input file - if it was not supplied with an absolute path. Each directory - path in the given list should be separated by a ':' on Unix (';' - on MSWin32 and DOS). - - -formatter *module* - Which text formatter to use. Default is the Pod::Text manpage, - or for very old Perl versions the Pod::PlainText manpage. An - alternative would be e.g. the Pod::Text::Termcap manpage. - - *file* The pathname of a file containing pod documentation to be output - in usage message format (defaults to standard input). - -DESCRIPTION - pod2usage will read the given input file looking for pod documentation - and will print the corresponding usage message. If no input file is - specified then standard input is read. - - pod2usage invokes the pod2usage() function in the Pod::Usage module. - Please see the pod2usage() entry in the Pod::Usage manpage. - -SEE ALSO - the Pod::Usage manpage, the pod2text(1) manpage - -AUTHOR - Please report bugs using http://rt.cpan.org. - - Brad Appleton <bradapp@enteract.com> - - Based on code for pod2text(1) written by Tom Christiansen - <tchrist@mox.perl.com> - -###### end =include pod2usage.PL ##### diff --git a/t/pod/testp2pt.pl b/t/pod/testp2pt.pl deleted file mode 100755 index 5c17300..0000000 --- a/t/pod/testp2pt.pl +++ /dev/null @@ -1,192 +0,0 @@ -package TestPodIncPlainText; - -BEGIN { - use File::Basename; - use File::Spec; - use Cwd qw(abs_path); - push @INC, '..'; - my $THISDIR = abs_path(dirname $0); - unshift @INC, $THISDIR; - require "testcmp.pl"; - import TestCompare; - my $PARENTDIR = dirname $THISDIR; - push @INC, map { File::Spec->catfile($_, 'lib') } ($PARENTDIR, $THISDIR); -} - -#use strict; -#use diagnostics; -use Carp; -use Exporter; -#use File::Compare; -#use Cwd qw(abs_path); - -use vars qw($MYPKG @EXPORT @ISA); -$MYPKG = eval { (caller)[0] }; -@EXPORT = qw(&testpodplaintext); -BEGIN { - require Pod::PlainText; - @ISA = qw( Pod::PlainText ); - require VMS::Filespec if $^O eq 'VMS'; -} - -## Hardcode settings for TERMCAP and COLUMNS so we can try to get -## reproducible results between environments -@ENV{qw(TERMCAP COLUMNS)} = ('co=76:do=^J', 76); - -sub catfile(@) { File::Spec->catfile(@_); } - -my $INSTDIR = abs_path(dirname $0); -$INSTDIR = VMS::Filespec::unixpath($INSTDIR) if $^O eq 'VMS'; -$INSTDIR =~ s#/$## if $^O eq 'VMS'; -$INSTDIR =~ s#:$## if $^O eq 'MacOS'; -$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 'pod'); -$INSTDIR =~ s#:$## if $^O eq 'MacOS'; -$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 't'); -my @PODINCDIRS = ( catfile($INSTDIR, 'lib', 'Pod'), - catfile($INSTDIR, 'scripts'), - catfile($INSTDIR, 'pod'), - catfile($INSTDIR, 't', 'pod') - ); - -# FIXME - we should make the core capable of finding utilities built in -# locations in ext. -push @PODINCDIRS, catfile((File::Spec->updir()) x 2, 'pod') if $ENV{PERL_CORE}; - -## Find the path to the file to =include -sub findinclude { - my $self = shift; - my $incname = shift; - - ## See if its already found w/out any "searching; - return $incname if (-r $incname); - - ## Need to search for it. Look in the following directories ... - ## 1. the directory containing this pod file - my $thispoddir = dirname $self->input_file; - ## 2. the parent directory of the above - my $parentdir = dirname $thispoddir; - my @podincdirs = ($thispoddir, $parentdir, @PODINCDIRS); - - for (@podincdirs) { - my $incfile = catfile($_, $incname); - return $incfile if (-r $incfile); - } - warn("*** Can't find =include file $incname in @podincdirs\n"); - return ""; -} - -sub command { - my $self = shift; - my ($cmd, $text, $line_num, $pod_para) = @_; - $cmd = '' unless (defined $cmd); - local $_ = $text || ''; - my $out_fh = $self->output_handle; - - ## Defer to the superclass for everything except '=include' - return $self->SUPER::command(@_) unless ($cmd eq "include"); - - ## We have an '=include' command - my $incdebug = 1; ## debugging - my @incargs = split; - if (@incargs == 0) { - warn("*** No filename given for '=include'\n"); - return; - } - my $incfile = $self->findinclude(shift @incargs) or return; - my $incbase = basename $incfile; - print $out_fh "###### begin =include $incbase #####\n" if ($incdebug); - $self->parse_from_file( {-cutting => 1}, $incfile ); - print $out_fh "###### end =include $incbase #####\n" if ($incdebug); -} - -sub begin_input { - $_[0]->{_INFILE} = VMS::Filespec::unixify($_[0]->{_INFILE}) if $^O eq 'VMS'; -} - -sub podinc2plaintext( $ $ ) { - my ($infile, $outfile) = @_; - local $_; - my $text_parser = $MYPKG->new; - $text_parser->parse_from_file($infile, $outfile); -} - -sub testpodinc2plaintext( @ ) { - my %args = @_; - my $infile = $args{'-In'} || croak "No input file given!"; - my $outfile = $args{'-Out'} || croak "No output file given!"; - my $cmpfile = $args{'-Cmp'} || croak "No compare-result file given!"; - - my $different = ''; - my $testname = basename $cmpfile, '.t', '.xr'; - - unless (-e $cmpfile) { - my $msg = "*** Can't find comparison file $cmpfile for testing $infile"; - warn "$msg\n"; - return $msg; - } - - print "# Running testpodinc2plaintext for '$testname'...\n"; - ## Compare the output against the expected result - podinc2plaintext($infile, $outfile); - if ( testcmp($outfile, $cmpfile) ) { - $different = "$outfile is different from $cmpfile"; - } - else { - unlink($outfile); - } - return $different; -} - -sub testpodplaintext( @ ) { - my %opts = (ref $_[0] eq 'HASH') ? %{shift()} : (); - my @testpods = @_; - my ($testname, $testdir) = ("", ""); - my ($podfile, $cmpfile) = ("", ""); - my ($outfile, $errfile) = ("", ""); - my $passes = 0; - my $failed = 0; - local $_; - - print "1..", scalar @testpods, "\n" unless ($opts{'-xrgen'}); - - for $podfile (@testpods) { - ($testname, $_) = fileparse($podfile); - $testdir ||= $_; - $testname =~ s/\.t$//; - $cmpfile = $testdir . $testname . '.xr'; - $outfile = $testdir . $testname . '.OUT'; - - if ($opts{'-xrgen'}) { - if ($opts{'-force'} or ! -e $cmpfile) { - ## Create the comparison file - print "# Creating expected result for \"$testname\"" . - " pod2plaintext test ...\n"; - podinc2plaintext($podfile, $cmpfile); - } - else { - print "# File $cmpfile already exists" . - " (use '-force' to regenerate it).\n"; - } - next; - } - - my $failmsg = testpodinc2plaintext - -In => $podfile, - -Out => $outfile, - -Cmp => $cmpfile; - if ($failmsg) { - ++$failed; - print "#\tFAILED. ($failmsg)\n"; - print "not ok ", $failed+$passes, "\n"; - } - else { - ++$passes; - unlink($outfile); - print "#\tPASSED.\n"; - print "ok ", $failed+$passes, "\n"; - } - } - return $passes; -} - -1; -- 1.8.2.1
Patches applied in Pod-Usage-1.62. Many thanks!!