diff options
author | ru <ru@FreeBSD.org> | 2002-11-18 10:11:22 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-11-18 10:11:22 +0000 |
commit | 6dc5377ec936ad6b02335fbff984a3fbbc374ca5 (patch) | |
tree | 56fc76240a31079df38e999ba1f96251fbe329df /gnu/usr.bin | |
parent | 40e2359f4b10f61d80f4c8a2f6d4a3fc5c377d95 (diff) | |
download | FreeBSD-src-6dc5377ec936ad6b02335fbff984a3fbbc374ca5.zip FreeBSD-src-6dc5377ec936ad6b02335fbff984a3fbbc374ca5.tar.gz |
Install /usr/libexec/makewhatis.local and /usr/libexec/catman.local.
This has slipped through the cracks of The Great Perl Script Rewrite.
Repocopied by: joe
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/man/makewhatis/Makefile | 12 | ||||
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.1 | 148 | ||||
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.local.8 | 82 | ||||
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.local.sh | 58 | ||||
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.perl | 574 |
5 files changed, 0 insertions, 874 deletions
diff --git a/gnu/usr.bin/man/makewhatis/Makefile b/gnu/usr.bin/man/makewhatis/Makefile deleted file mode 100644 index 73eb9e0..0000000 --- a/gnu/usr.bin/man/makewhatis/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ -MAINTAINER= wosch - -SCRIPTS=makewhatis.perl makewhatis.local.sh -MAN= makewhatis.1 makewhatis.local.8 - -libexecdir=/usr/libexec -LINKS=${libexecdir}/makewhatis.local ${libexecdir}/catman.local -SCRIPTSDIR_makewhatis.local.sh= ${libexecdir} -MLINKS= makewhatis.local.8 catman.local.8 - -.include <bsd.prog.mk> diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.1 b/gnu/usr.bin/man/makewhatis/makewhatis.1 deleted file mode 100644 index 015822f..0000000 --- a/gnu/usr.bin/man/makewhatis/makewhatis.1 +++ /dev/null @@ -1,148 +0,0 @@ -.\" Copyright (c) 1994-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd January 12, 1995 -.Dt MAKEWHATIS 1 -.Os -.Sh NAME -.Nm makewhatis -.Nd create whatis database -.Sh SYNOPSIS -.Nm -.Op Fl a | Fl append -.Op Fl h | Fl help -.Op Fl i | Fl indent Ar column -.Op Fl L | Fl locale -.Op Fl n | Fl name Ar name -.Op Fl o | Fl outfile Ar file -.Op Fl v | Fl verbose -.Op Ar directories ... -.Sh DESCRIPTION -.Nm -extracts the name and a short description from unformatted manpages -and creates the -.Xr whatis 1 -database. -.Nm -can read gzip'ed manpages. -.Ar Directory -names a directory containing manpage subdirectories -(named -.Pa man.+ ) . -Colons are treated as spaces, hence -.Ic makewhatis $MANPATH -or -.Ic makewhatis `manpath` -are allowed. -.Sh OPTIONS -.Bl -tag -width Ds -.It Fl a , Fl append -Append mode. Don't delete old entries in whatis database. Note: -the new database will be sorted without repeated lines and -.Nm -does not check if old entries are valid. -.It Fl h , Fl help -Print options and exit. -.It Fl i , Fl indent Ar column -Justify description strings to -.Ar column -(default 24). -.It Fl L , Fl locale -Sense locale environment variables for possible localized man subdirectories -and process this entries only. -.It Fl n , Fl name Ar name -Use -.Ar name -instead of -.Pa whatis . -.It Fl o , Fl outfile Ar file -Write all output to -.Ar file -instead of -.Pa dirname/whatis . -.It Fl v , Fl verbose -Issue more warnings -(to stderr). -For every parsed man page write a single char: -.Ql .\& -for an uncompressed page, -.Ql * -for a compressed page, and -.Ql + -for a link. -.El -.Sh EXAMPLES -.Ic makewhatis $MANPATH -.Pp -Create whatis database for all directories in your -.Pa $MANPATH . -.Pp -.Ic makewhatis -outfile /tmp/mywhatis /usr/local/man $HOME/man -.Pp -Create whatis database -.Pa /tmp/mywhatis . -Traverse directories -.Pa /usr/local/man -and -.Pa $HOME/man . -Don't create -.Pa /usr/local/man/whatis -or -.Pa $HOME/man/whatis . -.Pp -.Ic makewhatis -name windex $HOME/man -.Pp -Create whatis database -.Pa windex -instead of -.Pa whatis . -May be useful for Solaris. -.Sh FILES -.Bl -tag -width /etc/master.passwdxx -compact -.It Pa */man/whatis -whatis database -.It Pa /etc/periodic/weekly/320.whatis -run -.Nm makewhatis.local -every week -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr catman 1 , -.Xr getNAME 1 , -.Xr man 1 , -.Xr manpath 1 , -.Xr sort 1 , -.Xr uniq 1 , -.Xr whatis 1 , -.Xr makewhatis.local 8 -.Sh HISTORY -This -.Nm -command appeared in -.Fx 2.1 . -.Sh AUTHORS -.An Wolfram Schneider , -Berlin. diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.local.8 b/gnu/usr.bin/man/makewhatis/makewhatis.local.8 deleted file mode 100644 index a050f66..0000000 --- a/gnu/usr.bin/man/makewhatis/makewhatis.local.8 +++ /dev/null @@ -1,82 +0,0 @@ -.\" Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.Dd April 26, 1996 -.Dt MAKEWHATIS.LOCAL 8 -.Os -.Sh NAME -.Nm makewhatis.local , catman.local -.Nd start makewhatis or catman for local file systems -.Sh SYNOPSIS -.Nm /usr/libexec/makewhatis.local -.Op options -.Ar directories ... -.Nm /usr/libexec/catman.local -.Op options -.Ar directories ... -.Sh DESCRIPTION -The -.Nm -utility starts -.Xr makewhatis 1 -only for file systems physically mounted on the system -where the -.Nm -is being executed. Running makewhatis -by -.Pa periodic weekly -for rw nfs-mounted /usr may kill -your NFS server -- all NFS clients start makewhatis at the same time! -So use this wrapper for -.Xr cron 8 -instead of calling makewhatis directly. -The -.Nm catman.local -utility is using for same purposes as -.Nm -but for -.Xr catman 1 . -.Sh FILES -.Bl -tag -width /etc/periodic/weekly/320.whatis.XXX -compact -.It Pa /etc/periodic/weekly/320.whatis -run -.Nm -every week -.It Pa /etc/periodic/weekly/330.catman -run -.Nm catman.local -every week -.El -.Sh SEE ALSO -.Xr catman 1 , -.Xr find 1 , -.Xr makewhatis 1 , -.Xr cron 8 , -.Xr periodic 8 -.Sh HISTORY -The -.Nm -utility appeared in -.Fx 2.2 . diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.local.sh b/gnu/usr.bin/man/makewhatis/makewhatis.local.sh deleted file mode 100644 index 8be2530..0000000 --- a/gnu/usr.bin/man/makewhatis/makewhatis.local.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# -# Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# makewhatis.local - start makewhatis(1) only for file systems -# physically mounted on the system -# -# Running makewhatis from /etc/periodic/weekly/320.whatis for rw nfs-mounted -# /usr may kill your NFS server -- all clients start makewhatis at the same -# time! So use this wrapper instead calling makewhatis directly. -# -# PS: this wrapper works also for catman(1) -# -# $FreeBSD$ - -PATH=/bin:/usr/bin:$PATH; export PATH -opt= dirs= localdirs= - -for arg -do - case "$arg" in - -*) opt="$opt $arg";; - *) dirs="$dirs $arg";; - esac -done - -dirs=`echo $dirs | sed 's/:/ /g'` -case X"$dirs" in X) echo "usage: $0 [options] directories ..."; exit 1;; esac - -localdirs=`find -H $dirs -fstype local -type d -prune -print` - -case X"$localdirs" in - X) echo "$0: no local-mounted manual directories found: $dirs" - exit 1;; - *) exec `basename $0 .local` $opt $localdirs;; -esac diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.perl b/gnu/usr.bin/man/makewhatis/makewhatis.perl deleted file mode 100644 index 33cee65..0000000 --- a/gnu/usr.bin/man/makewhatis/makewhatis.perl +++ /dev/null @@ -1,574 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) 1994-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# makewhatis -- update the whatis database in the man directories. -# -# $FreeBSD$ - - -sub usage { - - warn <<EOF; -usage: makewhatis [-a|-append] [-h|-help] [-i|-indent column] [-L|-locale] - [-n|-name name] [-o|-outfile file] [-v|-verbose] - [directories ...] -EOF - exit 1; -} - - -# Format output -sub open_output { - local($dir) = @_; - - die "Name for whatis is empty\n" if $whatis_name eq ""; - - if ($outfile) { # Write all Output to $outfile - $whatisdb = $outfile; - } else { # Use man/whatis - $whatisdb = $dir . "/$whatis_name.tmp"; - } - $tmp = $whatisdb; # for signals - - # Array of all entries - @a = (); - - # Append mode - if ($append) { - local($file) = $whatisdb; - $file =~ s/\.tmp$// if !$outfile; - - if (open(A, "$file")) { - warn "Open $file for append mode\n" if $verbose; - while(<A>) { - push(@a, $_); - } - close A; - } - - else { - warn "$whatisdb: $!\n" if lstat($file) && $verbose; # - } - undef $file; - } - - - warn "Open $whatisdb\n" if $verbose; - if (!open(A, "> $whatisdb")) { - die "$whatisdb: $!\n" if $outfile; - - warn "$whatisdb: $!\n"; $err++; return 0; - } - - select A; - return 1; -} - -sub close_output { - local($success) = @_; - local($w) = $whatisdb; - local($counter) = 0; - local($i, $last,@b); - - $w =~ s/\.tmp$//; - if ($success) { # success - # uniq - warn "\n" if $verbose && $pointflag; - warn "sort -u > $whatisdb\n" if $verbose; - foreach $i (sort @a) { - if ($i ne $last) { - push(@b, $i); - } - $last =$i; - } - - $counter = $#b + 1; - print @b; close A; select STDOUT; - - if (!$outfile) { - warn "Rename $whatisdb to $w\n" if $verbose; - rename($whatisdb, $w) || warn "rename $whatisdb $w\n"; - $counter_all += $counter; - warn "$counter entries in $w\n" if $verbose; - } else { - $counter_all = $counter; - } - } else { # building whatisdb failed - unlink($whatisdb); - warn "building whatisdb: $whatisdb failed\n" if $verbose; - } - return 1; -} - -sub parse_subdir { - local($dir) = @_; - local($file, $dev,$ino); - - warn "\n" if $pointflag; - warn "traverse $dir\n" if $verbose; - $pointflag = 0; - - if (!opendir(M, $dir)) { - warn "$dir: $!\n"; $err++; return 0; - } - - $| = 1 if $verbose; - foreach $file (readdir(M)) { - next if $file =~ /^(\.|\.\.)$/; - - ($dev, $ino) = ((stat("$dir/$file"))[01]); - if (-f _) { - if ($man_red{"$dev.$ino"}) { - # Link - print STDERR "+" if $verbose; - $pointflag++ if $verbose; - } else { - &manual("$dir/$file"); - } - $man_red{"$dev.$ino"} = 1; - } elsif (! -d _) { - warn "Cannot find file: $dir/$file\n"; $err++; - } - } - closedir M; - return 1; -} - -# read man directory -sub parse_dir { - local($dir) = @_; - local($subdir, $file); - - # clean up, in case mandir and subdirs are called simultaneously - # e. g.: ~/man/man1 ~/man/man2 ~/man - #~/man/ man1 and ~/man/man2 are a subset of ~/man - foreach $file (keys %man_red) { - delete $man_red{$file}; - } - - if ($dir =~ /man/) { - warn "\n" if $verbose && $pointflag; - warn "open manpath directory ``$dir''\n" if $verbose; - $pointflag = 0; - if (!opendir(DIR, $dir)) { - warn "opendir ``$dir'':$!\n"; $err = 1; return 0; - } - foreach $subdir (sort(readdir(DIR))) { - if ($subdir =~ /^man\w+$/) { - $subdir = "$dir/$subdir"; - &parse_subdir($subdir); - &parse_subdir($subdir) if -d ($subdir .= "/${machine}"); - } - } - closedir DIR - - } elsif ($dir =~ /man\w+$/) { - &parse_subdir($dir); - } else { - warn "Assume ``$dir'' is not a man directory.\n"; - $err = 1; return 0; - } - return 1; -} - -sub dir_redundant { - local($dir) = @_; - - local($dev,$ino) = (stat($dir))[0..1]; - - if ($dir_redundant{"$dev.$ino"}) { - warn "$dir is equal to: $dir_redundant{\"$dev.$ino\"}\n" if $verbose; - return 0; - } - $dir_redundant{"$dev.$ino"} = $dir; - return 1; -} - - -# ``/usr/man/man1/foo.l'' -> ``l'' -sub ext { - local($filename) = @_; - local($extension) = $filename; - - $extension =~ s/$ext$//g; # strip .gz - $extension =~ s/.*\///g; # basename - - if ($extension !~ m%[^/]+\.[^.]+$%) { # no dot - $extension = $filename; - #$extension =~ s|/[^/]+$||; - $extension =~ s%.*man([^/]+)/[^/]+%$1%; # last character - warn "\n" if $verbose && $pointflag; - warn "$filename has no extension, try section ``$extension''\n" - if $verbose; - $pointflag = 0; - } else { - $extension =~ s/.*\.//g; # foo.bla.1 -> 1 - } - return "$extension"; -} - -# ``/usr/man/man1/foo.1'' -> ``foo'' -sub name { - local($name) = @_; - - $name =~ s=.*/==; - $name =~ s=$ext$==o; - $name =~ s=\.[^\.]+$==; - - return "$name"; -} - -# output -sub out { - local($list) = @_; - local($delim) = " - "; - $_ = $list; - - # delete italic etc. - s/^\.[^ -]+[ -]+//; - s/\\\((em|mi)//; - s/\\f[IRBP]//g; - s/\\\*p//g; - s/\(OBSOLETED\)[ ]?//; - s/\\&//g; - s/^\@INDOT\@//; - s/[\"\\]//g; #" - s/[. \t-]+$//; - - s/ / - / unless / - /; - ($man,$desc) = split(/ - /); - - $man = $name unless $man; - $man =~ s/[,. ]+$//; - $man =~ s/,/($extension),/g; - $man .= "($extension)"; - - &manpagename; - - $desc =~ s/^[ \t]+//; - - for($i = length($man); $i < $indent && $desc; $i++) { - $man .= ' '; - } - if ($desc) { - push(@a, "$man$delim$desc\n"); - } else { - push(@a, "$man\n"); - } -} - -# The filename of manual page is not a keyword. -# This is bad, because you don't find the manpage -# whith: $ man <section> <keyword> -# -# Add filename if a) filename is not a keyword and b) no keyword(s) -# exist as file in same mansection -# -sub manpagename { - foreach (split(/,\s+/, $man)) { - s/\(.+//; - # filename is keyword - return if $name eq $_; - } - - local($f) = $file; $f =~ s%/*[^/]+$%%; # dirname - local($e) = $file; $e =~ s/$ext$//; $e =~ s%.*(\.[^.]+)$%$1%; # .1 - - foreach (split(/,\s+/, $man)) { - s/\(.+//; - - # a keyword exist as file - return if -e "$f/$_$e" || -e "$f/$_$e$ext"; - } - - $man = "$name($extension), $man"; -} - -# looking for NAME -sub manual { - local($file) = @_; - local($list, $desc, $extension); - local($ofile) = $file; - - # Compressed man pages - if ($ofile =~ /$ext$/) { - $ofile = "gzcat $file |"; - print STDERR "*" if $verbose; - } else { - print STDERR "." if $verbose; - } - $pointflag++ if $verbose; - - if (!open(F, "$ofile")) { - warn "Cannot open file: $ofile\n"; $err++; - return 0; - } - # extension/section - $extension = &ext($file); - $name = &name($file); - - $section_name = "NAME|Name|NAMN|BEZEICHNUNG|̾¾Î|îáú÷áîéå"; - - local($source) = 0; - local($list); - while(<F>) { - # ``man'' style pages - # &&: it takes you only half the user time, regexp is slow!!! - if (/^\.SH/ && /^\.SH[ \t]+["]?($section_name)["]?/) { - #while(<F>) { last unless /^\./ } # Skip - #chop; $list = $_; - while(<F>) { - last if /^\.SH[ \t]/; - chop; - s/^\.IX\s.*//; # delete perlpod garbage - s/^\.[A-Z]+[ ]+[0-9]+$//; # delete commands - s/^\.[A-Za-z]*[ \t]*//; # delete commands - s/^\.\\".*$//; #" delete comments - s/^[ \t]+//; - if ($_) { - $list .= $_; - $list .= ' '; - } - } - while(<F>) { } # skip remaining input to avoid pipe errors - &out($list); close F; return 1; - } elsif (/^\.Sh/ && /^\.Sh[ \t]+["]?($section_name)["]?/) { - # ``doc'' style pages - local($flag) = 0; - while(<F>) { - last if /^\.Sh/; - chop; - s/^\.\\".*$//; #" delete comments - next if /^\.[ \t]*$/; # skip empty calls - if (/^\.Nm/) { - s/^\.Nm[ \t]*//; - s/ ,/,/g; - s/[ \t]+$//; - $list .= $_; - $list .= ' '; - } else { - $list .= '- ' if (!$flag && !/^- /); - $flag++; - if (/^\.Xr/) { - split; - $list .= @_[1]; - $list .= "(@_[2])" if @_[2]; - } else { - s/^\.([A-Z][a-z])?[ \t]*//; - s/[ \t]+$//; - $list .= $_; - } - $list .= ' '; - } - } - while(<F>) { } # skip remaining input to avoid pipe errors - &out($list); close F; return 1; - - } elsif(/^\.so/ && /^\.so[ \t]+man/) { - while(<F>) { } # skip remaining input to avoid pipe errors - close F; return 1; - } - } - if (!$source && $verbose) { - warn "\n" if $pointflag; - warn "Maybe $file is not a manpage\n" ; - $pointflag = 0; - } - return 0; -} - -# make relative path to absolute path -sub absolute_path { - local(@dirlist) = @_; - local($pwd, $dir, @a); - - $pwd = $ENV{'PWD'}; - foreach $dir (@dirlist) { - if ($dir !~ "^/") { - chop($pwd = `pwd`) if (!$pwd || $pwd !~ /^\//); - push(@a, "$pwd/$dir"); - } else { - push(@a, $dir); - } - } - return @a; -} - -# strip unused '/' -# e.g.: //usr///home// -> /usr/home -sub stripdir { - local($dir) = @_; - - $dir =~ s|/+|/|g; # delete double '/' - $dir =~ s|/$||; # delete '/' at end - $dir =~ s|/(\.\/)+|/|g; # delete ././././ - - $dir =~ s|/+|/|g; # delete double '/' - $dir =~ s|/$||; # delete '/' at end - $dir =~ s|/\.$||; # delete /. at end - return $dir if $dir ne ""; - return '/'; -} - -sub variables { - $verbose = 0; # Verbose - $indent = 24; # Indent for description - $outfile = 0; # Don't write to ./whatis - $whatis_name = "whatis"; # Default name for DB - $append = 0; # Don't delete old entries - $locale = 0; # Build DB only for localized man directories - chomp($machine = $ENV{'MACHINE'} || `uname -m`); - - # choose localized man directories suffix. - $local_suffix = $ENV{'LC_ALL'} || $ENV{'LC_CTYPE'} || $ENV{'LANG'}; - - # if no argument for directories given - @defaultmanpath = ( '/usr/share/man' ); - - $ext = '.gz'; # extension - umask(022); - - $err = 0; # exit code - $whatisdb = ''; - $counter_all = 0; - $dir_redundant = ''; # redundant directories - $man_red = ''; # redundant man pages - @a = (); # Array for output - - # Signals - $SIG{'INT'} = 'Exit'; - $SIG{'HUP'} = 'Exit'; - $SIG{'TRAP'} = 'Exit'; - $SIG{'QUIT'} = 'Exit'; - $SIG{'TERM'} = 'Exit'; - $tmp = ''; # tmp file - - $ENV{'PATH'} = "/bin:/usr/bin:$ENV{'PATH'}"; -} - -sub Exit { - unlink($tmp) if $tmp ne ""; # unlink if a filename - die "$0: die on signal SIG@_\n"; -} - -sub parse { - local(@argv) = @_; - local($i); - - while ($_ = $argv[0], /^-/) { - shift @argv; - last if /^--$/; - if (/^--?(v|verbose)$/) { $verbose = 1 } - elsif (/^--?(h|help|\?)$/) { &usage } - elsif (/^--?(o|outfile)$/) { $outfile = $argv[0]; shift @argv } - elsif (/^--?(f|format|i|indent)$/) { $i = $argv[0]; shift @argv } - elsif (/^--?(n|name)$/) { $whatis_name = $argv[0];shift @argv } - elsif (/^--?(a|append)$/) { $append = 1 } - elsif (/^--?(L|locale)$/) { $locale = 1 } - else { &usage } - } - warn "Localized man directory suffix is ``$local_suffix''\n" - if $verbose && $locale; - - if ($i ne "") { - if ($i =~ /^[0-9]+$/) { - $indent = $i; - } else { - warn "Ignoring wrong indent value: ``$i''\n"; - } - } - - return &absolute_path(@argv) if $#argv >= 0; - return @defaultmanpath if $#defaultmanpath >= 0; - - warn "Missing directories\n"; &usage; -} - -# Process man directory -sub process_dir { - local($dir) = @_; - - $dir = &stripdir($dir); - &dir_redundant($dir) && &parse_dir($dir); -} - -# Process man directory and store output to file -sub process_dir_to_file { - local($dir) = @_; - - $dir = &stripdir($dir); - &dir_redundant($dir) && - &close_output(&open_output($dir) && &parse_dir($dir)); -} - -# convert locale name to short notation (ru_RU.KOI8-R -> ru.KOI8-R) -sub short_locale_name { - local($lname) = @_; - - $lname =~ s|_[A-Z][A-Z]||; - warn "short locale name is $lname\n" if $verbose && $locale; - return $lname; -} - -## -## Main -## - -&variables; -# allow colons in dir: ``makewhatis dir1:dir2:dir3'' -@argv = &parse(split(/[: ]/, join($", @ARGV))); # " - -if ($outfile) { - if(&open_output($outfile)){ - foreach $dir (@argv) { - # "Local only" flag set ? Yes ... - if ($locale) { - if ($local_suffix ne "") { - &process_dir($dir.'/'.$local_suffix); - &process_dir($dir.'/'.&short_locale_name($local_suffix)); - } - } else { - &process_dir($dir); - } - } - } - &close_output(1); -} else { - foreach $dir (@argv) { - # "Local only" flag set ? Yes ... - if ($locale) { - if ($local_suffix ne "") { - &process_dir_to_file($dir.'/'.$local_suffix); - &process_dir_to_file($dir.'/'.&short_locale_name($local_suffix)); - } - } else { - &process_dir_to_file($dir); - } - } -} - -warn "Total entries: $counter_all\n" if $verbose && ($#argv > 0 || $outfile); -exit $err; |