+ if {[regexp {<entitymap>} $line s]} {
+ reset_trie
+ set trie(prefix) "${prefix}"
+ } elseif {[regexp {</entitymap>} $line s]} {
+ dump_trie $ofilehandle
+ } elseif {[regexp {<character hex="([^\"]*)".*<unientity>([0-9A-Fa-f]*)</unientity>} $line s hex ucs]} {
+ ins_trie $hex $ucs $combining {}
+ unset hex
+ } elseif {[regexp {<codeTable .*number="([0-9]+)"} $line s tablenumber]} {
+ reset_trie
+ set trie(prefix) "${prefix}_$tablenumber"
+ set combining 0
+ } elseif {[regexp {</codeTable>} $line s]} {
+ if {[lsearch $omits $tablenumber] == -1} {
+ dump_trie $ofilehandle
+ }
+ } elseif {[regexp {</code>} $line s]} {
+ if {[string length $ucs]} {
+ if {$reverse} {
+ for {set i 0} {$i < [string length $utf]} {incr i 2} {
+ lappend hex [string range $utf $i [expr $i+1]]
+ }
+ # puts "ins_trie $hex $marc
+ ins_trie $hex $marc $combining $codename
+ unset hex
+
+ } else {
+ for {set i 0} {$i < [string length $marc]} {incr i 2} {
+ lappend hex [string range $marc $i [expr $i+1]]
+ }
+ # puts "ins_trie $hex $ucs"
+ ins_trie $hex $ucs $combining $codename
+ unset hex
+ }
+ }
+ if {$reverse && [string length $marc]} {
+ for {set i 0} {$i < [string length $altutf]} {incr i 2} {
+ lappend hex [string range $altutf $i [expr $i+1]]
+ }
+ if {[info exists hex]} {
+ ins_trie $hex $marc $combining $codename
+ unset hex
+ }
+ }
+ set marc {}
+ set uni {}
+ set codename {}
+ set combining 0
+ set altutf {}
+ } elseif {[regexp {<marc>([0-9A-Fa-f]*)</marc>} $line s marc]} {
+ incr marc_lines
+ } elseif {[regexp {<name>(.*)</name>} $line s codename]} {
+ incr codename_lines
+ } elseif {[regexp {<name>(.*)} $line s codename]} {
+ incr codename_lines
+ incr lineno
+ set cnt [gets $f line]
+ if {$cnt < 0} {
+ break
+ }
+ if {[regexp {(.*)</name>} $line s codename_ex]} {
+ set codename "${codename} ${codename_ex}"
+ }
+ } elseif {[regexp {<isCombining>true</isCombining>} $line s]} {
+ set combining 1
+ } elseif {[regexp {<ucs>([0-9A-Fa-f]*)</ucs>} $line s ucs]} {
+ incr ucs_lines
+ } elseif {[regexp {<utf-8>([0-9A-Fa-f]*)</utf-8>} $line s utf]} {
+ incr utf_lines
+ } elseif {[regexp {<altutf-8>([0-9A-Fa-f]*)</altutf-8>} $line s altutf]} {
+ incr altutf_lines
+ }