diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-12-24 00:30:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-12-24 00:30:08 (GMT) |
commit | d7156f25cf364f27a66714b3180799d3abf07a9a (patch) | |
tree | 6c6340bb387ae1423667cd5c526982bf6d4bae90 /tools/uniParse.tcl | |
parent | 9c27c0e59b0afaae14af4b0a18f128744ea594b1 (diff) | |
parent | bd656d0e3881028b3b25a40e96d9253baabd44ec (diff) | |
download | tcl-d7156f25cf364f27a66714b3180799d3abf07a9a.zip tcl-d7156f25cf364f27a66714b3180799d3abf07a9a.tar.gz tcl-d7156f25cf364f27a66714b3180799d3abf07a9a.tar.bz2 |
[Bug 3464428] string is graph \u0120 is wrong
Diffstat (limited to 'tools/uniParse.tcl')
-rw-r--r-- | tools/uniParse.tcl | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/tools/uniParse.tcl b/tools/uniParse.tcl index 6850897..a13bae6 100644 --- a/tools/uniParse.tcl +++ b/tools/uniParse.tcl @@ -30,45 +30,39 @@ namespace eval uni { Cc Cf Co Cs Pc Pd Ps Pe Pi Pf Po Sm Sc Sk So }; # Ordered list of character categories, must # match the enumeration in the header file. - - variable titleCount 0; # Count of the number of title case - # characters. This value is used in the - # regular expression code to allocate enough - # space for the title case variants. } proc uni::getValue {items index} { variable categories - variable titleCount # Extract character info set category [lindex $items 2] - if {[scan [lindex $items 12] %6x toupper] == 1} { + if {[scan [lindex $items 12] %x toupper] == 1} { set toupper [expr {$index - $toupper}] } else { set toupper 0 } - if {[scan [lindex $items 13] %6x tolower] == 1} { + if {[scan [lindex $items 13] %x tolower] == 1} { set tolower [expr {$tolower - $index}] } else { set tolower 0 } - if {[scan [lindex $items 14] %6x totitle] == 1} { + if {[scan [lindex $items 14] %x totitle] == 1} { set totitle [expr {$index - $totitle}] - } else { + } elseif {$tolower} { set totitle 0 + } else { + set totitle $toupper } set categoryIndex [lsearch -exact $categories $category] if {$categoryIndex < 0} { puts "Unexpected character category: $index($category)" set categoryIndex 0 - } elseif {$category eq "Lt"} { - incr titleCount } - return "$categoryIndex,$toupper,$tolower,$totitle" + return [list $categoryIndex $toupper $tolower $totitle] } proc uni::getGroup {value} { @@ -100,7 +94,7 @@ proc uni::buildTables {data} { variable pMap {} variable pages {} - variable groups {{0,0,0,0}} + variable groups {{0 0 0 0}} variable next 0 set info {} ;# temporary page info @@ -120,7 +114,7 @@ proc uni::buildTables {data} { set items [split $line \;] scan [lindex $items 0] %x index - if {$index > 0xFFFF} then { + if {$index > 0xffff} then { # Ignore non-BMP characters, as long as Tcl doesn't support them continue } @@ -171,7 +165,6 @@ proc uni::main {} { variable pages variable groups variable shift - variable titleCount variable next if {$argc != 2} { @@ -186,7 +179,6 @@ proc uni::main {} { puts "X = [llength $pMap] Y= [llength $pages] A= [llength $groups]" set size [expr {[llength $pMap]*2 + [llength $pages]*(1<<$shift)}] puts "shift = $shift, space = $size" - puts "title case count = $titleCount" set f [open [file join [lindex $argv 1] tclUniData.c] w] fconfigure $f -translation lf @@ -280,7 +272,7 @@ static const int groups\[\] = {" set line " " set last [expr {[llength $groups] - 1}] for {set i 0} {$i <= $last} {incr i} { - foreach {type toupper tolower totitle} [split [lindex $groups $i] ,] {} + foreach {type toupper tolower totitle} [lindex $groups $i] {} # Compute the case conversion type and delta @@ -329,9 +321,9 @@ static const int groups\[\] = {" * Unicode character. */ -#define UNICODE_CATEGORY_MASK 0x1F +#define UNICODE_CATEGORY_MASK 0x1f #define UNICODE_OUT_OF_RANGE " - puts $f [format 0x%Xu $next] + puts $f [format 0x%xu $next] puts $f " enum { UNASSIGNED, @@ -372,8 +364,8 @@ enum { * to do sign extension on right shifts. */ -#define GetCaseType(info) (((info) & 0xE0) >> 5) -#define GetCategory(ch) (GetUniCharInfo(ch) & 0x1F) +#define GetCaseType(info) (((info) & 0xe0) >> 5) +#define GetCategory(ch) (GetUniCharInfo(ch) & 0x1f) #define GetDelta(info) (((info) > 0) ? ((info) >> 15) : (~(~((info)) >> 15))) /* |