diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-03-05 11:02:36 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-03-05 11:02:36 +0000 |
commit | 44bb145d41e4ce9724498acb159e8fa91b9d010d (patch) | |
tree | a2dd406621bc390206b4bfc5d274d03ab4d14b4e /libexec | |
parent | f24302530201508f541d4c58c5d29fa459b84204 (diff) |
bit of clean-up, cosmetic, style, comments.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis.pm | 53 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Check.pm | 4 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Find.pm | 16 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm | 6 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Whatis.pm | 11 |
5 files changed, 52 insertions, 38 deletions
diff --git a/libexec/makewhatis/OpenBSD/Makewhatis.pm b/libexec/makewhatis/OpenBSD/Makewhatis.pm index e62ee1d117f..3556c00737a 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Makewhatis.pm,v 1.4 2004/08/07 07:52:10 espie Exp $ +# $OpenBSD: Makewhatis.pm,v 1.5 2005/03/05 11:02:35 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -22,11 +22,11 @@ package OpenBSD::Makewhatis; my ($picky, $testmode); -# $subjects = scan_manpages($list) +# $subjects = scan_manpages(\@list) # # scan a set of manpages, return list of subjects # -sub scan_manpages +sub scan_manpages($) { my $list = shift; local $_; @@ -84,7 +84,7 @@ sub scan_manpages # # build index for $dir # -sub build_index +sub build_index($) { require OpenBSD::Makewhatis::Find; require OpenBSD::Makewhatis::Whatis; @@ -95,7 +95,11 @@ sub build_index OpenBSD::Makewhatis::Whatis::write($subjects, $dir); } -sub merge +# merge($dir, \@pages) +# +# merge set of pages into directory index +# +sub merge($$) { require OpenBSD::Makewhatis::Whatis; @@ -107,16 +111,20 @@ sub merge my $whatis = "$mandir/whatis.db"; my $subjects = scan_manpages($args); if (open(my $old, '<', $whatis)) { - while (<$old>) { - chomp; - push(@$subjects, $_); + while (my $l = <$old>) { + chomp $l; + push(@$subjects, $l); } close($old); } OpenBSD::Makewhatis::Whatis::write($subjects, $mandir); } -sub remove +# remove(dir, \@pages) +# +# remove set of pages from directory index +# +sub remove($$) { require OpenBSD::Makewhatis::Whatis; @@ -126,33 +134,40 @@ sub remove } my $whatis = "$mandir/whatis.db"; open(my $old, '<', $whatis) or - die "$0 $whatis to merge with"; + die "$0: can't open $whatis to merge with: $!"; my $subjects = scan_manpages($args); my %remove = map {$_ => 1 } @$subjects; $subjects = []; - while (<$old>) { - chomp; - push(@$subjects, $_) unless defined $remove{$_}; + while (my $l = <$old>) { + chomp $l; + push(@$subjects, $l) unless defined $remove{$l}; } close($old); OpenBSD::Makewhatis::Whatis::write($subjects, $mandir); } -sub default_dirs +# $dirs = default_dirs() +# +# read list of default directories from man.conf +# +sub default_dirs() { - local $_; my $args=[]; open(my $conf, '<', '/etc/man.conf') or die "$0: Can't open /etc/man.conf"; - while (<$conf>) { - chomp; - push(@$args, $1) if /^_whatdb\s+(.*)\/whatis\.db\s*$/; + while (my $l = <$conf>) { + chomp $l; + push(@$args, $1) if $l =~ m/^_whatdb\s+(.*)\/whatis\.db\s*$/; } close $conf; return $args; } -sub makewhatis +# makewhatis(\@args, \%opts) +# +# glue for front-end, see makewhatis(8) +# +sub makewhatis($$) { my ($args, $opts) = @_; if (defined $opts->{'p'}) { diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm index 66ee4ba12e9..96e7a574e76 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Check.pm,v 1.1 2004/08/06 12:05:08 espie Exp $ +# $OpenBSD: Check.pm,v 1.2 2005/03/05 11:02:35 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -46,7 +46,7 @@ sub found($$) # # reparse the subject we're about to add, and check whether it makes # sense, e.g., is there a man page around. -sub verify_subject +sub verify_subject($$) { local $_ = shift; my $filename = shift; diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm index 2673b86e9c2..8d38b860637 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Find.pm,v 1.1 2004/08/06 12:05:08 espie Exp $ +# $OpenBSD: Find.pm,v 1.2 2005/03/05 11:02:35 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -25,19 +25,19 @@ use File::Find; # # find all manpages under $dir, trim some duplicates. # -sub find_manpages +sub find_manpages($) { my $dir = shift; my ($list, %nodes); $list=[]; find( sub { - return unless /\.[\dln]\w*(?:\.Z|\.gz)?$/; - return unless -f $_; - my $unique = (stat _)[0]."/".(stat _)[1]; - return if defined $nodes{$unique}; - $nodes{$unique} = 1; - push(@$list, $File::Find::name); + return unless m/\.[\dln]\w*(?:\.Z|\.gz)?$/; + return unless -f $_; + my $unique = (stat _)[0]."/".(stat _)[1]; + return if defined $nodes{$unique}; + $nodes{$unique} = 1; + push(@$list, $File::Find::name); }, $dir); return $list; } diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm index 127bf9681f6..f909fe08e5c 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Formated.pm,v 1.2 2004/12/24 00:00:04 espie Exp $ +# $OpenBSD: Formated.pm,v 1.3 2005/03/05 11:02:35 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -18,7 +18,7 @@ use strict; use warnings; package OpenBSD::Makewhatis::Formated; -# add_formated_subject($subjects, $_, $section): +# add_formated_subject($subjects, $_, $section, $filename, $picky): # add subject $_ to the list of current $subjects, in section $section. # sub add_formated_subject @@ -73,7 +73,7 @@ sub handle my $foundname = 0; while (<$file>) { chomp; - if (/^$/) { + if (m/^$/) { # perl aggregates several subjects in one manpage # so we don't stop after we've got one subject add_formated_subject(\@lines, $subject, $section, $filename, $picky) diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Whatis.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Whatis.pm index 7f5111fb179..308e7c7a9ab 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Whatis.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Whatis.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Whatis.pm,v 1.2 2004/08/24 08:29:30 espie Exp $ +# $OpenBSD: Whatis.pm,v 1.3 2005/03/05 11:02:35 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -33,7 +33,6 @@ sub write { my ($list, $dir) = @_; my $f = "$dir/whatis.db"; - local $_; my ($out, $tempname); ($out, $tempname) = tempfile('/tmp/makewhatis.XXXXXXXXXX') or die "$0: Can't open temporary file"; @@ -41,10 +40,10 @@ sub write my @sorted = sort @$list; my $last; - while ($_ = shift @sorted) { - next if length > MAXLINELEN; - print $out $_, "\n" unless defined $last and $_ eq $last; - $last = $_; + while (my $l = shift @sorted) { + next if length $l > MAXLINELEN; + print $out $l, "\n" unless defined $last and $l eq $last; + $last = $l; } close $out; if (compare($tempname, $f) == 0) { |