: Use /bin/sh
#
# $Id: splitdict,v 1.3 89/04/28 01:12:19 geoff Exp $
#
# $Log:	splitdict,v $
# Revision 1.3  89/04/28  01:12:19  geoff
# Change Header to Id;  nobody cares about my pathnames.
# 
# Revision 1.2  88/04/11  01:38:45  geoff
# Run the dictionary through 'sq' before splitting, so that it is as
# small as possible.
# 
# Revision 1.1  87/09/25  00:27:37  geoff
# Initial revision
# 
#
#	Split a dictionary into posting-sized parts.
#
#	Usage:
#
#	splitdict byte-size file basename
#
#	The split is only approximate, as it is done on a line basis.
#
TMP=${TMPDIR:-/usr/tmp}/sd$$

case "$#" in
    3)
	;;
    *)
	echo Usage: splitdict byte-size file basename 1>&2
	exit 1
	;;
esac

SIZE=$1
DICT=$2
BASE=$3

trap '/bin/rm -f ${TMP}; exit 1' 1 2 15

sq < $DICT > $TMP

set X `wc -lc < $TMP`
lines=`expr $2 / \( \( $3 + $SIZE - 1 \) / $SIZE \) + 1`

split -$lines $TMP $BASE
/bin/rm -f $TMP
