summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorAndrew Moore <alm@FreeBSD.org>1993-07-21 21:08:32 +0000
committerAndrew Moore <alm@FreeBSD.org>1993-07-21 21:08:32 +0000
commit4a5e9a201722c2e388d2bb9e328fa1c3cdb834d3 (patch)
tree47f0b5548ab4853394115977286c73efb691084a /gnu
parent2aaed01e053d4847cbbe5b519bba8caee208fc09 (diff)
Notes
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.sh74
1 files changed, 53 insertions, 21 deletions
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.sh b/gnu/usr.bin/man/makewhatis/makewhatis.sh
index e6c238c2ba85..7501be7fc043 100644
--- a/gnu/usr.bin/man/makewhatis/makewhatis.sh
+++ b/gnu/usr.bin/man/makewhatis/makewhatis.sh
@@ -21,7 +21,6 @@ then
echo "usage: makewhatis directory [...]"
exit 1
fi
-
for dir in $*
do
cd $dir
@@ -29,50 +28,83 @@ do
do
if [ -d $subdir ]
then
- for f in `find . -name '*' -print`
+ for f in `find $subdir -name '*' -print`
do
sed -n '/^\.TH.*$/p
- /^\.SH[ ]*NAME/,/^\.SH/p' $f |\
+ /^\.Dt.*$/p
+ /^\.S[hH][ ]*NAME/,/^\.S[hH]/p' $f |\
sed -e 's/\\[ ]*\-/-/
- s/^.PP.*$//
+ s/^.P[Pp].*$//
s/\\(em//
s/\\fI//
s/\\fR//' |\
- awk 'BEGIN {insh = 0} {
- if ($1 == ".TH")
+ awk 'BEGIN {insh = 0; inSh = 0; Nd = 0} {
+ if ($1 == ".TH" || $1 == ".Dt")
sect = $3
- else if ($1 == ".SH" && insh == 1) {
- if (i > 0 && name != NULL) {
- namesect = sprintf("%s (%s)", name, sect)
- printf("%-20.20s", namesect)
- printf(" - ")
- for (j = 0; j < i-1; j++)
- printf("%s ", desc[j])
- printf("%s\n", desc[i-1])
+ else if (($1 == ".br" && insh == 1) || ($1 == ".SH" && insh == 1) || ($1 == ".Sh" && inSh == 1)) {
+ 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])
+ }
}
+ count = 0
+ i = 0
+ nc = 0
} else if ($1 == ".SH" && insh == 0) {
insh = 1
count = 0
i = 0
+ nc = 0
+ } else if ($1 == ".Sh" && inSh == 0) {
+ inSh = 1
+ i = 0
+ nc = 0
} else if (insh == 1) {
count++
if (count == 1 && NF > 2) {
- start = 2
- if ($2 == "-") start = 3
- if (NF > start + 1)
+ 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)
for (j = start; j <= NF; j++)
desc[i++] = $j
- name = $1
} else {
for (j = 1; j <= NF; j++)
desc[i++] = $j
}
- }
+ } 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
+ }
}'
done
- cd ..
fi
- done | sort | colrm 80 > $dir/whatis.db.tmp
+ done | sort | colrm 80 | uniq > $dir/whatis.db.tmp
mv $dir/whatis.db.tmp $dir/whatis
done