summaryrefslogtreecommitdiffstats
path: root/tools/uniClass.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-05-28 04:37:57 (GMT)
committerhobbs <hobbs>2001-05-28 04:37:57 (GMT)
commit10183c5e6c370680dca338ab2b5232626e501c0b (patch)
tree8df6501dbcea728ac431c40409dc5df693ba2a1c /tools/uniClass.tcl
parent08871cd59928d97b02d2821ef9dfa5024bf79806 (diff)
downloadtcl-10183c5e6c370680dca338ab2b5232626e501c0b.zip
tcl-10183c5e6c370680dca338ab2b5232626e501c0b.tar.gz
tcl-10183c5e6c370680dca338ab2b5232626e501c0b.tar.bz2
* tools/uniClass.tcl: added comments to output format and the
script for clarification. * tools/uniParse.tcl: corrected filename output and GetDelta macro to use 'info' as param (was 'infO')
Diffstat (limited to 'tools/uniClass.tcl')
-rw-r--r--tools/uniClass.tcl56
1 files changed, 49 insertions, 7 deletions
diff --git a/tools/uniClass.tcl b/tools/uniClass.tcl
index 2820ba4..442fc2a 100644
--- a/tools/uniClass.tcl
+++ b/tools/uniClass.tcl
@@ -1,3 +1,17 @@
+#!/bin/sh
+# The next line is executed by /bin/sh, but not tcl \
+exec tclsh "$0" ${1+"$@"}
+
+#
+# uniClass.tcl --
+#
+# Generates the character ranges and singletons that are used in
+# generic/regc_locale.c for translation of character classes.
+# This file must be generated using a tclsh that contains the
+# correct corresponding tclUniData.c file (generated by uniParse.tcl)
+# in order for the class ranges to match.
+#
+
proc emitRange {first last} {
global ranges numranges chars numchars
@@ -33,7 +47,7 @@ proc genTable {type} {
set chars " "
set numchars 0
- for {set i 0} {$i < 0x10000} {incr i} {
+ for {set i 0} {$i <= 0xFFFF} {incr i} {
if {[string is $type [format %c $i]]} {
if {$i == ($last + 1)} {
set last $i
@@ -47,15 +61,43 @@ proc genTable {type} {
}
}
emitRange $first $last
-
- puts "static crange ${type}RangeTable\[\] = {\n$ranges\n};\n"
- puts "#define NUM_[string toupper $type]_RANGE (sizeof(${type}RangeTable)/sizeof(crange))\n"
- puts "static chr ${type}CharTable\[\] = {\n$chars\n};\n"
- puts "#define NUM_[string toupper $type]_CHAR (sizeof(${type}CharTable)/sizeof(chr))\n"
+
+ set ranges [string trimright $ranges "\t\n ,"]
+ set chars [string trimright $chars "\t\n ,"]
+ if {$ranges != ""} {
+ puts "static crange ${type}RangeTable\[\] = {\n$ranges\n};\n"
+ puts "#define NUM_[string toupper $type]_RANGE (sizeof(${type}RangeTable)/sizeof(crange))\n"
+ } else {
+ puts "/* no contiguous ranges of $type characters */\n"
+ }
+ if {$chars != ""} {
+ puts "static chr ${type}CharTable\[\] = {\n$chars\n};\n"
+ puts "#define NUM_[string toupper $type]_CHAR (sizeof(${type}CharTable)/sizeof(chr))\n"
+ } else {
+ puts "/* no singletons of $type characters */\n"
+ }
}
+puts "/*
+ * Declarations of Unicode character ranges. This code
+ * is automatically generated by the tools/uniClass.tcl script
+ * and used in generic/regc_locale.c. Do not modify by hand.
+ */
+"
-foreach type {alpha digit punct space lower upper graph } {
+foreach {type desc} {
+ alpha "alphabetic characters"
+ digit "decimal digit characters"
+ punct "punctuation characters"
+ space "white space characters"
+ lower "lowercase characters"
+ upper "uppercase characters"
+ graph "unicode print characters excluding space"
+} {
+ puts "/* Unicode: $desc */\n"
genTable $type
}
+puts "/*
+ * End of auto-generated Unicode character ranges declarations.
+ */"