projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9ee70f4
)
Use unsigned short rather than int for char conversion trie
author
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 15 Mar 2004 23:14:40 +0000
(23:14 +0000)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 15 Mar 2004 23:14:40 +0000
(23:14 +0000)
src/charconv.tcl
patch
|
blob
|
history
diff --git
a/src/charconv.tcl
b/src/charconv.tcl
index
7a8fc1a
..
44a8d85
100755
(executable)
--- a/
src/charconv.tcl
+++ b/
src/charconv.tcl
@@
-2,7
+2,7
@@
# the next line restats using tclsh \
exec tclsh "$0" "$@"
#
# 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 ... }
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
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
}
incr trie(size)
ins_trie_r [split $from] $to 0
@@
-77,23
+81,29
@@
proc dump_trie {ofile} {
set f [open $ofile w]
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 <string.h>"
puts $f "/* TRIE: size $trie(size) */"
puts $f "\#include <string.h>"
- puts $f {
+ puts $f "
struct yaz_iconv_trie_flat {
char *from;
struct yaz_iconv_trie_flat {
char *from;
- int to;
+ $totype to;
};
struct yaz_iconv_trie_dir {
struct yaz_iconv_trie *ptr;
};
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;
};
};
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 } {
set this $trie(no)
while { [incr this -1] >= 0 } {
@@
-272,4
+282,5
@@
if {![info exists ifiles]} {
foreach ifile $ifiles {
readfile $ifile
}
foreach ifile $ifiles {
readfile $ifile
}
+
dump_trie $ofile
dump_trie $ofile