summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--lib/Pod/Man.pm23
-rw-r--r--lib/Pod/Text.pm12
-rw-r--r--lib/Pod/t/filehandle.t122
4 files changed, 152 insertions, 6 deletions
diff --git a/MANIFEST b/MANIFEST
index 0eeaae08d7..194f1c6da9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2213,6 +2213,7 @@ lib/Pod/Text/Color.pm Convert POD data to color ASCII text
lib/Pod/Text/Overstrike.pm Convert POD data to formatted overstrike text
lib/Pod/Text.pm Pod-Parser - convert POD data to formatted ASCII text
lib/Pod/Text/Termcap.pm Convert POD data to ASCII text with format escapes
+lib/Pod/t/filehandle.t podlators test
lib/Pod/t/Functions.t See if Pod::Functions works
lib/Pod/t/htmlescp.pod pod2html escape test input data
lib/Pod/t/htmlescp.t pod2html escape test
diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm
index e4cf0be8eb..dd81035ad5 100644
--- a/lib/Pod/Man.pm
+++ b/lib/Pod/Man.pm
@@ -1,5 +1,5 @@
# Pod::Man -- Convert POD data to formatted *roff input.
-# $Id: Man.pm,v 2.8 2006-01-25 23:56:52 eagle Exp $
+# $Id: Man.pm,v 2.9 2006-02-19 23:02:35 eagle Exp $
#
# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# Russ Allbery <rra@stanford.edu>
@@ -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.08;
+$VERSION = 2.09;
# Set the debugging level. If someone has inserted a debug function into this
# class already, use that. Otherwise, use any Pod::Simple debug function
@@ -819,11 +819,18 @@ sub devise_title {
# Determine the modification date and return that, properly formatted in ISO
# format. If we can't get the modification date of the input, instead use the
-# current time.
+# current time. Pod::Simple returns a completely unuseful stringified file
+# handle as the source_filename for input from a file handle, so we have to
+# deal with that as well.
sub devise_date {
my ($self) = @_;
my $input = $self->source_filename;
- my $time = ($input ? (stat $input)[9] : time);
+ my $time;
+ if ($input) {
+ $time = (stat $input)[9] || time;
+ } else {
+ $time = time;
+ }
return strftime ('%Y-%m-%d', localtime $time);
}
@@ -1220,6 +1227,14 @@ sub parse_from_file {
return $retval;
}
+# Pod::Simple failed to provide this backward compatibility function, so
+# implement it ourselves. File handles are one of the inputs that
+# parse_from_file supports.
+sub parse_from_filehandle {
+ my $self = shift;
+ $self->parse_from_file (@_);
+}
+
##############################################################################
# Translation tables
##############################################################################
diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm
index 089d6b0b18..a23f70a0fc 100644
--- a/lib/Pod/Text.pm
+++ b/lib/Pod/Text.pm
@@ -1,5 +1,5 @@
# Pod::Text -- Convert POD data to formatted ASCII text.
-# $Id: Text.pm,v 3.6 2006-01-25 23:56:52 eagle Exp $
+# $Id: Text.pm,v 3.7 2006-02-19 23:02:35 eagle Exp $
#
# Copyright 1999, 2000, 2001, 2002, 2004, 2006
# by Russ Allbery <rra@stanford.edu>
@@ -41,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.06;
+$VERSION = 3.07;
##############################################################################
# Initialization
@@ -600,6 +600,14 @@ sub parse_from_file {
return $retval;
}
+# Pod::Simple failed to provide this backward compatibility function, so
+# implement it ourselves. File handles are one of the inputs that
+# parse_from_file supports.
+sub parse_from_filehandle {
+ my $self = shift;
+ $self->parse_from_file (@_);
+}
+
##############################################################################
# Module return value and documentation
##############################################################################
diff --git a/lib/Pod/t/filehandle.t b/lib/Pod/t/filehandle.t
new file mode 100644
index 0000000000..bcad199444
--- /dev/null
+++ b/lib/Pod/t/filehandle.t
@@ -0,0 +1,122 @@
+#!/usr/bin/perl -w
+# $Id: filehandle.t,v 1.1 2006-02-19 23:02:37 eagle Exp $
+#
+# filehandle.t -- Test the parse_from_filehandle interface.
+#
+# Copyright 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.
+
+BEGIN {
+ chdir 't' if -d 't';
+ if ($ENV{PERL_CORE}) {
+ @INC = '../lib';
+ } else {
+ unshift (@INC, '../blib/lib');
+ }
+ unshift (@INC, '../blib/lib');
+ $| = 1;
+ print "1..3\n";
+}
+
+END {
+ print "not ok 1\n" unless $loaded;
+}
+
+use Pod::Man;
+use Pod::Text;
+
+$loaded = 1;
+print "ok 1\n";
+
+my $man = Pod::Man->new or die "Cannot create parser\n";
+my $text = Pod::Text->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";
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ print TMP $_;
+ }
+ close TMP;
+ open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $man->parse_from_filehandle (\*IN, \*OUT);
+ close IN;
+ close OUT;
+ open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ while (<OUT>) { last if /^\.TH/ }
+ my $output;
+ {
+ local $/;
+ $output = <OUT>;
+ }
+ close OUT;
+ my $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ if ($output eq $expected) {
+ print "ok $n\n";
+ } else {
+ print "not ok $n\n";
+ print "Expected\n========\n$expected\nOutput\n======\n$output\n";
+ }
+ $n++;
+ open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $text->parse_from_filehandle (\*IN, \*OUT);
+ close IN;
+ close OUT;
+ open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ {
+ local $/;
+ $output = <OUT>;
+ }
+ close OUT;
+ unlink ('tmp.pod', 'out.tmp');
+ $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ if ($output eq $expected) {
+ print "ok $n\n";
+ } else {
+ print "not ok $n\n";
+ print "Expected\n========\n$expected\nOutput\n======\n$output\n";
+ }
+ $n++;
+}
+
+# Below the marker are bits of POD, corresponding expected nroff output, and
+# corresponding expected text output. The input and output are separated by
+# lines containing only ###.
+
+__DATA__
+
+###
+=head1 NAME
+
+gcc - GNU project C and C++ compiler
+
+=head1 C++ NOTES
+
+Other mentions of C++.
+###
+.SH "NAME"
+gcc \- GNU project C and C++ compiler
+.SH "\*(C+ NOTES"
+.IX Header " NOTES"
+Other mentions of \*(C+.
+###
+NAME
+ gcc - GNU project C and C++ compiler
+
+C++ NOTES
+ Other mentions of C++.
+
+###