Subject: Re: makewhatis.sed
To: None <cjones@rupert.oscs.montana.edu, current-users@NetBSD.ORG>
From: Robert Dobbs <banshee@gabriella.resort.com>
List: current-users
Date: 08/03/1995 22:35:48
use /usr/libexec/makewhatis

however this doesn't get unformatted pages

so add (for .1 -- .8):

find $MANDIR -type f -name '*.1' -print | while read file
do
        sed -n -f /usr/share/man/makewhatis-man.sed $file;
done >> /tmp/whatis$$

with this sed file I wrote (i think it works)
note that in those brackets is a TAB and then a SPACE

##BEGIN##
#!/usr/bin/sed -nf
#

# Look for the manual page header .TH name number[ date]
/^.TH [a-zA-Z][a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*/ {
	s;^.TH [a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*;\1;
	# add a trailing space following the pattern space
	s;[a-zA-Z0-9\._+\-]*;& ;
	# save the manual number
	h
	d
}

# look for the program name
/^.SH NAME/!d

:name
	s;.*;;
	N
	s;\n;;
	# Convert "foo /- does bar" to "foo - does bar"
	s;\\-;-;
	# some twits underline the command name
	s;;;g
	/^[^a-zA-Z]/b print
	H
	b name

:print
	x
	s;\n;;g
	/-/!d
	s;;;g
	s;\([a-z][A-z]\)-[	 ][	 ]*;\1;
	s;\([a-zA-Z0-9,\._+\-]\)[	 ][	 ]*;\1 ;g
	s;[^a-zA-Z0-9\._+\-]*\([a-zA-Z0-9\._+\-]*\)[^a-zA-Z0-9\._+\-]*\(.*\) - \
(.*\);\2 (\1) - \3;
	p
	q
##END##

I submitted a pr on this once 

-j