PG=kspell
H='
==========
kspell [-options] file(s)
==========
is a driver for **IX spell. It provides for a user-supplied spelling
list. kspell is called by krect. it may be used as a stand alone
program. it is preferable to **IX spell because of better handling of
words with Bibliofile vowel marks, provision for local exclusion lists,
etc.
==========
the user-supplied list is named "words" and may be located in the
current directory or the $DICT directory. if $DICT is undefined, $HOME
is used.
==========
OPTIONS
==========
-?	lower case turns on, upper case turns off
-h	this explanation
-r	reduce output from kbreak [on]
	turn off if the input files are already sorted
-x	execution trace [off]
==========
BUGS
==========
Path names and parameters are system specific.  Look at the
source and change as needed.
==========
'
MEMO='
using set -e with some versions of the Bourne shell causes
if test -r file
then
fi
patterns to exit as errors if file does not exist.
'
:
RO=-r1
:
for i in $*
do
case $i in
	-R)				RO=-r0;;
	-r)				RO=-r1;;
	-v)				set -v;;
	-x)				set -x;;
    -h|help|hint)   clear;echo "$H";exit 0;;
	?*)				F="$F $i";;
esac
done
#	if the construct *) is used in the above switch, F always is "set"
#	and the following test will fail.  it should used the kbreak.xrc
#	list if no files have been given in the call to kspell
:
:	${F=`cat kbreak.xrc`}
:
case $OS in
	MKS)	SUF=exe;;
	DOS)	SUF=exe;;
	UNIX)	SUF=x;;
	XENIX)	SUF=x;;
	*)		echo "($0) <OS var not set, assuming UNIX>" 1>&2;SUF=x;;
esac
WL=$PUBKIN/wordlist.$SUF
KB=$PUBKIN/kbreak.$SUF
:
#	check for read permission on files
for f in $F
do
if test -r $f
then continue
else
echo "($PG) <cannot read> $f" 1>&2
exit 69
fi
done
:
#	check for Bibliofile programs
for i in $WL $KB
do
if test -s $i
then
continue
echo "($PG) <cannot find> $i" 1>&2
exit 69
fi
done
#	look for a user dictionary
:	${DICT=$HOME}
for i in ./words $DICT/words
do
if test -r $i
then
UD=$i
echo "($PG) <user dictionary> $UD" 1>&2
break
fi
done
:
:	${TMPDIR=/usr/tmp}
:
B=$TMPDIR/ks$$.bbb
K=$TMPDIR/ks$$.kkk
L=$TMPDIR/ks$$.lll
M=$TMPDIR/ks$$.mmm
:
rm -f $TMPDIR/kb*.tmp
:
trap 'rm -f $TMPDIR/kb*.tmp $B $K $L $M;exit' 0 1 2 3 4 14
#	break into words
eval "$KB $RO $F | sort -u > $B"
#	test against user dictionaries
case $UD in
	?*)	eval "$WL -d $UD -e $B > $K";;
	*)	mv $B $K;;
esac
#	separate vowel marked items
S="
/[aeiou]^/w $L
/[aeiou]^/!w $M
"
sed -n -e "$S" $K
#	pass purged list to spell, then merge if there is a separate
#	vowel list
spell $M | sort -dfb - $L
