X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fcharconv.tcl;h=e57ac3c584b8a7e4007076a8171db7b6eab3db26;hb=4b3d1e197d75fcb2607be8d86d244f20c4180000;hp=befad0fa0209944e5363cb9fd35f06d91ce59d05;hpb=1121eeb134f61c6c2510143858db59045c1b6757;p=yaz-moved-to-github.git diff --git a/util/charconv.tcl b/util/charconv.tcl index befad0f..e57ac3c 100755 --- a/util/charconv.tcl +++ b/util/charconv.tcl @@ -2,10 +2,10 @@ # the next line restats using tclsh \ exec tclsh "$0" "$@" # -# $Id: charconv.tcl,v 1.1 2002-12-16 13:13:53 adam Exp $ +# $Id: charconv.tcl,v 1.3 2003-06-02 22:17:20 adam Exp $ proc usage {} { - puts {charconv.tcl: [-p prefix] [-s split] input output} + puts {charconv.tcl: [-p prefix] [-s split] [-o ofile] file ... } exit 1 } @@ -103,7 +103,7 @@ proc dump_trie {ofile} { foreach m $trie($this,content) { puts -nonewline $f " \{\"" foreach d [lindex $m 0] { - puts -nonewline $f "\\0x$d" + puts -nonewline $f "\\x$d" } puts -nonewline $f "\", 0x[lindex $m 1]" puts $f "\}," @@ -175,7 +175,7 @@ proc dump_trie {ofile} { while (flat->from) { size_t len = strlen(flat->from); - if (len >= inbytesleft) + if (len <= inbytesleft) { if (memcmp(flat->from, inp, len) == 0) { @@ -229,7 +229,7 @@ proc readfile {fname} { set verbose 0 set ifile {} -set ofile {} +set ofile out.c set trie(split) 40 set trie(prefix) {} # Parse command line @@ -253,26 +253,23 @@ while {$i < $l} { } set trie(prefix) $arg } - default { - if {![string length $ifile]} { - set ifile $arg - } elseif {![string length $ofile]} { - set ofile $arg - } else { - puts "charconv.tcl: too many files given" - usage + -o { + if {[string length $arg]} { + set arg [lindex $argv [incr i]] } + set ofile $arg + } + default { + lappend ifiles $arg } } incr i } -if {![string length $ifile]} { - puts "charconv.tcl: missing input file" +if {![info exists ifiles]} { + puts "charconv.tcl: missing input file(s)" usage } -if {![string length $ofile]} { - puts "charconv.tcl: missing output file" - usage +foreach ifile $ifiles { + readfile $ifile } -readfile $ifile dump_trie $ofile