#/! /usr/bin/perl
#---------------------------------------------------------------------
# All portions of code are copyright by their respective author/s.
# Copyright (C) 1996-2001 Vuthichai Ampornaramveth <vuthi@venus.dti.ne.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#---------------------------------------------------------------------

# Convert Dictionary file to header file
# Usage: dict2c tdict.txt > tdict.h
# By: vuthi@ctrl.titech.ac.jp

print <<ENDEND;
/* This file is machine-generated by a perl script. */
/* Don't modify unless you maintain the word order. */

unsigned char *wordptr[]={
ENDEND
$c = 0;
while(<>) {
  chop;
  next if /^\s*$/;
  $i = length($_);
  $ex[$i]=1;
  $maxl = $i if $i > $maxl;
  print ",\n" if $c;
  printf "\"\\x%02X%s\"", $i, $_;
  $c++;
}

print <<ENDEND;
};
int numword = $c;
int maxwordlength = $maxl;
ENDEND
