1993-07-07 23:07:02 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# makewhatis -- update the whatis database in the man directories.
|
|
|
|
#
|
|
|
|
# Copyright (c) 1990, 1991, John W. Eaton.
|
|
|
|
#
|
|
|
|
# You may distribute under the terms of the GNU General Public
|
|
|
|
# License as specified in the README file that comes with the man
|
|
|
|
# distribution.
|
|
|
|
#
|
|
|
|
# John W. Eaton
|
|
|
|
# jwe@che.utexas.edu
|
|
|
|
# Department of Chemical Engineering
|
|
|
|
# The University of Texas at Austin
|
|
|
|
# Austin, Texas 78712
|
|
|
|
|
|
|
|
PATH=/bin:/usr/local/bin:/usr/ucb:/usr/bin
|
|
|
|
|
|
|
|
if [ $# = 0 ]
|
|
|
|
then
|
|
|
|
echo "usage: makewhatis directory [...]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
for dir in $*
|
|
|
|
do
|
|
|
|
cd $dir
|
|
|
|
for subdir in man*
|
|
|
|
do
|
|
|
|
if [ -d $subdir ]
|
|
|
|
then
|
1993-07-24 03:41:41 +00:00
|
|
|
for f in `find $subdir -type f -print`
|
1993-07-07 23:07:02 +00:00
|
|
|
do
|
1994-03-05 13:48:38 +00:00
|
|
|
suffix=`echo $f | sed -e 's/.*\\.//'`
|
|
|
|
if [ ".$suffix" = "%compext%" ]; then
|
|
|
|
output=%zcat%
|
|
|
|
else
|
|
|
|
output=cat
|
|
|
|
fi
|
|
|
|
$output $f | \
|
1993-07-07 23:07:02 +00:00
|
|
|
sed -n '/^\.TH.*$/p
|
1993-07-21 21:08:32 +00:00
|
|
|
/^\.Dt.*$/p
|
1994-03-05 13:48:38 +00:00
|
|
|
/^\.S[hH][ ]*NAME/,/^\.S[hH]/p'|\
|
1993-07-07 23:07:02 +00:00
|
|
|
sed -e 's/\\[ ]*\-/-/
|
1993-07-21 21:08:32 +00:00
|
|
|
s/^.P[Pp].*$//
|
1993-07-07 23:07:02 +00:00
|
|
|
s/\\(em//
|
|
|
|
s/\\fI//
|
|
|
|
s/\\fR//' |\
|
1993-07-21 21:08:32 +00:00
|
|
|
awk 'BEGIN {insh = 0; inSh = 0; Nd = 0} {
|
|
|
|
if ($1 == ".TH" || $1 == ".Dt")
|
1993-07-07 23:07:02 +00:00
|
|
|
sect = $3
|
1993-07-24 03:41:41 +00:00
|
|
|
else if (($1 == ".br" && insh == 1)\
|
|
|
|
|| ($1 == ".SH" && insh == 1)\
|
|
|
|
|| ($1 == ".Sh" && inSh == 1)) {
|
1993-07-21 21:08:32 +00:00
|
|
|
if (i > 0 && nc > 0) {
|
|
|
|
for (k= 1; k <= nc; k++) {
|
|
|
|
namesect = sprintf("%s (%s)", name[k], sect)
|
|
|
|
printf("%s", namesect)
|
|
|
|
printf(" - ")
|
|
|
|
for (j = 0; j < i-1; j++)
|
|
|
|
printf("%s ", desc[j])
|
|
|
|
printf("%s\n", desc[i-1])
|
|
|
|
}
|
1993-07-07 23:07:02 +00:00
|
|
|
}
|
1993-07-21 21:08:32 +00:00
|
|
|
count = 0
|
|
|
|
i = 0
|
|
|
|
nc = 0
|
1993-07-07 23:07:02 +00:00
|
|
|
} else if ($1 == ".SH" && insh == 0) {
|
|
|
|
insh = 1
|
|
|
|
count = 0
|
|
|
|
i = 0
|
1993-07-21 21:08:32 +00:00
|
|
|
nc = 0
|
|
|
|
} else if ($1 == ".Sh" && inSh == 0) {
|
|
|
|
inSh = 1
|
|
|
|
i = 0
|
|
|
|
nc = 0
|
1993-07-07 23:07:02 +00:00
|
|
|
} else if (insh == 1) {
|
|
|
|
count++
|
|
|
|
if (count == 1 && NF > 2) {
|
1993-07-21 21:08:32 +00:00
|
|
|
start = 2
|
|
|
|
for (k = 1; k <= NF; k++)
|
|
|
|
if ($k == "-") {
|
|
|
|
start = k + 1
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
sub(",","",$k)
|
|
|
|
if ($k != "")
|
|
|
|
name[++nc] = $k
|
|
|
|
}
|
|
|
|
if (NF >= start)
|
1993-07-07 23:07:02 +00:00
|
|
|
for (j = start; j <= NF; j++)
|
|
|
|
desc[i++] = $j
|
|
|
|
} else {
|
|
|
|
for (j = 1; j <= NF; j++)
|
|
|
|
desc[i++] = $j
|
|
|
|
}
|
1993-07-21 21:08:32 +00:00
|
|
|
} else if ($1 == ".Nm" && inSh == 1 && Nd == 0) {
|
|
|
|
for (k = 2; k <= NF; k++) {
|
|
|
|
sub(",","",$k)
|
|
|
|
if ($k != "")
|
|
|
|
name[++nc] = $k
|
|
|
|
}
|
|
|
|
} else if ($1 == ".Nd" && inSh == 1) {
|
|
|
|
Nd = 1
|
|
|
|
for (j = 2; j <= NF; j++)
|
|
|
|
desc[i++] = $j
|
|
|
|
} else if (Nd == 1) {
|
|
|
|
start = 1
|
|
|
|
if ($1 ~ /\..*/)
|
|
|
|
start = 2
|
|
|
|
for (j = start; j <= NF; j++)
|
|
|
|
desc[i++] = $j
|
|
|
|
}
|
1993-07-07 23:07:02 +00:00
|
|
|
}'
|
|
|
|
done
|
|
|
|
fi
|
1993-07-21 21:08:32 +00:00
|
|
|
done | sort | colrm 80 | uniq > $dir/whatis.db.tmp
|
1993-07-07 23:07:02 +00:00
|
|
|
mv $dir/whatis.db.tmp $dir/whatis
|
|
|
|
done
|
|
|
|
|
|
|
|
exit
|