version distributed with 4.2BSD
[unix-history] / usr / src / share / man / man0 / tocrc
CommitLineData
0e4b7f4e
KM
1#!/bin/sh -
2#
3# Copyright (c) 1980 Regents of the University of California.
4# All rights reserved. The Berkeley software License Agreement
5# specifies the terms and conditions for redistribution.
6#
2a72b9ee 7# @(#)tocrc 5.1 (Berkeley) %G%
0e4b7f4e
KM
8#
9tmp=/tmp/toc$$
2a72b9ee 10troff=itroff
0e4b7f4e 11trap "rm $tmp ; exit" 2 3 15
2a72b9ee
KM
12if [ $# -eq 2 -a $1 = "3" ]
13then
14 : create toc input files for section 3 only
15
16 ( cd man3 ; for x in 3 3f 3m 3n 3s 3x 3c
17 do
18 /usr/lib/getNAME -t *.$x |
19 sed \
20 -e 's/.s-2//g' \
21 -e 's/.s-1//g' \
22 -e 's/.s0//g' \
23 -e 's/.s+1//g' \
24 -e 's/ *.- */: /' \
25 -e 's/ *$/./' \
26 -e 's/.TH.* //' \
27 > ../man0/tocx$x
28 done
29 )
30elif [ $# -eq 2 ]
0e4b7f4e
KM
31then
32 : create toc input file for one section only
33
34 ( cd man$1 ; /usr/lib/getNAME -t *.* |
35 sed \
2a72b9ee 36 -e 's/.s-2//g' \
0e4b7f4e
KM
37 -e 's/.s-1//g' \
38 -e 's/.s0//g' \
39 -e 's/.s+1//g' \
40 -e 's/ *.- */: /' \
2a72b9ee 41 -e 's/ *$/./' \
0e4b7f4e
KM
42 -e 's/.TH.* //' \
43 > ../man0/tocx$1
44 )
45else case $1 in
46 all )
47 : tocx files for all sections and everything else
48
49 for x in 1 2 3 4 5 6 7 8
50 do
51 ./$0 $x $x
52 done
53 ./$0 t
54 ;;
55 t )
56 : permuted index and toc files
57
58 if [ ! -f man0/tocx1 ]
59 then
2a72b9ee 60 echo "tocx* files missing; must run tocrc all first"
0e4b7f4e
KM
61 exit
62 fi
63 sed \
64 -e 's/(1c)/(1C)/' \
0e4b7f4e
KM
65 -e 's/(1g)/(1G)/' \
66 -e 's/(3c)/(3C)/' \
67 -e 's/(3m)/(3M)/' \
68 -e 's/(3s)/(3S)/' \
2a72b9ee
KM
69 -e 's/(3x)/(3X)/' \
70 -e 's/(3f)/(3F)/' \
71 -e 's/(4f)/(4F)/' \
72 -e 's/(4n)/(4N)/' \
73 -e 's/(4p)/(4P)/' \
74 -e 's/(8c)/(8C)/' \
75 -e 's/(8v)/(8V)/' \
0e4b7f4e 76 -e '/"\."/d' \
2a72b9ee 77 man0/tocx* man0/cshcmd \
0e4b7f4e
KM
78 > /tmp/cattoc
79
80 ptx -r -t -b break -f -w 108 -i man0/ignore \
81 /tmp/cattoc man0/ptxx
82
2a72b9ee 83 for x in 1 2 3 3f 3m 3n 3s 3x 3c 4 5 6 7 8
0e4b7f4e
KM
84 do
85 < man0/tocx$x grep '^intro' >$tmp
86 sed \
87 -e '2,${' \
88 -e '/^intro/d' \
89 -e '}' \
90 -e 's/ .*://' \
91 -e 's/.$//' \
92 -e 's/([^)]*) /" "/' \
93 -e 's/.*/.xx "&"/' \
94 -e '/""/d' \
95 $tmp man0/tocx$x \
96 >man0/toc$x
97 done
98 ;;
99 tr )
100 cd man0; $troff ptx.in ; cd ..
101 cd man0 ; $troff toc.in ; cd ..
102 ;;
103 * )
104 ./$0 $1 $1
105 ;;
106 esac
107fi
108exit