diff options
-rw-r--r-- | lib/Pod/Man.pm | 30 | ||||
-rw-r--r-- | lib/Pod/Text.pm | 33 | ||||
-rw-r--r-- | lib/Pod/Text/Color.pm | 15 | ||||
-rw-r--r-- | lib/Pod/Text/Termcap.pm | 14 | ||||
-rw-r--r-- | lib/Pod/t/basic.t | 3 | ||||
-rwxr-xr-x | lib/Pod/t/color.t | 5 | ||||
-rw-r--r-- | lib/Pod/t/man.t | 93 | ||||
-rwxr-xr-x | lib/Pod/t/termcap.t | 5 | ||||
-rw-r--r-- | lib/Pod/t/text-options.t | 3 | ||||
-rw-r--r-- | lib/Pod/t/text.t | 5 | ||||
-rw-r--r-- | pod/pod2man.PL | 8 | ||||
-rw-r--r-- | pod/pod2text.PL | 9 |
12 files changed, 123 insertions, 100 deletions
diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm index 0ccbfbee0c..e4cf0be8eb 100644 --- a/lib/Pod/Man.pm +++ b/lib/Pod/Man.pm @@ -1,7 +1,7 @@ # Pod::Man -- Convert POD data to formatted *roff input. -# $Id: Man.pm,v 2.4 2005/03/19 19:40:01 eagle Exp $ +# $Id: Man.pm,v 2.8 2006-01-25 23:56:52 eagle Exp $ # -# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 # Russ Allbery <rra@stanford.edu> # Substantial contributions by Sean Burke <sburke@cpan.org> # @@ -40,7 +40,7 @@ use POSIX qw(strftime); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 2.04; +$VERSION = 2.08; # Set the debugging level. If someone has inserted a debug function into this # class already, use that. Otherwise, use any Pod::Simple debug function @@ -300,7 +300,7 @@ sub _handle_element_end { } } elsif ($self->can ("end_$method")) { my $method = 'end_' . $method; - $self->$method; + $self->$method (); } else { DEBUG > 2 and print "No $method end method, skipping\n"; } @@ -1201,6 +1201,26 @@ sub cmd_item_text { my $self = shift; $self->item_common ('text', @_) } sub cmd_item_block { my $self = shift; $self->item_common ('block', @_) } ############################################################################## +# Backward compatibility +############################################################################## + +# Reset the underlying Pod::Simple object between calls to parse_from_file so +# that the same object can be reused to convert multiple pages. +sub parse_from_file { + my $self = shift; + $self->reinit; + my $retval = $self->SUPER::parse_from_file (@_); + my $fh = $self->output_fh (); + my $oldfh = select $fh; + my $oldflush = $|; + $| = 1; + print $fh ''; + $| = $oldflush; + select $oldfh; + return $retval; +} + +############################################################################## # Translation tables ############################################################################## @@ -1607,7 +1627,7 @@ mine). =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm index 70db15f0d0..089d6b0b18 100644 --- a/lib/Pod/Text.pm +++ b/lib/Pod/Text.pm @@ -1,7 +1,8 @@ # Pod::Text -- Convert POD data to formatted ASCII text. -# $Id: Text.pm,v 3.1 2005/03/19 19:40:01 eagle Exp $ +# $Id: Text.pm,v 3.6 2006-01-25 23:56:52 eagle Exp $ # -# Copyright 1999, 2000, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2000, 2001, 2002, 2004, 2006 +# by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -40,7 +41,7 @@ use Pod::Simple (); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 3.01; +$VERSION = 3.06; ############################################################################## # Initialization @@ -192,7 +193,7 @@ sub _handle_element_end { } } elsif ($self->can ("end_$method")) { my $method = 'end_' . $method; - $self->$method; + $self->$method (); } } @@ -573,12 +574,32 @@ sub pod2text { return; } $fhs[0] = \*IN; - return $parser->parse_file (@fhs); + $parser->output_fh ($fhs[1]); + my $retval = $parser->parse_file ($fhs[0]); + my $fh = $parser->output_fh (); + close $fh; + return $retval; } else { return $parser->parse_file (@_); } } +# Reset the underlying Pod::Simple object between calls to parse_from_file so +# that the same object can be reused to convert multiple pages. +sub parse_from_file { + my $self = shift; + $self->reinit; + my $retval = $self->Pod::Simple::parse_from_file (@_); + my $fh = $self->output_fh (); + my $oldfh = select $fh; + my $oldflush = $|; + $| = 1; + print $fh ''; + $| = $oldflush; + select $oldfh; + return $retval; +} + ############################################################################## # Module return value and documentation ############################################################################## @@ -733,7 +754,7 @@ how to use Pod::Simple. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2000, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>. +Copyright 1999, 2000, 2001, 2002, 2004, 2006 Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Pod/Text/Color.pm b/lib/Pod/Text/Color.pm index 68de203e4e..ce95dbe56f 100644 --- a/lib/Pod/Text/Color.pm +++ b/lib/Pod/Text/Color.pm @@ -1,7 +1,7 @@ # Pod::Text::Color -- Convert POD data to formatted color ASCII text -# $Id: Color.pm,v 2.1 2004/12/31 21:50:00 eagle Exp $ +# $Id: Color.pm,v 2.3 2006-01-25 23:56:54 eagle Exp $ # -# Copyright 1999, 2001, 2004 by Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -29,7 +29,7 @@ use vars qw(@ISA $VERSION); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 2.01; +$VERSION = 2.03; ############################################################################## # Overrides @@ -69,9 +69,14 @@ sub wrap { my $output = ''; my $spaces = ' ' x $$self{MARGIN}; my $width = $$self{opt_width} - $$self{MARGIN}; + + # We have to do $shortchar and $longchar in variables because the + # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x. my $char = '(?:(?:\e\[[\d;]+m)*[^\n])'; + my $shortchar = $char . "{0,$width}"; + my $longchar = $char . "{$width}"; while (length > $width) { - if (s/^(${char}{0,$width})\s+// || s/^(${char}{$width})//) { + if (s/^($shortchar)\s+// || s/^($longchar)//) { $output .= $spaces . $1 . "\n"; } else { last; @@ -134,7 +139,7 @@ Russ Allbery <rra@stanford.edu>. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2001, 2004 by Russ Allbery <rra@stanford.edu>. +Copyright 1999, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Pod/Text/Termcap.pm b/lib/Pod/Text/Termcap.pm index f24e4ee70d..0b3caf3436 100644 --- a/lib/Pod/Text/Termcap.pm +++ b/lib/Pod/Text/Termcap.pm @@ -1,7 +1,7 @@ # Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes. -# $Id: Termcap.pm,v 2.1 2004/12/31 21:50:00 eagle Exp $ +# $Id: Termcap.pm,v 2.3 2006-01-25 23:56:54 eagle Exp $ # -# Copyright 1999, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2001, 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -30,7 +30,7 @@ use vars qw(@ISA $VERSION); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 2.01; +$VERSION = 2.03; ############################################################################## # Overrides @@ -107,10 +107,14 @@ sub wrap { # $codes matches a single special sequence. $char matches any number of # special sequences preceeding a single character other than a newline. + # We have to do $shortchar and $longchar in variables because the + # construct ${char}{0,$width} didn't do the right thing until Perl 5.8.x. my $codes = "(?:\Q$$self{BOLD}\E|\Q$$self{UNDL}\E|\Q$$self{NORM}\E)"; my $char = "(?:$codes*[^\\n])"; + my $shortchar = $char . "{0,$width}"; + my $longchar = $char . "{$width}"; while (length > $width) { - if (s/^(${char}{0,$width})\s+// || s/^(${char}{$width})//) { + if (s/^($shortchar)\s+// || s/^($longchar)//) { $output .= $spaces . $1 . "\n"; } else { last; @@ -172,7 +176,7 @@ Russ Allbery <rra@stanford.edu>. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2001, 2002, 2004 by Russ Allbery <rra@stanford.edu>. +Copyright 1999, 2001, 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Pod/t/basic.t b/lib/Pod/t/basic.t index 6a70f7c167..4b88f61130 100644 --- a/lib/Pod/t/basic.t +++ b/lib/Pod/t/basic.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: basic.t,v 1.8 2004/12/31 21:27:58 eagle Exp $ +# $Id: basic.t,v 1.9 2006-01-20 21:20:58 eagle Exp $ # # basic.t -- Basic tests for podlators. # @@ -83,7 +83,6 @@ for (sort keys %translators) { # line. That means that we don't check those things; oh well. The header # changes with each version change or touch of the input file. $parser->parse_from_file (source_path ('basic.pod'), 'out.tmp'); - undef $parser; if ($_ eq 'Pod::Man') { open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; open (OUTPUT, "> out.$translators{$_}") diff --git a/lib/Pod/t/color.t b/lib/Pod/t/color.t index 52146478fb..58783a4f7a 100755 --- a/lib/Pod/t/color.t +++ b/lib/Pod/t/color.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: color.t,v 1.1 2004/12/31 21:50:05 eagle Exp $ +# $Id: color.t,v 1.2 2006-01-20 21:20:58 eagle Exp $ # # color.t -- Additional specialized tests for Pod::Text::Color. # @@ -37,6 +37,7 @@ require Pod::Text::Color; $loaded = 1; print "ok 1\n"; +my $parser = Pod::Text::Color->new or die "Cannot create parser\n"; my $n = 2; while (<DATA>) { next until $_ eq "###\n"; @@ -46,9 +47,7 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Text::Color->new or die "Cannot create parser\n"; $parser->parse_from_file ('tmp.pod', 'out.tmp'); - undef $parser; open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; my $output; { diff --git a/lib/Pod/t/man.t b/lib/Pod/t/man.t index 2225fa49c3..d556f21fb8 100644 --- a/lib/Pod/t/man.t +++ b/lib/Pod/t/man.t @@ -1,9 +1,9 @@ #!/usr/bin/perl -w -# $Id: man.t,v 1.5 2004/02/15 06:42:49 eagle Exp $ +# $Id: man.t,v 1.8 2006-01-25 23:58:22 eagle Exp $ # # man.t -- Additional specialized tests for Pod::Man. # -# Copyright 2002, 2003, 2004 by Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2003, 2004, 2006 by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -29,70 +29,23 @@ use Pod::Man; $loaded = 1; print "ok 1\n"; -SKIP: { - if (defined $ENV{PERL_UNICODE}) { - print "not ok 2 # TODO Unicode not yet supported\n" - } else { - my $pod = <<EOP; -=head1 ACCENTS - -Beyoncé! Beyoncé! Beyoncé!! - - Beyoncé! Beyoncé! - Beyoncé! Beyoncé! - Beyoncé! Beyoncé! - -Older versions didn't convert Beyoncé in verbatim. -EOP - - my $expected = <<"EOM"; -.SH "ACCENTS" -.IX Header "ACCENTS" -Beyonce\\*'! Beyonce\\*'! Beyonce\\*'!! -.PP -.Vb 3 -\\& Beyonce\\*'! Beyonce\\*'! -\\& Beyonce\\*'! Beyonce\\*'! -\\& Beyonce\\*'! Beyonce\\*'! -.Ve -.PP -Older versions didn't convert Beyonce\\*' in verbatim. -EOM - $parser = Pod::Man->new or die "Cannot create parser\n"; - open my $out_fh, ">", 'out.tmp' or die "Can't open \$out_fh: $!"; - $parser->output_fh($out_fh); - $parser->parse_string_document($pod); - close $out_fh; - open my $in_fh, "<", 'out.tmp' or die "Can't open \$in_fh: $!"; - while (<$in_fh>) { last if /^\.TH/; } - my $man; - { - local $/ = undef; - $man = <$in_fh>; - } - close $in_fh; - unlink 'out.tmp'; - if ($man eq $expected) { - print "ok 2\n"; - } else { - print "not ok 2\n"; - print "Expected\n========\n$expected\nOutput\n======\n$man\n"; - } - } -} - -my $n = 3; +my $parser = Pod::Man->new or die "Cannot create parser\n"; +my $n = 2; while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; + + # We have a test in ISO 8859-1 encoding. Make sure that nothing strange + # happens if Perl thinks the world is Unicode. Wrap this in eval so that + # older versions of Perl don't croak. + eval { binmode (\*TMP, ':encoding(iso-8859-1)') }; + while (<DATA>) { last if $_ eq "###\n"; print TMP $_; } close TMP; - my $parser = Pod::Man->new or die "Cannot create parser\n"; $parser->parse_from_file ('tmp.pod', 'out.tmp'); - undef $parser; open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; while (<OUT>) { last if /^\.TH/ } my $output; @@ -192,6 +145,32 @@ Also not a bullet. ### ### +=encoding iso-8859-1 + +=head1 ACCENTS + +Beyoncé! Beyoncé! Beyoncé!! + + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + +Older versions didn't convert Beyoncé in verbatim. +### +.SH "ACCENTS" +.IX Header "ACCENTS" +Beyonce\*'! Beyonce\*'! Beyonce\*'!! +.PP +.Vb 3 +\& Beyonce\*'! Beyonce\*'! +\& Beyonce\*'! Beyonce\*'! +\& Beyonce\*'! Beyonce\*'! +.Ve +.PP +Older versions didn't convert Beyonce\*' in verbatim. +### + +### =over 4 =item 1. Not a number diff --git a/lib/Pod/t/termcap.t b/lib/Pod/t/termcap.t index f5e5b39f52..e3e8c7ca05 100755 --- a/lib/Pod/t/termcap.t +++ b/lib/Pod/t/termcap.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: termcap.t,v 1.2 2005/11/28 23:38:02 eagle Exp $ +# $Id: termcap.t,v 1.3 2006-01-20 21:20:58 eagle Exp $ # # termcap.t -- Additional specialized tests for Pod::Text::Termcap. # @@ -34,6 +34,7 @@ use Pod::Text::Termcap; $loaded = 1; print "ok 1\n"; +my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n"; my $n = 2; while (<DATA>) { next until $_ eq "###\n"; @@ -43,9 +44,7 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n"; $parser->parse_from_file ('tmp.pod', 'out.tmp'); - undef $parser; open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; my $output; { diff --git a/lib/Pod/t/text-options.t b/lib/Pod/t/text-options.t index 6fadd2998f..cb418d3b69 100644 --- a/lib/Pod/t/text-options.t +++ b/lib/Pod/t/text-options.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: text-options.t,v 1.4 2004/12/31 21:29:34 eagle Exp $ +# $Id: text-options.t,v 1.5 2006-01-20 21:20:58 eagle Exp $ # # text-options.t -- Additional tests for Pod::Text options. # @@ -46,7 +46,6 @@ while (<DATA>) { close TMP; my $parser = Pod::Text->new (%options) or die "Cannot create parser\n"; $parser->parse_from_file ('tmp.pod', 'out.tmp'); - undef $parser; open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; my $output; { diff --git a/lib/Pod/t/text.t b/lib/Pod/t/text.t index ad39b654a3..fd25c78532 100644 --- a/lib/Pod/t/text.t +++ b/lib/Pod/t/text.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: text.t,v 1.3 2004/12/31 21:29:48 eagle Exp $ +# $Id: text.t,v 1.4 2006-01-20 21:20:58 eagle Exp $ # # text.t -- Additional specialized tests for Pod::Text. # @@ -29,6 +29,7 @@ use Pod::Text; $loaded = 1; print "ok 1\n"; +my $parser = Pod::Text->new or die "Cannot create parser\n"; my $n = 2; while (<DATA>) { next until $_ eq "###\n"; @@ -38,9 +39,7 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Text->new or die "Cannot create parser\n"; $parser->parse_from_file ('tmp.pod', 'out.tmp'); - undef $parser; open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; my $output; { diff --git a/pod/pod2man.PL b/pod/pod2man.PL index 5a78c012ea..9a8414ad92 100644 --- a/pod/pod2man.PL +++ b/pod/pod2man.PL @@ -36,9 +36,9 @@ $Config{startperl} print OUT <<'!NO!SUBS!'; # pod2man -- Convert POD data to formatted *roff input. -# $Id: pod2man.PL,v 1.14 2004/12/31 20:39:30 eagle Exp $ +# $Id: pod2man.PL,v 1.16 2006-01-21 01:53:55 eagle Exp $ # -# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2000, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -84,9 +84,9 @@ delete $options{lax}; # Initialize and run the formatter, pulling a pair of input and output off at # a time. +my $parser = Pod::Man->new (%options); my @files; do { - my $parser = Pod::Man->new (%options); @files = splice (@ARGV, 0, 2); print " $files[1]\n" if $verbose; $parser->parse_from_file (@files); @@ -537,7 +537,7 @@ page, are taken from the B<pod2man> documentation by Tom. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>. +Copyright 1999, 2000, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/pod/pod2text.PL b/pod/pod2text.PL index 785a3f393f..a978f717ad 100644 --- a/pod/pod2text.PL +++ b/pod/pod2text.PL @@ -37,7 +37,7 @@ print OUT <<'!NO!SUBS!'; # pod2text -- Convert POD data to formatted ASCII text. # -# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu> +# Copyright 1999, 2000, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. @@ -99,11 +99,10 @@ if ($options{color}) { delete @options{'color', 'termcap', 'overstrike'}; # Initialize and run the formatter. +my $parser = $formatter->new (%options); do { - my $parser = $formatter->new (%options); my ($input, $output) = splice (@ARGV, 0, 2); - $parser->parse_file ($input, $output); - undef $parser; + $parser->parse_from_file ($input, $output); } while (@ARGV); __END__ @@ -273,7 +272,7 @@ Russ Allbery <rra@stanford.edu>. =head1 COPYRIGHT AND LICENSE -Copyright 1999, 2000, 2001, 2004 by Russ Allbery <rra@stanford.edu>. +Copyright 1999, 2000, 2001, 2004, 2006 by Russ Allbery <rra@stanford.edu>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |