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