#!/bin/sh
#
# Copyright (c) 1990,1991, OPEN SOFTWARE FOUNDATION, INC.
# ALL RIGHTS RESERVED
# 
# $Header: /project/docsrc/src/dte/RCS/fix-man.sh,v 1.4 91/04/09 17:51:30 bowe Exp $

FTMP=/tmp/FxNm$$
trap "rm -f $FTMP /tmp/fix$$; exit $?" 0 1 2 3 4 5 6 7 8 10 12 13 14 15 16 17 19

# _______________________________

#  I could not get all this to work without writing it to a temp file
#  and telling sed to read that file.  - J.Bowe

#sed -f $FIXNAME > /tmp/fix$$
cat > $FTMP << 'END_FIXNAME_SED'
/^\.SH NAME/ {
n
/^\.PP/ {
s/^\.PP$/...\\".PP/
n
}
/^\\f[BP]$/ n
s/\\f[BPR]//g
s/\.*$//
s/\(.*\) -- a/.tS "\1"\
.SH PURPOSE\
A/
s/\(.*\) - a/.tS "\1"\
.SH PURPOSE\
A/
s/\(.*\) \\- a/.tS "\1"\
.SH PURPOSE\
A/
s/\(.*\) \\(em a/.tS "\1"\
.SH PURPOSE\
A/
s/\(.*\) -- the/.tS "\1"\
.SH PURPOSE\
The/
s/\(.*\) - the/.tS "\1"\
.SH PURPOSE\
The/
s/\(.*\) \\- the/.tS "\1"\
.SH PURPOSE\
The/
s/\(.*\) \\(em the/.tS "\1"\
.SH PURPOSE\
The/
s/\(.*\) -- /.tS "\1"\
.SH PURPOSE\
/
s/\(.*\) - /.tS "\1"\
.SH PURPOSE\
/
s/\(.*\) \\- /.tS "\1"\
.SH PURPOSE\
/
s/\(.*\) \\(em /.tS "\1"\
.SH PURPOSE\
/
}
s/^Name	Class	Type	Default	Access/_\
Name	Default	Access\
\\ \\ \\ \\ \\ \\ Class	\\ \\ \\ \\ \\ \\ Type\
_/g
/Name	Default	Access/,/^\.TE/{
s/^\([^	]*\)	\([^	]*\)	\([^	]*\)	\([^	]*\)	\([^	]*\)/\1	\4	\5\
\\ \\ \\ \\ \\ \\ \2	\\ \\ \\ \\ \\ \\ \\ \3\
_/g
}
s/^lBp8 lBp8 lBp8 lBp8 lBp8$/lB lB lB\
lB lB lB/g
s/^lp8 lp8 lp8 lp8 lp8/l l l/g
s/^cBp9 ssss$/CB ss/g
s/^center allbox/center box/g
s/^\.tH/\.TE\
\.bp\
\.TS\
center box;\
lB lB lB\
lB lB lB\
l l l\.\
Name	Default	Access\
\\ \\ \\ \\ \\ \\ Class	\\ \\ \\ \\ \\ \\ Type\
_\
_/g
END_FIXNAME_SED
sed -f $FTMP > /tmp/fix$$

# _______________________________

ex - /tmp/fix$$ << E_N_D
g/^Name Default Access$/-7s/^center allbox;/center box;/
g/^\.TE/-2s/^_//
g/^\.TE/-1s/^_//
wq
E_N_D

# _______________________________

sed -e '
/^Name  Default Access$/,/\.TE/{
/^$/d
}' /tmp/fix$$

