From b3e335c2b47f57c2d32282f7f26ea73a3536807f Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 18 Dec 2011 19:36:14 +0100 Subject: 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. --- installman | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'installman') diff --git a/installman b/installman index e798e9a425..495b9ca467 100755 --- a/installman +++ b/installman @@ -84,12 +84,12 @@ while () { 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 () { } 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); -- cgit v1.2.1