# spellin - a utility to build hashed word lists for `spell'.
# Copyright 1999 Nathan Scott Thompson ( quimby at city-net dot com )
# You may use this according to the GNU Public License: see http://www.gnu.org

use Spelling;
use strict;

die "usage: $0 {hashfile |size} [ file ] ...\n"
 unless @ARGV;
my ($dict,$warned);
if ( $ARGV[0] =~ /[^\d]/ )
{
    my $filename = shift;
    open IN, $filename or die "Can't open $filename: $!\n";
    $dict = Hlist->new( FileHandle => \*IN )
        or die "Bad hashed word list: $filename\n";
    close IN;
}
else
{
    $dict = Hlist->new( Capacity => shift );
}

while ( <> )
{
    /\S+/ or next;
    $dict->insert( $& )
        or die "Capacity exceeded: $dict->{Capacity} maximum.\n",
               "Rebuild the hashed word list with a larger capacity.\n";
}

$dict->dump( \*STDOUT );
