summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-12-17 11:32:54 +0100
committerNicholas Clark <nick@ccl4.org>2011-12-19 13:55:19 +0100
commit449e2f794bd454dce291b0a7192232fe882f1318 (patch)
tree0d41532afaf6eda2ab0259f0cc446be3fafc7a68
parent524b493266cc54d7a692b52997e57235d9fdeabe (diff)
downloadperl-449e2f794bd454dce291b0a7192232fe882f1318.tar.gz
Move the pod de-duplication logic from buildtoc to pod_lib.pl
is_duplicate_pod() moves. register_duplicate_pod() can be inlined into get_pod_metadata().
-rw-r--r--Porting/pod_lib.pl20
-rw-r--r--pod/buildtoc24
2 files changed, 20 insertions, 24 deletions
diff --git a/Porting/pod_lib.pl b/Porting/pod_lib.pl
index 25e33d58bc..3676953db6 100644
--- a/Porting/pod_lib.pl
+++ b/Porting/pod_lib.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl -w
use strict;
+use Digest::MD5 'md5';
# make it clearer when we haven't run to completion, as we can be quite
# noisy when things are working ok
@@ -36,6 +37,16 @@ sub write_or_die {
close $fh or die "Can't close $filename: $!";
}
+my (%Lengths, %MD5s);
+
+sub is_duplicate_pod {
+ my $file = shift;
+ # We are a file in lib. Are we a duplicate?
+ # Don't bother calculating the MD5 if there's no interesting file of
+ # this length.
+ return $Lengths{-s $file} && $MD5s{md5(slurp_or_die($file))};
+}
+
sub get_pod_metadata {
# Do we expect to find generated pods on disk?
my $permit_missing_generated = shift;
@@ -116,6 +127,15 @@ sub get_pod_metadata {
}
my_die "Unknown flag found in section line: $_" if length $flags;
my ($leafname) = $podname =~ m!([^/]+)$!;
+
+ if ($leafname ne $podname) {
+ # We are a dual-life perl*.pod file, which will have be copied
+ # to lib/ by the build process, and hence also found there.
+ # These are the only pod files that might become duplicated.
+ ++$Lengths{-s $filename};
+ ++$MD5s{md5(slurp_or_die($filename))};
+ }
+
push @{$state{master}},
[\%flags, $podname, $filename, $desc, $leafname];
} elsif (/^$/) {
diff --git a/pod/buildtoc b/pod/buildtoc
index 9a43fa5c55..edf77ed1fd 100644
--- a/pod/buildtoc
+++ b/pod/buildtoc
@@ -7,7 +7,6 @@ use File::Find;
use FindBin;
use Text::Wrap;
use Getopt::Long;
-use Digest::MD5 'md5';
no locale;
@@ -97,9 +96,6 @@ EOPOD2B
# All the things in the master list that happen to be pod filenames
foreach (grep {defined $_ && @$_ == 5 && !$_->[0]{toc_omit}} @{$state->{master}}) {
- # Only bother registering those files that we know that we copy
- register_duplicate_pod($_->[2])
- if $_->[1] ne $_->[4];
$roffitall .= " \$mandir/$_->[4].1 \\\n";
podset($_->[4], $_->[2]);
}
@@ -223,26 +219,6 @@ exit(0);
# Below are all the auxiliary routines for generating perltoc.pod
-{
- my (%Lengths, %MD5s);
-
- sub register_duplicate_pod {
- my $file = shift;
- # 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))};
- }
-
- sub is_duplicate_pod {
- my $file = shift;
- # We are a file in lib. Are we a duplicate?
- # Don't bother calculating the MD5 if there's no interesting file of
- # this length.
- return $Lengths{-s $file} && $MD5s{md5(slurp_or_die($file))};
- }
-}
-
my ($inhead1, $inhead2, $initem);
sub podset {