1 | : Use /bin/sh |
---|
2 | # |
---|
3 | # $Id: splitdict,v 1.1.1.1 1997-09-03 21:08:09 ghudson Exp $ |
---|
4 | # |
---|
5 | # Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA |
---|
6 | # All rights reserved. |
---|
7 | # |
---|
8 | # Redistribution and use in source and binary forms, with or without |
---|
9 | # modification, are permitted provided that the following conditions |
---|
10 | # are met: |
---|
11 | # |
---|
12 | # 1. Redistributions of source code must retain the above copyright |
---|
13 | # notice, this list of conditions and the following disclaimer. |
---|
14 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
15 | # notice, this list of conditions and the following disclaimer in the |
---|
16 | # documentation and/or other materials provided with the distribution. |
---|
17 | # 3. All modifications to the source code must be clearly marked as |
---|
18 | # such. Binary redistributions based on modified source code |
---|
19 | # must be clearly marked as modified versions in the documentation |
---|
20 | # and/or other materials provided with the distribution. |
---|
21 | # 4. All advertising materials mentioning features or use of this software |
---|
22 | # must display the following acknowledgment: |
---|
23 | # This product includes software developed by Geoff Kuenning and |
---|
24 | # other unpaid contributors. |
---|
25 | # 5. The name of Geoff Kuenning may not be used to endorse or promote |
---|
26 | # products derived from this software without specific prior |
---|
27 | # written permission. |
---|
28 | # |
---|
29 | # THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND |
---|
30 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
31 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
32 | # ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE |
---|
33 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
34 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
35 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
36 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
37 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
38 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
39 | # SUCH DAMAGE. |
---|
40 | # |
---|
41 | # Split a dictionary into posting-sized parts. |
---|
42 | # |
---|
43 | # Usage: |
---|
44 | # |
---|
45 | # splitdict byte-size file basename |
---|
46 | # |
---|
47 | # The split is only approximate, as it is done on a line basis. |
---|
48 | # |
---|
49 | # $Log: not supported by cvs2svn $ |
---|
50 | # Revision 1.5 1994/01/25 07:12:06 geoff |
---|
51 | # Get rid of all old RCS log lines in preparation for the 3.1 release. |
---|
52 | # |
---|
53 | # |
---|
54 | TMP=${TMPDIR:-/usr/tmp}/sd$$ |
---|
55 | |
---|
56 | case "$#" in |
---|
57 | 3) |
---|
58 | ;; |
---|
59 | *) |
---|
60 | echo Usage: splitdict byte-size file basename 1>&2 |
---|
61 | exit 1 |
---|
62 | ;; |
---|
63 | esac |
---|
64 | |
---|
65 | SIZE=$1 |
---|
66 | DICT=$2 |
---|
67 | BASE=$3 |
---|
68 | |
---|
69 | trap '/bin/rm -f ${TMP}; exit 1' 1 2 15 |
---|
70 | |
---|
71 | sq < $DICT > $TMP |
---|
72 | |
---|
73 | set X `wc -lc < $TMP` |
---|
74 | lines=`expr $2 / \( \( $3 + $SIZE - 1 \) / $SIZE \) + 1` |
---|
75 | |
---|
76 | split -$lines $TMP $BASE |
---|
77 | /bin/rm -f $TMP |
---|