1 proc emitRange {first last} {
2 global ranges numranges chars numchars
4 if {$first < ($last-1)} {
5 append ranges [format "{0x%04x, 0x%04x}, " \
7 if {[incr numranges] % 4 == 0} {
11 append chars [format "0x%04x, " $first]
13 if {$numchars % 9 == 0} {
16 if {$first != $last} {
17 append chars [format "0x%04x, " $last]
19 if {$numchars % 9 == 0} {
26 proc genTable {type} {
27 global first last ranges numranges chars numchars
36 for {set i 0} {$i < 0x10000} {incr i} {
37 if {[string is $type [format %c $i]]} {
38 if {$i == ($last + 1)} {
42 emitRange $first $last
49 emitRange $first $last
51 puts "static crange ${type}RangeTable\[\] = {\n$ranges\n};\n"
52 puts "#define NUM_[string toupper $type]_RANGE (sizeof(${type}RangeTable)/sizeof(crange))\n"
53 puts "static chr ${type}CharTable\[\] = {\n$chars\n};\n"
54 puts "#define NUM_[string toupper $type]_CHAR (sizeof(${type}CharTable)/sizeof(chr))\n"
58 foreach type {alpha digit punct space lower upper graph } {