xref: /netbsd/share/man/tools/pgcnt (revision 6550d01e)
1set x $*
2. ./.param
3
4PATH=$PATH:$MANDIR/tools
5
6sm=
7if test "$PFLAG" -eq 1
8then
9	sm="-rs1"
10fi
11
12for dir in $DIRLST
13do
14	cd $MANDIR/man$dir
15	date > $TMPDIR/pages$dir
16	echo >> $TMPDIR/pages$dir
17	for file in $FILLST
18	do
19		prep="cat $file |"
20
21		first=`line < $file`
22		case "$first" in
23			.so*)	continue
24				;;
25			\'\\\"*)
26				option=`expr "$first" : '.* \(.*\)'`
27				case "$option" in
28					c)
29						prep="${prep} cw |"
30						;;
31					e)
32						prep="${prep} eqn |"
33						;;
34					t)
35						prep="${prep} tbl |"
36						;;
37					ce | ec)
38						prep="${prep} cw | eqn"
39						;;
40					ct | tc)
41						prep="${prep} cw | tbl |"
42						;;
43					et | te)
44						prep="${prep} tbl | eqn |"
45						;;
46					cet | cte | ect | etc | tce | tec)
47						prep="${prep} cw | tbl | eqn |"
48						;;
49				esac
50				;;
51			*)
52				;;
53		esac
54
55		numb=`eval ${prep} troff -man $sm -s -f -t | pages`
56		echo "$file	$numb" >> $TMPDIR/pages$dir
57	done
58done
59
60tsum=0
61cd $TMPDIR
62date > totalpgs
63echo >> totalpgs
64
65for dir in $DIRLST
66do
67	ed - pages$dir <<!
68		1,2d
69		w tmp1.$$
70		q
71!
72	sum=0
73	while read val
74	do
75		val=`echo $val | sed "s/.* / /"`
76		sum=`expr $sum + $val`
77		if test $? -eq 2
78		then
79			echo "pgcnt: error in summing - sum is $sum, val is $val"
80			exit
81		fi
82		echo $sum > tmp.$$
83	done < tmp1.$$
84	sumt=`line < tmp.$$`
85	echo "total pages Section $dir -- $sumt" >> totalpgs
86	tsum=`expr $tsum + $sumt`
87done
88
89echo >> totalpgs
90echo >> totalpgs
91echo "total pages -- $tsum" >> totalpgs
92rm tmp.$$ tmp1.$$
93