summaryrefslogtreecommitdiff
path: root/pod/buildtoc
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-12-17 11:03:15 +0100
committerNicholas Clark <nick@ccl4.org>2011-12-19 13:55:19 +0100
commit524b493266cc54d7a692b52997e57235d9fdeabe (patch)
treee183ede4871dd6e852bf7da73c9ec0a8ee3e952e /pod/buildtoc
parentb186d677a9fa494035b07d613cfd0fdbaf1aaa5d (diff)
downloadperl-524b493266cc54d7a692b52997e57235d9fdeabe.tar.gz
In installman, break the de-duplication code out from from podset().
It is both clearer and simpler to have separate subroutines to implement the logic to avoid processing copied podfiles more than once.
Diffstat (limited to 'pod/buildtoc')
-rw-r--r--pod/buildtoc46
1 files changed, 29 insertions, 17 deletions
diff --git a/pod/buildtoc b/pod/buildtoc
index 25ff14a8f8..9a43fa5c55 100644
--- a/pod/buildtoc
+++ b/pod/buildtoc
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use vars qw(%Found $Quiet %Lengths %MD5s);
+use vars qw(%Found $Quiet);
use File::Spec;
use File::Find;
use FindBin;
@@ -97,8 +97,11 @@ 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], $_->[1] ne $_->[4]);
+ podset($_->[4], $_->[2]);
}
foreach my $type (qw(PRAGMA MODULE)) {
@@ -111,8 +114,9 @@ foreach my $type (qw(PRAGMA MODULE)) {
EOPOD2B
foreach my $name (sort keys %{$Found{$type}}) {
- $roffitall .= " \$libdir/$name.3 \\\n"
- if podset($name, $Found{$type}{$name});
+ next if is_duplicate_pod($Found{$type}{$name});
+ $roffitall .= " \$libdir/$name.3 \\\n";
+ podset($name, $Found{$type}{$name});
}
}
@@ -219,25 +223,34 @@ 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 {
- my ($pod, $file, $possibly_duplicated) = @_;
+ my ($pod, $file) = @_;
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;
@@ -284,7 +297,6 @@ sub podset {
}
$OUT .= $_;
}
- return 1;
}
sub unhead1 {