From 47acd69a8a66bd220b56900cc2bc495aaa284ffa Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 15 Mar 2004 23:14:40 +0000 Subject: [PATCH] Use unsigned short rather than int for char conversion trie --- src/charconv.tcl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/charconv.tcl b/src/charconv.tcl index 7a8fc1a..44a8d85 100755 --- a/src/charconv.tcl +++ b/src/charconv.tcl @@ -2,7 +2,7 @@ # the next line restats using tclsh \ exec tclsh "$0" "$@" # -# $Id: charconv.tcl,v 1.1 2003-10-27 12:21:30 adam Exp $ +# $Id: charconv.tcl,v 1.2 2004-03-15 23:14:40 adam Exp $ proc usage {} { puts {charconv.tcl: [-p prefix] [-s split] [-o ofile] file ... } @@ -14,6 +14,10 @@ proc ins_trie {from to} { if {![info exists trie(no)]} { set trie(no) 1 set trie(size) 0 + set trie(max) 0 + } + if {$trie(max) < $to} { + set trie(max) $to } incr trie(size) ins_trie_r [split $from] $to 0 @@ -77,23 +81,29 @@ proc dump_trie {ofile} { set f [open $ofile w] + if {[string length $trie(max)] > 4} { + set totype int + } else { + set totype {unsigned short} + } + puts $f "/* TRIE: size $trie(size) */" puts $f "\#include " - puts $f { + puts $f " struct yaz_iconv_trie_flat { char *from; - int to; + $totype to; }; struct yaz_iconv_trie_dir { struct yaz_iconv_trie *ptr; - int to; + $totype to; }; struct yaz_iconv_trie { struct yaz_iconv_trie_flat *flat; struct yaz_iconv_trie_dir *dir; }; - } + " set this $trie(no) while { [incr this -1] >= 0 } { @@ -272,4 +282,5 @@ if {![info exists ifiles]} { foreach ifile $ifiles { readfile $ifile } + dump_trie $ofile -- 1.7.10.4