X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcharconv.tcl;h=45f6e13336a98548db85a9c5fada13b0f9ed78cd;hb=e38c23b29a89e9c4e1cd5aa9033015efc39b26c0;hp=2d946d052675460aca3b1b406c4b20a23272fef4;hpb=30d210952d2f8b305f9f79e637a4db53dcf0873c;p=yaz-moved-to-github.git diff --git a/src/charconv.tcl b/src/charconv.tcl index 2d946d0..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.8 2005-03-16 21:26:37 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,11 +245,10 @@ 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; - code = *inp; } return code; }