X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcharconv.tcl;h=45f6e13336a98548db85a9c5fada13b0f9ed78cd;hb=e38c23b29a89e9c4e1cd5aa9033015efc39b26c0;hp=6ffdd650a53c2aa693b392fbfe8ec29651025d3e;hpb=9527520d6b18b7c74d74ff4ad42fbf7eab73d203;p=yaz-moved-to-github.git diff --git a/src/charconv.tcl b/src/charconv.tcl index 6ffdd65..45f6e13 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.9 2005-11-06 01:55:06 adam Exp $ +# $Id: charconv.tcl,v 1.11 2006-02-23 13:15:43 adam Exp $ proc usage {} { puts {charconv.tcl: [-p prefix] [-s split] [-o ofile] file ... } @@ -22,7 +22,7 @@ proc preamble_trie {ofilehandle} { $totype to : 24; }; struct yaz_iconv_trie_dir { - short ptr : 15; + int ptr : 15; unsigned combining : 1; $totype to : 24; }; @@ -36,7 +36,7 @@ proc preamble_trie {ofilehandle} { static unsigned long lookup(struct yaz_iconv_trie **ptrs, int ptr, unsigned char *inp, size_t inbytesleft, size_t *no_read, int *combining) { - struct yaz_iconv_trie *t = (ptr >= 0) ? ptrs[ptr] : 0; + struct yaz_iconv_trie *t = (ptr > 0) ? ptrs[ptr-1] : 0; if (!t || inbytesleft < 1) return 0; if (t->dir) @@ -200,10 +200,10 @@ proc dump_trie {ofilehandle} { set ch [format %02X $i] set null 1 if {[info exist trie($this,ptr,$ch)]} { - puts -nonewline $f "$trie($this,ptr,$ch), " + puts -nonewline $f "[expr $trie($this,ptr,$ch)+1], " set null 0 } else { - puts -nonewline $f "-1, " + puts -nonewline $f "0, " } if {[info exist trie($this,combining,$ch)]} { puts -nonewline $f "$trie($this,combining,$ch), " @@ -245,7 +245,7 @@ proc dump_trie {ofilehandle} { { unsigned long code; - code = lookup($trie(prefix)ptrs, 0, inp, inbytesleft, no_read, combining); + code = lookup($trie(prefix)ptrs, 1, inp, inbytesleft, no_read, combining); if (!code) { *no_read = 1;