Skip to content

Commit 6e47258

Browse files
committed
refactor init_MAN3PODS so pod files get priority
This moves the name transforming code into the initial loop through PM, building a hash keyed by the final man name. Pod files will take priority over pm files, which will take priority over pl files. We only check the pm/pl files for Pod once we know that they will be used.
1 parent 023adfc commit 6e47258

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

lib/ExtUtils/MM_Unix.pm

+31-33
Original file line numberDiff line numberDiff line change
@@ -1575,43 +1575,41 @@ Initializes MAN3PODS from the list of PM files.
15751575
sub init_MAN3PODS {
15761576
my $self = shift;
15771577

1578-
my %manifypods = (); # we collect the keys first, i.e. the files
1579-
# we have to convert to pod
1580-
1581-
foreach my $name (keys %{$self->{PM}}) {
1582-
if ($name =~ /\.pod\z/ ) {
1583-
$manifypods{$name} = $self->{PM}{$name};
1584-
} elsif ($name =~ /\.p[ml]\z/ ) {
1585-
if( $self->_has_pod($name) ) {
1586-
$manifypods{$name} = $self->{PM}{$name};
1587-
}
1588-
}
1589-
}
1590-
15911578
my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1592-
1593-
# Remove "Configure.pm" and similar, if it's not the only pod listed
1594-
# To force inclusion, just name it "Configure.pod", or override
1595-
# MAN3PODS
1596-
foreach my $name (keys %manifypods) {
1597-
if (
1579+
my %man;
1580+
foreach my $name (sort keys %{$self->{PM}}) {
1581+
# Remove "Configure.pm" and similar, if it's not the only pod listed
1582+
# To force inclusion, just name it "Configure.pod", or override
1583+
# MAN3PODS
1584+
if (
15981585
($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) or
15991586
( $name =~ m/^README\.pod$/i ) # don't manify top-level README.pod
16001587
) {
1601-
delete $manifypods{$name};
1602-
next;
1603-
}
1604-
my($manpagename) = $name;
1605-
$manpagename =~ s/\.p(od|m|l)\z//;
1606-
# everything below lib is ok
1607-
unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1608-
$manpagename = $self->catfile(
1609-
split(/::/,$self->{PARENT_NAME}),$manpagename
1610-
);
1611-
}
1612-
$manpagename = $self->replace_manpage_separator($manpagename);
1613-
$self->{MAN3PODS}->{$name} =
1614-
$self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1588+
next;
1589+
}
1590+
my $man = $name;
1591+
$man =~ s/\.(p(?:od|m|l))\z//;
1592+
my $ext = $1;
1593+
unless ($man =~ s!^\W*($parentlibs_re)\W+!!s) {
1594+
$man = $self->catfile(
1595+
split(/::/,$self->{PARENT_NAME}),$man
1596+
);
1597+
}
1598+
$man = $self->replace_manpage_separator($man) .'.$(MAN3EXT)';
1599+
if ($ext && $ext eq 'pod') {
1600+
$man{$man} = $name;
1601+
}
1602+
else {
1603+
$man{$man} ||= $name;
1604+
}
1605+
}
1606+
1607+
foreach my $man (keys %man) {
1608+
my $name = $man{$man};
1609+
next
1610+
if $name =~ /\.p[ml]\z/ && !$self->_has_pod($name);
1611+
$self->{MAN3PODS}->{$name} =
1612+
$self->catfile("\$(INST_MAN3DIR)", $man);
16151613
}
16161614
}
16171615

0 commit comments

Comments
 (0)