Skip to content

Commit bfa0bbb

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 fdcae88 commit bfa0bbb

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

lib/ExtUtils/MM_Unix.pm

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,43 +1491,41 @@ Initializes MAN3PODS from the list of PM files.
14911491
sub init_MAN3PODS {
14921492
my $self = shift;
14931493

1494-
my %manifypods = (); # we collect the keys first, i.e. the files
1495-
# we have to convert to pod
1496-
1497-
foreach my $name (keys %{$self->{PM}}) {
1498-
if ($name =~ /\.pod\z/ ) {
1499-
$manifypods{$name} = $self->{PM}{$name};
1500-
} elsif ($name =~ /\.p[ml]\z/ ) {
1501-
if( $self->_has_pod($name) ) {
1502-
$manifypods{$name} = $self->{PM}{$name};
1503-
}
1504-
}
1505-
}
1506-
15071494
my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1508-
1509-
# Remove "Configure.pm" and similar, if it's not the only pod listed
1510-
# To force inclusion, just name it "Configure.pod", or override
1511-
# MAN3PODS
1512-
foreach my $name (keys %manifypods) {
1513-
if (
1495+
my %man;
1496+
foreach my $name (sort keys %{$self->{PM}}) {
1497+
# Remove "Configure.pm" and similar, if it's not the only pod listed
1498+
# To force inclusion, just name it "Configure.pod", or override
1499+
# MAN3PODS
1500+
if (
15141501
($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) or
15151502
( $name eq 'README.pod') # don't manify top-level README.pod
15161503
) {
1517-
delete $manifypods{$name};
1518-
next;
1519-
}
1520-
my($manpagename) = $name;
1521-
$manpagename =~ s/\.p(od|m|l)\z//;
1522-
# everything below lib is ok
1523-
unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1524-
$manpagename = $self->catfile(
1525-
split(/::/,$self->{PARENT_NAME}),$manpagename
1526-
);
1527-
}
1528-
$manpagename = $self->replace_manpage_separator($manpagename);
1529-
$self->{MAN3PODS}->{$name} =
1530-
$self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1504+
next;
1505+
}
1506+
my $man = $name;
1507+
$man =~ s/\.(p(?:od|m|l))\z//;
1508+
my $ext = $1;
1509+
unless ($man =~ s!^\W*($parentlibs_re)\W+!!s) {
1510+
$man = $self->catfile(
1511+
split(/::/,$self->{PARENT_NAME}),$man
1512+
);
1513+
}
1514+
$man = $self->replace_manpage_separator($man) .'.$(MAN3EXT)';
1515+
if ($ext && $ext eq 'pod') {
1516+
$man{$man} = $name;
1517+
}
1518+
else {
1519+
$man{$man} ||= $name;
1520+
}
1521+
}
1522+
1523+
foreach my $man (keys %man) {
1524+
my $name = $man{$man};
1525+
next
1526+
if $name =~ /\.p[ml]\z/ && !$self->_has_pod($name);
1527+
$self->{MAN3PODS}->{$name} =
1528+
$self->catfile("\$(INST_MAN3DIR)", $man);
15311529
}
15321530
}
15331531

0 commit comments

Comments
 (0)