From 1a4c851c7c580ee70f485b2d9d98289a85a8079a Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Fri, 6 May 2005 01:38:05 +0000 Subject: * src/stringprep/uni_norm.c: Regenerated with Unicode 3.2 tables as required by RFC3454 * src/stringprep/uni_parse2.tcl: Bugfixes * src/stringprep/stringprep_drv.c: Bugfixes, added hangul composition SVN Revision: 342 --- src/stringprep/uni_parse2.tcl | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src/stringprep/uni_parse2.tcl') diff --git a/src/stringprep/uni_parse2.tcl b/src/stringprep/uni_parse2.tcl index 968f262b7..ac1551766 100644 --- a/src/stringprep/uni_parse2.tcl +++ b/src/stringprep/uni_parse2.tcl @@ -233,15 +233,32 @@ proc uni::buildTables {} { set decomp_mask [expr {(1 << $decomp_shift) - 1}] set comp_mask [expr {(1 << $comp_shift) - 1}] + foreach comp [array names comp_map] { + set ch1 [lindex $comp 0] + if {[info exists comp_first($ch1)] && $comp_first($ch1) > 0 && \ + [info exists comp_second($ch1)] && $comp_second($ch1) > 0} { + if {[lsearch -exact $comp_x_list $ch1] < 0} { + set i [llength $comp_x_list] + lappend comp_x_list $ch1 + set comp_info_map($ch1) $i + lappend comp_y_list $ch1 + set comp_info_map($ch1) $i + puts "There should be no symbols which appears on" + puts "both first and second place in composition" + exit + } + } + } + foreach comp [array names comp_map] { set ch1 [lindex $comp 0] set ch2 [lindex $comp 1] - if {$comp_first($ch1) == 1} { + if {$comp_first($ch1) == 1 && ![info exists comp_second($ch1)]} { set i [llength $comp_first_list] lappend comp_first_list [list $ch2 $comp_map($comp)] set comp_info_map($ch1) [expr {$i | (1 << 16)}] - } elseif {$comp_second($ch2) == 1} { + } elseif {$comp_second($ch2) == 1 && ![info exists comp_first($ch2)]} { set i [llength $comp_second_list] lappend comp_second_list [list $ch1 $comp_map($comp)] set comp_info_map($ch2) [expr {$i | (1 << 16)}] @@ -254,7 +271,7 @@ proc uni::buildTables {} { if {[lsearch -exact $comp_y_list $ch2] < 0} { set i [llength $comp_y_list] lappend comp_y_list $ch2 - set comp_info_map($ch2) $i + set comp_info_map($ch2) [expr {$i | (1 << 17)}] } } } @@ -283,10 +300,19 @@ proc uni::buildTables {} { if {[info exists decomp_map($i)]} { set decomp $decomp_map($i) - #puts -$decomp - while {[info exists decomp_map([set ch1 [lindex $decomp 0]])]} { - set decomp [concat $decomp_map($ch1) [lreplace $decomp 0 0]] - #puts +$decomp + set b 1 + while {$b} { + set b 0 + for {set j 0} {$j < [llength $decomp]} {incr j} { + if {[info exists \ + decomp_map([set ch1 [lindex $decomp $j]])]} { + #puts -$decomp + set decomp [eval [list lreplace $decomp $j $j] \ + $decomp_map($ch1)] + #puts +$decomp + set b 1 + } + } } if {[info exists decomp_used($decomp)]} { @@ -665,6 +691,7 @@ static int compBothList\[[llength $comp_x_list]\]\[[llength $comp_y_list]\] = {" #define CompSingleMask (1 << 16) #define CompMask ((1 << 16) - 1) +#define CompSecondMask (1 << 17) " close $f -- cgit v1.2.3