diff options
Diffstat (limited to 'gnu/usr.bin/perl/cpan/podlators/lib/Pod')
6 files changed, 68 insertions, 89 deletions
diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Man.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Man.pm index 71798c2533e..d7c029357a2 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Man.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Man.pm @@ -14,7 +14,7 @@ package Pod::Man; -use 5.006; +use 5.008; use strict; use warnings; @@ -24,7 +24,9 @@ use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION); use Carp qw(carp croak); use Pod::Simple (); -# Conditionally import Encode and set $HAS_ENCODE if it is available. +# Conditionally import Encode and set $HAS_ENCODE if it is available. This is +# required to support building as part of Perl core, since podlators is built +# before Encode is. our $HAS_ENCODE; BEGIN { $HAS_ENCODE = eval { require Encode }; @@ -32,7 +34,7 @@ BEGIN { @ISA = qw(Pod::Simple); -$VERSION = '4.11'; +$VERSION = '4.14'; # Set the debugging level. If someone has inserted a debug function into this # class already, use that. Otherwise, use any Pod::Simple debug function @@ -245,13 +247,8 @@ sub init_quotes { sub init_page { my ($self) = @_; - # We used to try first to get the version number from a local binary, but - # we shouldn't need that any more. Get the version from the running Perl. - # Work a little magic to handle subversions correctly under both the - # pre-5.6 and the post-5.6 version numbering schemes. - my @version = ($] =~ /^(\d+)\.(\d{3})(\d{0,3})$/); - $version[2] ||= 0; - $version[2] *= 10 ** (3 - length $version[2]); + # Get the version from the running Perl. + my @version = ($] =~ /^(\d+)\.(\d{3})(\d+)$/); for (@version) { $_ += 0 } my $version = join ('.', @version); @@ -799,7 +796,7 @@ sub start_document { eval { my @options = (output => 1, details => 1); my @layers = PerlIO::get_layers (*{$$self{output_fh}}, @options); - if ($layers[-1] & PerlIO::F_UTF8 ()) { + if ($layers[-1] && ($layers[-1] & PerlIO::F_UTF8 ())) { $$self{ENCODE} = 0; } } @@ -903,8 +900,6 @@ sub devise_title { $cut = $i + 1; $cut++ if ($dirs[$i + 1] && $dirs[$i + 1] eq 'lib'); last; - } elsif ($dirs[$i] eq 'lib' && $dirs[$i + 1] && $dirs[0] eq 'ext') { - $cut = $i + 1; } } if ($cut > 0) { @@ -1883,7 +1878,9 @@ being the file to write the formatted output to. You can also call parse_lines() to parse an array of lines or parse_string_document() to parse a document already in memory. As with parse_file(), parse_lines() and parse_string_document() default to sending -their output to C<STDOUT> unless changed with the output_fh() method. +their output to C<STDOUT> unless changed with the output_fh() method. Be +aware that parse_lines() and parse_string_document() both expect raw bytes, +not decoded characters. To put the output from any parse method into a string instead of a file handle, call the output_string() method instead of output_fh(). @@ -2014,7 +2011,7 @@ are mine). =head1 COPYRIGHT AND LICENSE -Copyright 1999-2010, 2012-2018 Russ Allbery <rra@cpan.org> +Copyright 1999-2010, 2012-2019 Russ Allbery <rra@cpan.org> Substantial contributions by Sean Burke <sburke@cpan.org>. diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/ParseLink.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/ParseLink.pm index 0be5323973b..273c95847ac 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/ParseLink.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/ParseLink.pm @@ -13,7 +13,7 @@ package Pod::ParseLink; -use 5.006; +use 5.008; use strict; use warnings; @@ -23,7 +23,7 @@ use Exporter; @ISA = qw(Exporter); @EXPORT = qw(parselink); -$VERSION = '4.11'; +$VERSION = '4.14'; ############################################################################## # Implementation @@ -167,11 +167,11 @@ L<perlpodspec> for more information. =head1 AUTHOR -Russ Allbery <rra@cpan.org>. +Russ Allbery <rra@cpan.org> =head1 COPYRIGHT AND LICENSE -Copyright 2001, 2008, 2009, 2014, 2018 Russ Allbery <rra@cpan.org> +Copyright 2001, 2008, 2009, 2014, 2018-2019 Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text.pm index b05730ef476..56e6e78a86c 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text.pm @@ -14,7 +14,7 @@ package Pod::Text; -use 5.006; +use 5.008; use strict; use warnings; @@ -30,7 +30,7 @@ use Pod::Simple (); # We have to export pod2text for backward compatibility. @EXPORT = qw(pod2text); -$VERSION = '4.11'; +$VERSION = '4.14'; # Ensure that $Pod::Simple::nbsp and $Pod::Simple::shy are available. Code # taken from Pod::Simple 3.32, but was only added in 3.30. @@ -39,16 +39,8 @@ if ($Pod::Simple::VERSION ge 3.30) { $NBSP = $Pod::Simple::nbsp; $SHY = $Pod::Simple::shy; } else { - if ($] ge 5.007_003) { - $NBSP = chr utf8::unicode_to_native(0xA0); - $SHY = chr utf8::unicode_to_native(0xAD); - } elsif (Pod::Simple::ASCII) { - $NBSP = "\xA0"; - $SHY = "\xAD"; - } else { - $NBSP = "\x41"; - $SHY = "\xCA"; - } + $NBSP = chr utf8::unicode_to_native(0xA0); + $SHY = chr utf8::unicode_to_native(0xAD); } ############################################################################## @@ -247,7 +239,7 @@ sub wrap { my $spaces = ' ' x $$self{MARGIN}; my $width = $$self{opt_width} - $$self{MARGIN}; while (length > $width) { - if (s/^([^\n]{0,$width})\s+// || s/^([^\n]{$width})//) { + if (s/^([^\n]{0,$width})[ \t\n]+// || s/^([^\n]{$width})//) { $output .= $spaces . $1 . "\n"; } else { last; @@ -265,14 +257,16 @@ sub reformat { local $_ = shift; # If we're trying to preserve two spaces after sentences, do some munging - # to support that. Otherwise, smash all repeated whitespace. + # to support that. Otherwise, smash all repeated whitespace. Be careful + # not to use \s here, which in Unicode input may match non-breaking spaces + # that we don't want to smash. if ($$self{opt_sentence}) { s/ +$//mg; s/\.\n/. \n/g; s/\n/ /g; s/ +/ /g; } else { - s/\s+/ /g; + s/[ \t\n]+/ /g; } return $self->wrap ($_); } @@ -333,15 +327,14 @@ sub start_document { # When UTF-8 output is set, check whether our output file handle already # has a PerlIO encoding layer set. If it does not, we'll need to encode - # our output before printing it (handled in the output() sub). Wrap the - # check in an eval to handle versions of Perl without PerlIO. + # our output before printing it (handled in the output() sub). $$self{ENCODE} = 0; if ($$self{opt_utf8}) { $$self{ENCODE} = 1; eval { my @options = (output => 1, details => 1); my $flag = (PerlIO::get_layers ($$self{output_fh}, @options))[-1]; - if ($flag & PerlIO::F_UTF8 ()) { + if ($flag && ($flag & PerlIO::F_UTF8 ())) { $$self{ENCODE} = 0; $$self{ENCODING} = 'UTF-8'; } @@ -919,7 +912,9 @@ being the file to write the formatted output to. You can also call parse_lines() to parse an array of lines or parse_string_document() to parse a document already in memory. As with parse_file(), parse_lines() and parse_string_document() default to sending -their output to C<STDOUT> unless changed with the output_fh() method. +their output to C<STDOUT> unless changed with the output_fh() method. Be +aware that parse_lines() and parse_string_document() both expect raw bytes, +not decoded characters. To put the output from any parse method into a string instead of a file handle, call the output_string() method instead of output_fh(). @@ -1006,7 +1001,7 @@ how to use Pod::Simple. =head1 COPYRIGHT AND LICENSE -Copyright 1999-2002, 2004, 2006, 2008-2009, 2012-2016, 2018 Russ Allbery +Copyright 1999-2002, 2004, 2006, 2008-2009, 2012-2016, 2018-2019 Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Color.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Color.pm index 8d956f2a5dd..5d47c5ecb3b 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Color.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Color.pm @@ -12,7 +12,7 @@ package Pod::Text::Color; -use 5.006; +use 5.008; use strict; use warnings; @@ -23,7 +23,7 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -$VERSION = '4.11'; +$VERSION = '4.14'; ############################################################################## # Overrides @@ -97,9 +97,6 @@ sub wrap { # $shortchar matches some sequence of $char ending in codes followed by # whitespace or the end of the string. $longchar matches exactly $width # $chars, used when we have to truncate and hard wrap. - # - # $shortchar and $longchar are created in a slightly odd way because the - # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x. my $code = '(?:\e\[[\d;]+m)'; my $char = "(?>$code*[^\\n])"; my $shortchar = '^(' . $char . "{0,$width}(?>$code*)" . ')(?:\s+|\z)'; @@ -185,7 +182,7 @@ Russ Allbery <rra@cpan.org>. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2001, 2004, 2006, 2008, 2009, 2018 Russ Allbery +Copyright 1999, 2001, 2004, 2006, 2008, 2009, 2018-2019 Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Overstrike.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Overstrike.pm index 92a3a9330e0..53bc6afef23 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Overstrike.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Overstrike.pm @@ -19,7 +19,7 @@ package Pod::Text::Overstrike; -use 5.006; +use 5.008; use strict; use warnings; @@ -29,7 +29,7 @@ use Pod::Text (); @ISA = qw(Pod::Text); -$VERSION = '4.11'; +$VERSION = '4.14'; ############################################################################## # Overrides @@ -185,7 +185,7 @@ created by Russ Allbery <rra@cpan.org>. Subsequently updated by Russ Allbery. Copyright 2000 by Joe Smith <Joe.Smith@inwap.com> -Copyright 2001, 2004, 2008, 2014, 2018 by Russ Allbery <rra@cpan.org> +Copyright 2001, 2004, 2008, 2014, 2018-2019 by Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Termcap.pm b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Termcap.pm index d36ba4f518a..be218f0bf04 100644 --- a/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Termcap.pm +++ b/gnu/usr.bin/perl/cpan/podlators/lib/Pod/Text/Termcap.pm @@ -12,7 +12,7 @@ package Pod::Text::Termcap; -use 5.006; +use 5.008; use strict; use warnings; @@ -24,7 +24,7 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -$VERSION = '4.11'; +$VERSION = '4.14'; ############################################################################## # Overrides @@ -36,14 +36,6 @@ sub new { my ($self, %args) = @_; my ($ospeed, $term, $termios); - # $ENV{HOME} is usually not set on Windows. The default Term::Cap path - # may not work on Solaris. - unless (exists $ENV{TERMPATH}) { - my $home = exists $ENV{HOME} ? "$ENV{HOME}/.termcap:" : ''; - $ENV{TERMPATH} = - "${home}/etc/termcap:/usr/share/misc/termcap:/usr/share/lib/termcap"; - } - # Fall back on a hard-coded terminal speed if POSIX::Termios isn't # available (such as on VMS). eval { $termios = POSIX::Termios->new }; @@ -80,10 +72,12 @@ sub new { # Initialize Pod::Text. $self = $self->SUPER::new (%args); - # Fall back on the ANSI escape sequences if Term::Cap doesn't work. - $$self{BOLD} = $bold || "\e[1m"; - $$self{UNDL} = $undl || "\e[4m"; - $$self{NORM} = $norm || "\e[m"; + # If we were unable to get any of the formatting sequences, don't attempt + # that type of formatting. This will do weird things if bold or underline + # were available but normal wasn't, but hopefully that will never happen. + $$self{BOLD} = $bold || q{}; + $$self{UNDL} = $undl || q{}; + $$self{NORM} = $norm || q{}; return $self; } @@ -106,11 +100,19 @@ sub cmd_head2 { sub cmd_b { my $self = shift; return "$$self{BOLD}$_[1]$$self{NORM}" } sub cmd_i { my $self = shift; return "$$self{UNDL}$_[1]$$self{NORM}" } +# Return a regex that matches a formatting sequence. This will only be valid +# if we were able to get at least some termcap information. +sub format_regex { + my ($self) = @_; + my @codes = ($self->{BOLD}, $self->{UNDL}, $self->{NORM}); + return join(q{|}, map { $_ eq q{} ? () : "\Q$_\E" } @codes); +} + # Analyze a single line and return any formatting codes in effect at the end # of that line. sub end_format { my ($self, $line) = @_; - my $pattern = "(\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)"; + my $pattern = "(" . $self->format_regex() . ")"; my $current; while ($line =~ /$pattern/g) { my $code = $1; @@ -147,15 +149,17 @@ sub wrap { my $spaces = ' ' x $$self{MARGIN}; my $width = $$self{opt_width} - $$self{MARGIN}; + # If we were unable to find any termcap sequences, use Pod::Text wrapping. + if ($self->{BOLD} eq q{} && $self->{UNDL} eq q{} && $self->{NORM} eq q{}) { + return $self->SUPER::wrap($_); + } + # $code matches a single special sequence. $char matches any number of # special sequences preceding a single character other than a newline. # $shortchar matches some sequence of $char ending in codes followed by # whitespace or the end of the string. $longchar matches exactly $width # $chars, used when we have to truncate and hard wrap. - # - # $shortchar and $longchar are created in a slightly odd way because the - # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x. - my $code = "(?:\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)"; + my $code = "(?:" . $self->format_regex() . ")"; my $char = "(?>$code*[^\\n])"; my $shortchar = '^(' . $char . "{0,$width}(?>$code*)" . ')(?:\s+|\z)'; my $longchar = '^(' . $char . "{$width})"; @@ -225,34 +229,20 @@ text using the correct termcap escape sequences for the current terminal. Apart from the format codes, it in all ways functions like Pod::Text. See L<Pod::Text> for details and available options. -=head1 ENVIRONMENT - -This module sets the TERMPATH environment variable globally to: - - $HOME/.termcap:/etc/termcap:/usr/share/misc/termcap:/usr/share/lib/termcap - -if it isn't already set. (The first entry is omitted if the HOME -environment variable isn't set.) This is a (very old) workaround for -problems finding termcap information on older versions of Solaris, and is -not good module behavior. Please do not rely on this behavior; it may be -dropped in a future release. - -=head1 NOTES - -This module uses Term::Cap to retrieve the formatting escape sequences for -the current terminal, and falls back on the ECMA-48 (the same in this -regard as ANSI X3.64 and ISO 6429, the escape codes also used by DEC VT100 -terminals) if the bold, underline, and reset codes aren't set in the -termcap information. +This module uses L<Term::Cap> to find the correct terminal settings. See the +documentation of that module for how it finds terminal database information +and how to override that behavior if necessary. If unable to find control +strings for bold and underscore formatting, that formatting is skipped, +resulting in the same output as Pod::Text. =head1 AUTHOR -Russ Allbery <rra@cpan.org>. +Russ Allbery <rra@cpan.org> =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2001-2002, 2004, 2006, 2008-2009, 2014-2015, 2018 Russ Allbery -<rra@cpan.org> +Copyright 1999, 2001-2002, 2004, 2006, 2008-2009, 2014-2015, 2018-2019 Russ +Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |