xref: /csrg-svn/share/man/man0/tocrc (revision 27960)
1*27960Smckusick#!/bin/sh -
2*27960Smckusick#
3*27960Smckusick# Copyright (c) 1980 Regents of the University of California.
4*27960Smckusick# All rights reserved.  The Berkeley software License Agreement
5*27960Smckusick# specifies the terms and conditions for redistribution.
6*27960Smckusick#
7*27960Smckusick#	@(#)tocrc	4.1 (Berkeley) 05/11/86
8*27960Smckusick#
9*27960Smckusicktmp=/tmp/toc$$
10*27960Smckusicktroff=vtroff
11*27960Smckusicktrap "rm $tmp ; exit" 2 3 15
12*27960Smckusickif [ $# -eq 2 ]
13*27960Smckusickthen
14*27960Smckusick	: create toc input file for one section only
15*27960Smckusick
16*27960Smckusick	( cd man$1 ; /usr/lib/getNAME -t *.* |
17*27960Smckusick		sed \
18*27960Smckusick			-e 's/.s-1//g' \
19*27960Smckusick			-e 's/.s0//g' \
20*27960Smckusick			-e 's/.s+1//g' \
21*27960Smckusick			-e 's/  *.-  */: /' \
22*27960Smckusick			-e 's/$/./' \
23*27960Smckusick			-e 's/.TH.*	//' \
24*27960Smckusick		> ../man0/tocx$1
25*27960Smckusick	)
26*27960Smckusickelse case $1 in
27*27960Smckusick	all )
28*27960Smckusick		:   tocx files for all sections and everything else
29*27960Smckusick
30*27960Smckusick		for x in 1 2 3 4 5 6 7 8
31*27960Smckusick			do
32*27960Smckusick			./$0 $x $x
33*27960Smckusick			done
34*27960Smckusick		./$0 t
35*27960Smckusick		;;
36*27960Smckusick	t )
37*27960Smckusick		:   permuted index and toc files
38*27960Smckusick
39*27960Smckusick		if [ ! -f man0/tocx1 ]
40*27960Smckusick		then
41*27960Smckusick			echo "tocx? files missing; must run tocrc all first"
42*27960Smckusick			exit
43*27960Smckusick		fi
44*27960Smckusick		sed \
45*27960Smckusick			-e 's/(1c)/(1C)/' \
46*27960Smckusick			-e 's/(1m)/(1M)/' \
47*27960Smckusick			-e 's/(1g)/(1G)/' \
48*27960Smckusick			-e 's/(3c)/(3C)/' \
49*27960Smckusick			-e 's/(3m)/(3M)/' \
50*27960Smckusick			-e 's/(3s)/(3S)/' \
51*27960Smckusick			-e '/"\."/d' \
52*27960Smckusick			man0/tocx? man0/cshcmd \
53*27960Smckusick		> /tmp/cattoc
54*27960Smckusick
55*27960Smckusick		ptx -r -t -b break -f -w 108 -i man0/ignore \
56*27960Smckusick		    /tmp/cattoc man0/ptxx
57*27960Smckusick
58*27960Smckusick		for x in 1 2 3 4 5 6 7 8
59*27960Smckusick		do
60*27960Smckusick			< man0/tocx$x grep '^intro' >$tmp
61*27960Smckusick				sed \
62*27960Smckusick				-e '2,${' \
63*27960Smckusick				-e '/^intro/d' \
64*27960Smckusick				-e '}' \
65*27960Smckusick				-e 's/ .*://' \
66*27960Smckusick				-e 's/.$//' \
67*27960Smckusick				-e 's/([^)]*) /" "/' \
68*27960Smckusick				-e 's/.*/.xx "&"/' \
69*27960Smckusick				-e '/""/d' \
70*27960Smckusick				$tmp man0/tocx$x \
71*27960Smckusick			>man0/toc$x
72*27960Smckusick		done
73*27960Smckusick		;;
74*27960Smckusick	tr )
75*27960Smckusick		cd man0; $troff ptx.in ; cd ..
76*27960Smckusick		cd man0 ; $troff toc.in  ; cd ..
77*27960Smckusick		;;
78*27960Smckusick	* )
79*27960Smckusick		./$0 $1 $1
80*27960Smckusick		;;
81*27960Smckusick	esac
82*27960Smckusickfi
83*27960Smckusickexit
84