Fix the ref string
[krb5.git] / doc / man2ps
1 #!/bin/sh
2
3 com=`basename $0`
4 files=$*
5 ROFF=groff
6 ROFF_FLAGS="-C -man -Tps"
7 CSPLIT=
8
9 IFS="${IFS=     }"; save_ifs="$IFS"; IFS="${IFS}:"
10 for i in $PATH; do
11   if [ -f $i/gcsplit ]; then
12         CSPLIT=$i/gcsplit
13         break
14   fi
15   if [ -f $i/csplit ]; then
16         CSPLIT=$i/csplit
17         break
18   fi
19 done
20 IFS="$save_ifs"
21
22 if [ "$files" = "" ]; then
23     echo "\aUsage: $com file [file2 ...]"
24     exit 1
25 fi
26
27 for file in $files
28 do
29     filename=`basename $file | awk -F. '{print $1}'`
30     eval $ROFF $ROFF_FLAGS $file > $filename.ps
31
32     pages=`grep '%%Pages\:' $filename.ps | awk '{print $2}'`
33     pp=`expr $pages - 1`
34
35     echo $filename': '$pages' pages'
36
37     if [ "$CSPLIT"x != x ]; then
38         $CSPLIT -k $filename.ps /Page:/ \{$pp\} > /dev/null
39
40         counter=0
41
42         for number in `ls xx*`
43         do
44             cat xx00 > $filename$counter.ps
45             echo '0.85 dup scale' >> $filename$counter.ps
46             cat $number >> $filename$counter.ps
47             if [ $counter != $pages ];
48                 then
49                 echo '%%Trailer' >> $filename$counter.ps
50                 echo 'end' >> $filename$counter.ps
51                 echo '%%EOF' >> $filename$counter.ps
52             fi
53             counter=`expr $counter + 1`
54         done
55
56         rm $filename.ps $filename'0.ps' xx*
57     else
58         echo "\aCan't find the csplit command.  You'll have to split $filename.ps manually."
59     fi
60 done