Subject: bin/1809: makewhatis
To: None <gnats-bugs@gnats.netbsd.org>
From: Robert Dobbs <banshee@gabriella.resort.com>
List: netbsd-bugs
Date: 12/05/1995 01:06:57
>Number:         1809
>Category:       bin
>Synopsis:       Man page for makewhatis and files to find unformatted files.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Dec  5 04:35:01 1995
>Last-Modified:
>Originator:     Robert Dobbs
>Organization:
>Release:        1.1
>Environment:
System: NetBSD gabriella.resort.com 1.1 NetBSD 1.1 (GABRIELLA-NCR) #1: Thu Nov 30 03:14:47 PST 1995 banshee@gabriella.resort.com:/usr/src/sys/arch/i386/compile/GABRIELLA-NCR i386


>Description:
	PR1062 and PR1168 complain that makewhatis fails to find 
unformatted man files, and that makewhatis lacks a man page.

>How-To-Repeat:
>Fix:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	makewhatis
#	makewhatis.8
#	makewhatis-man.sed
#
echo x - makewhatis
sed 's/^X//' >makewhatis << 'END-of-makewhatis'
X#! /bin/sh
X#
X# Written by J.T. Conklin <jtc@netbsd.org>.
X# Public domain.
X#
X
Xtrap "rm -f /tmp/whatis$$; exit 1" 1 2 15
X
XMANDIR=${1-/usr/share/man}
Xif test ! -d "$MANDIR"; then 
X	echo "makewhatis: $MANDIR: not a directory"
X	exit 1
Xfi
X
Xfind $MANDIR -type f -name '*.0' -print | while read file
Xdo
X	sed -n -f /usr/share/man/makewhatis.sed $file;
Xdone > /tmp/whatis$$
X
Xfind $MANDIR -type f -name '*.0.Z' -print | while read file
Xdo
X	zcat $file | sed -n -f /usr/share/man/makewhatis.sed;
Xdone >> /tmp/whatis$$
X
Xfind $MANDIR -type f -name '*.0.gz' -print | while read file
Xdo
X	gzip -dc $file | sed -n -f /usr/share/man/makewhatis.sed;
Xdone >> /tmp/whatis$$
X
Xfind $MANDIR -type f -name '*.[1-8]' -print | while read file
Xdo
X	sed -n -f /usr/share/man/makewhatis-man.sed $file;
Xdone >> /tmp/whatis$$
X
Xsort -u -o /tmp/whatis$$ /tmp/whatis$$
X
Xinstall -o bin -g bin -m 444 /tmp/whatis$$ "$MANDIR/whatis.db"
Xexit 0
END-of-makewhatis
echo x - makewhatis.8
sed 's/^X//' >makewhatis.8 << 'END-of-makewhatis.8'
X.Dd July 5, 1995
X.Dt MAKEWHATIS 8
X.Sh NAME
X.Nm makewhatis
X.Nd create a whatis.db database
X.Sh SYNOPSIS
X.Nm makewhatis
X.Op Ar manpath
X.Sh DESCRIPTION
X.Nm makewhatis
Xstrips the NAME lines from compiled or raw man(1) pages and creates
Xa whatis.db database.  If
X.Nm manpath
Xis unspecified,
X.Nm makewhatis
Xby default creates a database for /usr/share/man.
X.Sh BUGS
X.Nm makewhatis
Xshould find its search paths using /etc/man.conf
X.Sh SEE ALSO
X.Xr man 1
X.Xr man.conf 5
X.Sh AUTHOR
XJ.T. Conklin (jtc@netbsd.org)
END-of-makewhatis.8
echo x - makewhatis-man.sed
sed 's/^X//' >makewhatis-man.sed << 'END-of-makewhatis-man.sed'
X#!/usr/bin/sed -nf
X#
X# A whatis.db program to process unformatted man pages.
X# Modified from the bsd source by John M Vinopal,
X# banshee@resort.com May 1995
X#
X# Copyright (c) 1988 The Regents of the University of California.
X# All rights reserved.
X#
X# Redistribution and use in source and binary forms, with or without
X# modification, are permitted provided that the following conditions
X# are met:
X# 1. Redistributions of source code must retain the above copyright
X#    notice, this list of conditions and the following disclaimer.
X# 2. Redistributions in binary form must reproduce the above copyright
X#    notice, this list of conditions and the following disclaimer in the
X#    documentation and/or other materials provided with the distribution.
X# 3. All advertising materials mentioning features or use of this software
X#    must display the following acknowledgement:
X#       This product includes software developed by the University of
X#       California, Berkeley and its contributors.
X# 4. Neither the name of the University nor the names of its contributors
X#    may be used to endorse or promote products derived from this software
X#    without specific prior written permission.
X#
X# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X# SUCH DAMAGE.
X#
X#       @(#)makewhatis.sed      8.4 (Berkeley) 4/3/94
X#
X
X# Look for the manual page header .TH name number[ date]
X/^.[tT][hH] [a-zA-Z][a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*/ {
X	s;^.[tT][hH] [a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*;\1;
X	# add a trailing space following the pattern space
X	s;[a-zA-Z0-9\._+\-]*;& ;
X	# save the manual number
X	h
X	d
X}
X/^.[dD][tT] [a-zA-Z][a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*/ {
X	s;^.[dD][tT] [a-zA-Z0-9\._+\-]* \([a-zA-Z0-9\._+\-]*\).*;\1;
X	# add a trailing space following the pattern space
X	s;[a-zA-Z0-9\._+\-]*;& ;
X	# save the manual number
X	h
X	d
X}
X
X# look for the program name
X/^.[sS][hH] NAME/!d
X
X:name
X	s;.*;;
X	N
X	s;\n;;
X	# Convert "foo \- does bar" to "foo - does bar"
X	s;\\-;-;
X	# An alternate man page format.
X	/^.[nN][mM]/ {
X		s;.[nN][mM] ;;
X		s;$; - ;
X		N
X		s;\n;;
X		s;.[nN][dD] ;;
X	}
X	# some twits underline the command name
X	s;_;;g
X	/^[^a-zA-Z]/b print
X	H
X	b name
X
X:print
X	x
X	s;\n;;g
X	/-/!d
X	s;.;;g
X	s;\([a-z][A-z]\)-[	 ][	 ]*;\1;
X	s;\([a-zA-Z0-9,\._+\-]\)[	 ][	 ]*;\1 ;g
X	s;[^a-zA-Z0-9\._+\-]*\([a-zA-Z0-9\._+\-]*\)[^a-zA-Z0-9\._+\-]*\(.*\) - \(.*\);\2 (\1) - \3;
X	p
X	q
END-of-makewhatis-man.sed
exit

>Audit-Trail:
>Unformatted: