diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-12-18 19:36:14 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-12-19 13:55:20 +0100 |
commit | b3e335c2b47f57c2d32282f7f26ea73a3536807f (patch) | |
tree | af09e9b6deec9133e3d40a6ef4104de4e59d8a23 /installman | |
parent | a73d7a2450e62847d0d471100c7ca5791572a067 (diff) | |
download | perl-b3e335c2b47f57c2d32282f7f26ea73a3536807f.tar.gz |
In installman, pod2man() now takes a hashref instead of a list of scripts.
Avoid needless splitting and joining of paths when processing the "scripts"
from utils.lst. Remove the unused lexical $where2. Remove an inaccurate
comment about nochdir.
Diffstat (limited to 'installman')
-rwxr-xr-x | installman | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/installman b/installman index e798e9a425..495b9ca467 100755 --- a/installman +++ b/installman @@ -84,12 +84,12 @@ while (<UTILS>) { next if /^#/; chomp; $_ = $1 if /#.*pod\s*=\s*(\S+)/; - my ($where, $what) = m|^(\S*)/(\S+)|; - pod2man($where, $opts{man1dir}, $opts{man1ext}, $what); + my ($path, $leaf) = m|^(\S*/(\S+))|; + pod2man({$leaf, $path}, $opts{man1dir}, $opts{man1ext}); if ($has_man1dir) { - if (my ($where2, $what2) = m|#.*link\s*=\s*(\S+)/(\S+)|) { - my $old = "$opts{man1dir}/$what.$opts{man1ext}"; - my $new = "$opts{man1dir}/$what2.$opts{man1ext}"; + if (my ($link) = m|#.*link\s*=\s*\S+/(\S+)|) { + my $old = "$opts{man1dir}/$leaf.$opts{man1ext}"; + my $new = "$opts{man1dir}/$link.$opts{man1ext}"; unlink($new); link($old, $new); my $xold = $old; @@ -102,49 +102,51 @@ while (<UTILS>) { } sub pod2man { - # @script is scripts names if we are installing manpages embedded - # in scripts, () otherwise - my($poddir, $mandir, $manext, @script) = @_; + my($what, $mandir, $manext) = @_; if ($mandir eq ' ' or $mandir eq '') { - if (@script) { - warn "Skipping installation of $poddir/$_ man page.\n" - foreach @script; + if (ref $what) { + warn "Skipping installation of $_ man page.\n" + foreach values %$what; } else { - warn "Skipping installation of $poddir man pages.\n"; + warn "Skipping installation of $what man pages.\n" } return; } - print "installing from $poddir\n" if $opts{verbose}; + if ($opts{verbose}) { + if (ref $what) { + print "installing $_\n" + foreach sort keys %$what; + } else { + print "installing from $what\n"; + } + } mkpath($mandir, $opts{verbose}, 0777) unless $opts{notify}; # In File::Path - # Make a list of all the .pm and .pod files in the directory. We avoid - # chdir because we are running with @INC = '../lib', and modules may wish - # to dynamically require Carp::Heavy or other diagnostics warnings. - # Hash the names of files we find, keys are names relative to perl build - # dir ('.'), values are names relative to $poddir. - my %modpods; - if (@script) { - %modpods = (map {$_, "$poddir/$_"} @script); + + my $modpods; + if (ref $what) { + $modpods = $what; } else { + # Make a list of all the .pm and .pod files in the directory. File::Find::find({no_chdir=>1, wanted => sub { # $_ is $File::Find::name when using no_chdir if (-f $_ and /\.p(?:m|od)$/) { my $fullname = $_; - s!^\Q$poddir\E/!!; + s!^\Q$what\E/!!; # perlfaq manpages are installed in section 1, # so skip when searching files for section 3 return if m(perlfaq.?\.pod|perlglossary.pod); - $modpods{$_} = $fullname; + $modpods->{$_} = $fullname; } }}, - $poddir); + $what); } my @to_process; - foreach my $manpage (sort keys %modpods) { - my $mod = $modpods{$manpage}; + foreach my $manpage (sort keys %$modpods) { + my $mod = $modpods->{$manpage}; my $tmp; # Skip .pm files that have corresponding .pod files, and Functions.pm. next if (($tmp = $mod) =~ s/\.pm$/.pod/ && -f $tmp); |