File: dict2c.pl

package info (click to toggle)
cttex 1.23
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,748 kB
  • ctags: 133
  • sloc: ansic: 2,299; makefile: 53; perl: 21
file content (47 lines) | stat: -rwxr-xr-x 1,502 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#/! /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