summaryrefslogtreecommitdiff
path: root/pod/buildtoc
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-11-27 21:26:46 +0100
committerNicholas Clark <nick@ccl4.org>2011-11-27 21:34:27 +0100
commitb0f2e9edf966bfc1d2c74c5c60829849f5a6832e (patch)
tree764395eab89d119880a93e1f43add547de67ed81 /pod/buildtoc
parent1d59c038541d06bcc3c0126ba2a62aefd47228a2 (diff)
downloadperl-b0f2e9edf966bfc1d2c74c5c60829849f5a6832e.tar.gz
Fix two bugs related to pod files outside of pod/
Commit 1721346e4e420217, which allowed buildtoc to handle files outside of pod/, had two bugs when processing files from outside of pod/ Firstly, the call to podset() for the core pods needs to pass in the short name of the pod, not the name with the path in it (ie $_->[4], not $_->[1]), else the =head2 entry for that pod will have the pathname in it. Secondly, buildtoc must take care to avoid outputting the contents for these pods twice - once when read from cpan/ or dist/ using the path in pod.lst, and once from the file as found in lib/
Diffstat (limited to 'pod/buildtoc')
-rw-r--r--pod/buildtoc18
1 files changed, 15 insertions, 3 deletions
diff --git a/pod/buildtoc b/pod/buildtoc
index 29c8bc89f8..b3a13c48fa 100644
--- a/pod/buildtoc
+++ b/pod/buildtoc
@@ -1,12 +1,13 @@
#!/usr/bin/perl -w
use strict;
-use vars qw(%Found $Quiet);
+use vars qw(%Found $Quiet %Lengths %MD5s);
use File::Spec;
use File::Find;
use FindBin;
use Text::Wrap;
use Getopt::Long;
+use Digest::MD5 'md5';
no locale;
@@ -99,7 +100,7 @@ EOPOD2B
# All the things in the master list that happen to be pod filenames
foreach (grep {defined $_ && @$_ == 5 && !$_->[0]{toc_omit}} @{$state->{master}}) {
- podset($_->[1], $_->[2]);
+ podset($_->[4], $_->[2], $_->[1] ne $_->[4]);
}
foreach my $type (qw(PRAGMA MODULE)) {
@@ -158,11 +159,22 @@ exit(0);
my ($inhead1, $inhead2, $initem);
sub podset {
- my ($pod, $file) = @_;
+ my ($pod, $file, $possibly_duplicated) = @_;
local $/ = '';
open my $fh, '<', $file or my_die "Can't open file '$file' for $pod: $!";
+ if ($possibly_duplicated) {
+ # We are a dual-life perl*.pod file, which will have be copied to lib/
+ # by the build process, and hence also found there.
+ ++$Lengths{-s $file};
+ ++$MD5s{md5(slurp_or_die($file))};
+ } elsif (!defined $possibly_duplicated) {
+ # We are a file in lib. Are we a duplicate?
+ # Don't bother calculating the MD5 if there's no intersting file of this
+ # length.
+ return if $Lengths{-s $file} && $MD5s{md5(slurp_or_die($file))};
+ }
while(<$fh>) {
tr/\015//d;