tocrc revision 1.4
11.1Smrg#!/bin/sh -
21.1Smrg#
31.4Ssnj#	$NetBSD: tocrc,v 1.4 2004/03/31 02:10:00 snj Exp $
41.2Sperry#
51.1Smrg# Copyright (c) 1993
61.1Smrg#	The Regents of the University of California.  All rights reserved.
71.1Smrg#
81.1Smrg# Redistribution and use in source and binary forms, with or without
91.1Smrg# modification, are permitted provided that the following conditions
101.1Smrg# are met:
111.1Smrg# 1. Redistributions of source code must retain the above copyright
121.1Smrg#    notice, this list of conditions and the following disclaimer.
131.1Smrg# 2. Redistributions in binary form must reproduce the above copyright
141.1Smrg#    notice, this list of conditions and the following disclaimer in the
151.1Smrg#    documentation and/or other materials provided with the distribution.
161.1Smrg# 3. All advertising materials mentioning features or use of this software
171.1Smrg#    must display the following acknowledgement:
181.1Smrg#	This product includes software developed by the University of
191.1Smrg#	California, Berkeley and its contributors.
201.1Smrg# 4. Neither the name of the University nor the names of its contributors
211.1Smrg#    may be used to endorse or promote products derived from this software
221.1Smrg#    without specific prior written permission.
231.1Smrg#
241.1Smrg# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251.1Smrg# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261.1Smrg# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271.1Smrg# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281.1Smrg# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291.1Smrg# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301.1Smrg# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311.1Smrg# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321.1Smrg# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331.1Smrg# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341.1Smrg# SUCH DAMAGE.
351.1Smrg#
361.1Smrg#       @(#)tocrc	8.2 (Berkeley) 5/5/94
371.1Smrg#
381.1Smrgtmp=/tmp/toc$$
391.1Smrgtrap "rm $tmp ; exit" 2 3 15
401.1Smrg:   tocx files for all sections and everything else
411.1Smrg
421.1Smrgif [ ! -f tocx8 ]; then
431.1Smrg	for x in 1 2 3 4 5 6 7 8; do
441.1Smrg		/usr/libexec/getNAME -t `cat man$x` |
451.1Smrg			sed \
461.1Smrg				-e 's/.s-2//g' \
471.1Smrg				-e 's/.s-1//g' \
481.1Smrg				-e 's/.s0//g' \
491.1Smrg				-e 's/.s+1//g' \
501.1Smrg				-e 's/  *.-  */: /' \
511.1Smrg				-e 's/ *$/./' \
521.1Smrg				-e 's/.TH.*	//' \
531.1Smrg				-e 's/@g@//' \
541.1Smrg				-e 's/@G@//' \
551.1Smrg			> tocx$x
561.1Smrg	done
571.1Smrgfi
581.1Smrg:   permuted index and toc files
591.1Smrg
601.1Smrgcat tocx* cshcmd > /tmp/cattoc
611.1Smrg
621.4Ssnj# If this fails, try gptx from GNU coreutils (pkgsrc/sysutils/coreutils)
631.1Smrgptx -r -t -b break -f -w 108 -i ignore /tmp/cattoc ptxx
641.1Smrg
651.1Smrgfor x in 1 2 3 4 5 6 7 8; do
661.1Smrg	grep '^intro' <tocx$x >$tmp
671.1Smrg	sed \
681.1Smrg		-e '2,${' \
691.1Smrg		-e '/^intro/d' \
701.1Smrg		-e '}' \
711.1Smrg		-e 's/ .*://' \
721.1Smrg		-e 's/.$//' \
731.1Smrg		-e 's/([^)]*) /" "/' \
741.1Smrg		-e 's/.*/.xx "&"/' \
751.1Smrg		-e '/""/d' \
761.1Smrg		$tmp tocx$x \
771.1Smrg	>toc$x
781.1Smrgdone
791.1Smrgexit
80