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