track 3.7.13
[sqlcipher.git] / ext / fts3 / unicode / mkunicode.tcl
blob0d58e8aa5c0bc10bd631617582a7eb8dbfb30f1b
3 # Parameter $zName must be a path to the file UnicodeData.txt. This command
4 # reads the file and returns a list of mappings required to remove all
5 # diacritical marks from a unicode string. Each mapping is itself a list
6 # consisting of two elements - the unicode codepoint and the single ASCII
7 # character that it should be replaced with, or an empty string if the
8 # codepoint should simply be removed from the input. Examples:
10 # { 224 a } (replace codepoint 224 to "a")
11 # { 769 "" } (remove codepoint 769 from input)
13 # Mappings are only returned for non-upper case codepoints. It is assumed
14 # that the input has already been folded to lower case.
16 proc rd_load_unicodedata_text {zName} {
17 global tl_lookup_table
19 set fd [open $zName]
20 set lField {
21 code
22 character_name
23 general_category
24 canonical_combining_classes
25 bidirectional_category
26 character_decomposition_mapping
27 decimal_digit_value
28 digit_value
29 numeric_value
30 mirrored
31 unicode_1_name
32 iso10646_comment_field
33 uppercase_mapping
34 lowercase_mapping
35 titlecase_mapping
37 set lRet [list]
39 while { ![eof $fd] } {
40 set line [gets $fd]
41 if {$line == ""} continue
43 set fields [split $line ";"]
44 if {[llength $fields] != [llength $lField]} { error "parse error: $line" }
45 foreach $lField $fields {}
46 if { [llength $character_decomposition_mapping]!=2
47 || [string is xdigit [lindex $character_decomposition_mapping 0]]==0
48 } {
49 continue
52 set iCode [expr "0x$code"]
53 set iAscii [expr "0x[lindex $character_decomposition_mapping 0]"]
54 set iDia [expr "0x[lindex $character_decomposition_mapping 1]"]
56 if {[info exists tl_lookup_table($iCode)]} continue
58 if { ($iAscii >= 97 && $iAscii <= 122)
59 || ($iAscii >= 65 && $iAscii <= 90)
60 } {
61 lappend lRet [list $iCode [string tolower [format %c $iAscii]]]
62 set dia($iDia) 1
66 foreach d [array names dia] {
67 lappend lRet [list $d ""]
69 set lRet [lsort -integer -index 0 $lRet]
71 close $fd
72 set lRet
76 proc print_rd {map} {
77 global tl_lookup_table
78 set aChar [list]
79 set lRange [list]
81 set nRange 1
82 set iFirst [lindex $map 0 0]
83 set cPrev [lindex $map 0 1]
85 foreach m [lrange $map 1 end] {
86 foreach {i c} $m {}
88 if {$cPrev == $c} {
89 for {set j [expr $iFirst+$nRange]} {$j<$i} {incr j} {
90 if {[info exists tl_lookup_table($j)]==0} break
93 if {$j==$i} {
94 set nNew [expr {(1 + $i - $iFirst)}]
95 if {$nNew<=8} {
96 set nRange $nNew
97 continue
102 lappend lRange [list $iFirst $nRange]
103 lappend aChar $cPrev
105 set iFirst $i
106 set cPrev $c
107 set nRange 1
109 lappend lRange [list $iFirst $nRange]
110 lappend aChar $cPrev
112 puts "/*"
113 puts "** If the argument is a codepoint corresponding to a lowercase letter"
114 puts "** in the ASCII range with a diacritic added, return the codepoint"
115 puts "** of the ASCII letter only. For example, if passed 235 - \"LATIN"
116 puts "** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER"
117 puts "** E\"). The resuls of passing a codepoint that corresponds to an"
118 puts "** uppercase letter are undefined."
119 puts "*/"
120 puts "static int remove_diacritic(int c)\{"
121 puts " unsigned short aDia\[\] = \{"
122 puts -nonewline " 0, "
123 set i 1
124 foreach r $lRange {
125 foreach {iCode nRange} $r {}
126 if {($i % 8)==0} {puts "" ; puts -nonewline " " }
127 incr i
129 puts -nonewline [format "%5d" [expr ($iCode<<3) + $nRange-1]]
130 puts -nonewline ", "
132 puts ""
133 puts " \};"
134 puts " char aChar\[\] = \{"
135 puts -nonewline " '\\0', "
136 set i 1
137 foreach c $aChar {
138 set str "'$c', "
139 if {$c == ""} { set str "'\\0', " }
141 if {($i % 12)==0} {puts "" ; puts -nonewline " " }
142 incr i
143 puts -nonewline "$str"
145 puts ""
146 puts " \};"
147 puts {
148 unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
149 int iRes = 0;
150 int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
151 int iLo = 0;
152 while( iHi>=iLo ){
153 int iTest = (iHi + iLo) / 2;
154 if( key >= aDia[iTest] ){
155 iRes = iTest;
156 iLo = iTest+1;
157 }else{
158 iHi = iTest-1;
161 assert( key>=aDia[iRes] );
162 return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);}
163 puts "\};"
166 proc print_isdiacritic {zFunc map} {
168 set lCode [list]
169 foreach m $map {
170 foreach {code char} $m {}
171 if {$code && $char == ""} { lappend lCode $code }
173 set lCode [lsort -integer $lCode]
174 set iFirst [lindex $lCode 0]
175 set iLast [lindex $lCode end]
177 set i1 0
178 set i2 0
180 foreach c $lCode {
181 set i [expr $c - $iFirst]
182 if {$i < 32} {
183 set i1 [expr {$i1 | (1<<$i)}]
184 } else {
185 set i2 [expr {$i2 | (1<<($i-32))}]
189 puts "/*"
190 puts "** Return true if the argument interpreted as a unicode codepoint"
191 puts "** is a diacritical modifier character."
192 puts "*/"
193 puts "int ${zFunc}\(int c)\{"
194 puts " unsigned int mask0 = [format "0x%08X" $i1];"
195 puts " unsigned int mask1 = [format "0x%08X" $i2];"
197 puts " if( c<$iFirst || c>$iLast ) return 0;"
198 puts " return (c < $iFirst+32) ?"
199 puts " (mask0 & (1 << (c-$iFirst))) :"
200 puts " (mask1 & (1 << (c-$iFirst-32)));"
201 puts "\}"
205 #-------------------------------------------------------------------------
207 # Parameter $zName must be a path to the file UnicodeData.txt. This command
208 # reads the file and returns a list of codepoints (integers). The list
209 # contains all codepoints in the UnicodeData.txt assigned to any "General
210 # Category" that is not a "Letter" or "Number".
212 proc an_load_unicodedata_text {zName} {
213 set fd [open $zName]
214 set lField {
215 code
216 character_name
217 general_category
218 canonical_combining_classes
219 bidirectional_category
220 character_decomposition_mapping
221 decimal_digit_value
222 digit_value
223 numeric_value
224 mirrored
225 unicode_1_name
226 iso10646_comment_field
227 uppercase_mapping
228 lowercase_mapping
229 titlecase_mapping
231 set lRet [list]
233 while { ![eof $fd] } {
234 set line [gets $fd]
235 if {$line == ""} continue
237 set fields [split $line ";"]
238 if {[llength $fields] != [llength $lField]} { error "parse error: $line" }
239 foreach $lField $fields {}
241 set iCode [expr "0x$code"]
242 set bAlnum [expr {[lsearch {L N} [string range $general_category 0 0]]>=0}]
244 if { !$bAlnum } { lappend lRet $iCode }
247 close $fd
248 set lRet
251 proc an_load_separator_ranges {} {
252 global unicodedata.txt
253 set lSep [an_load_unicodedata_text ${unicodedata.txt}]
254 unset -nocomplain iFirst
255 unset -nocomplain nRange
256 set lRange [list]
257 foreach sep $lSep {
258 if {0==[info exists iFirst]} {
259 set iFirst $sep
260 set nRange 1
261 } elseif { $sep == ($iFirst+$nRange) } {
262 incr nRange
263 } else {
264 lappend lRange [list $iFirst $nRange]
265 set iFirst $sep
266 set nRange 1
269 lappend lRange [list $iFirst $nRange]
270 set lRange
273 proc an_print_range_array {lRange} {
274 set iFirstMax 0
275 set nRangeMax 0
276 foreach range $lRange {
277 foreach {iFirst nRange} $range {}
278 if {$iFirst > $iFirstMax} {set iFirstMax $iFirst}
279 if {$nRange > $nRangeMax} {set nRangeMax $nRange}
281 if {$iFirstMax >= (1<<22)} {error "first-max is too large for format"}
282 if {$nRangeMax >= (1<<10)} {error "range-max is too large for format"}
284 puts -nonewline " "
285 puts [string trim {
286 /* Each unsigned integer in the following array corresponds to a contiguous
287 ** range of unicode codepoints that are not either letters or numbers (i.e.
288 ** codepoints for which this function should return 0).
290 ** The most significant 22 bits in each 32-bit value contain the first
291 ** codepoint in the range. The least significant 10 bits are used to store
292 ** the size of the range (always at least 1). In other words, the value
293 ** ((C<<22) + N) represents a range of N codepoints starting with codepoint
294 ** C. It is not possible to represent a range larger than 1023 codepoints
295 ** using this format.
298 puts -nonewline " const static unsigned int aEntry\[\] = \{"
299 set i 0
300 foreach range $lRange {
301 foreach {iFirst nRange} $range {}
302 set u32 [format "0x%08X" [expr ($iFirst<<10) + $nRange]]
304 if {($i % 5)==0} {puts "" ; puts -nonewline " "}
305 puts -nonewline " $u32,"
306 incr i
308 puts ""
309 puts " \};"
312 proc an_print_ascii_bitmap {lRange} {
313 foreach range $lRange {
314 foreach {iFirst nRange} $range {}
315 for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} {
316 if {$i<=127} { set a($i) 1 }
320 set aAscii [list 0 0 0 0]
321 foreach key [array names a] {
322 set idx [expr $key >> 5]
323 lset aAscii $idx [expr [lindex $aAscii $idx] | (1 << ($key&0x001F))]
326 puts " static const unsigned int aAscii\[4\] = \{"
327 puts -nonewline " "
328 foreach v $aAscii { puts -nonewline [format " 0x%08X," $v] }
329 puts ""
330 puts " \};"
333 proc print_isalnum {zFunc lRange} {
334 puts "/*"
335 puts "** Return true if the argument corresponds to a unicode codepoint"
336 puts "** classified as either a letter or a number. Otherwise false."
337 puts "**"
338 puts "** The results are undefined if the value passed to this function"
339 puts "** is less than zero."
340 puts "*/"
341 puts "int ${zFunc}\(int c)\{"
342 an_print_range_array $lRange
343 an_print_ascii_bitmap $lRange
344 puts {
345 if( c<128 ){
346 return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );
347 }else if( c<(1<<22) ){
348 unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;
349 int iRes;
350 int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
351 int iLo = 0;
352 while( iHi>=iLo ){
353 int iTest = (iHi + iLo) / 2;
354 if( key >= aEntry[iTest] ){
355 iRes = iTest;
356 iLo = iTest+1;
357 }else{
358 iHi = iTest-1;
361 assert( aEntry[0]<key );
362 assert( key>=aEntry[iRes] );
363 return (c >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
365 return 1;}
366 puts "\}"
369 proc print_test_isalnum {zFunc lRange} {
370 foreach range $lRange {
371 foreach {iFirst nRange} $range {}
372 for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} { set a($i) 1 }
375 puts "static int isalnum_test(int *piCode)\{"
376 puts -nonewline " unsigned char aAlnum\[\] = \{"
377 for {set i 0} {$i < 70000} {incr i} {
378 if {($i % 32)==0} { puts "" ; puts -nonewline " " }
379 set bFlag [expr ![info exists a($i)]]
380 puts -nonewline "${bFlag},"
382 puts ""
383 puts " \};"
385 puts -nonewline " int aLargeSep\[\] = \{"
386 set i 0
387 foreach iSep [lsort -integer [array names a]] {
388 if {$iSep<70000} continue
389 if {($i % 8)==0} { puts "" ; puts -nonewline " " }
390 puts -nonewline " $iSep,"
391 incr i
393 puts ""
394 puts " \};"
395 puts -nonewline " int aLargeOther\[\] = \{"
396 set i 0
397 foreach iSep [lsort -integer [array names a]] {
398 if {$iSep<70000} continue
399 if {[info exists a([expr $iSep-1])]==0} {
400 if {($i % 8)==0} { puts "" ; puts -nonewline " " }
401 puts -nonewline " [expr $iSep-1],"
402 incr i
404 if {[info exists a([expr $iSep+1])]==0} {
405 if {($i % 8)==0} { puts "" ; puts -nonewline " " }
406 puts -nonewline " [expr $iSep+1],"
407 incr i
410 puts ""
411 puts " \};"
413 puts [subst -nocommands {
414 int i;
415 for(i=0; i<sizeof(aAlnum)/sizeof(aAlnum[0]); i++){
416 if( ${zFunc}(i)!=aAlnum[i] ){
417 *piCode = i;
418 return 1;
421 for(i=0; i<sizeof(aLargeSep)/sizeof(aLargeSep[0]); i++){
422 if( ${zFunc}(aLargeSep[i])!=0 ){
423 *piCode = aLargeSep[i];
424 return 1;
427 for(i=0; i<sizeof(aLargeOther)/sizeof(aLargeOther[0]); i++){
428 if( ${zFunc}(aLargeOther[i])!=1 ){
429 *piCode = aLargeOther[i];
430 return 1;
434 puts " return 0;"
435 puts "\}"
438 #-------------------------------------------------------------------------
440 proc tl_load_casefolding_txt {zName} {
441 global tl_lookup_table
443 set fd [open $zName]
444 while { ![eof $fd] } {
445 set line [gets $fd]
446 if {[string range $line 0 0] == "#"} continue
447 if {$line == ""} continue
449 foreach x {a b c d} {unset -nocomplain $x}
450 foreach {a b c d} [split $line ";"] {}
452 set a2 [list]
453 set c2 [list]
454 foreach elem $a { lappend a2 [expr "0x[string trim $elem]"] }
455 foreach elem $c { lappend c2 [expr "0x[string trim $elem]"] }
456 set b [string trim $b]
457 set d [string trim $d]
459 if {$b=="C" || $b=="S"} { set tl_lookup_table($a2) $c2 }
463 proc tl_create_records {} {
464 global tl_lookup_table
466 set iFirst ""
467 set nOff 0
468 set nRange 0
469 set nIncr 0
471 set lRecord [list]
472 foreach code [lsort -integer [array names tl_lookup_table]] {
473 set mapping $tl_lookup_table($code)
474 if {$iFirst == ""} {
475 set iFirst $code
476 set nOff [expr $mapping - $code]
477 set nRange 1
478 set nIncr 1
479 } else {
480 set diff [expr $code - ($iFirst + ($nIncr * ($nRange - 1)))]
481 if { $nRange==1 && ($diff==1 || $diff==2) } {
482 set nIncr $diff
485 if {$diff != $nIncr || ($mapping - $code)!=$nOff} {
486 if { $nRange==1 } {set nIncr 1}
487 lappend lRecord [list $iFirst $nIncr $nRange $nOff]
488 set iFirst $code
489 set nOff [expr $mapping - $code]
490 set nRange 1
491 set nIncr 1
492 } else {
493 incr nRange
498 lappend lRecord [list $iFirst $nIncr $nRange $nOff]
500 set lRecord
503 proc tl_print_table_header {} {
504 puts -nonewline " "
505 puts [string trim {
506 /* Each entry in the following array defines a rule for folding a range
507 ** of codepoints to lower case. The rule applies to a range of nRange
508 ** codepoints starting at codepoint iCode.
510 ** If the least significant bit in flags is clear, then the rule applies
511 ** to all nRange codepoints (i.e. all nRange codepoints are upper case and
512 ** need to be folded). Or, if it is set, then the rule only applies to
513 ** every second codepoint in the range, starting with codepoint C.
515 ** The 7 most significant bits in flags are an index into the aiOff[]
516 ** array. If a specific codepoint C does require folding, then its lower
517 ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).
519 ** The contents of this array are generated by parsing the CaseFolding.txt
520 ** file distributed as part of the "Unicode Character Database". See
521 ** http://www.unicode.org for details.
524 puts " static const struct TableEntry \{"
525 puts " unsigned short iCode;"
526 puts " unsigned char flags;"
527 puts " unsigned char nRange;"
528 puts " \} aEntry\[\] = \{"
531 proc tl_print_table_entry {togglevar entry liOff} {
532 upvar $togglevar t
533 foreach {iFirst nIncr nRange nOff} $entry {}
535 if {$iFirst > (1<<16)} { return 1 }
537 if {[info exists t]==0} {set t 0}
538 if {$t==0} { puts -nonewline " " }
540 set flags 0
541 if {$nIncr==2} { set flags 1 ; set nRange [expr $nRange * 2]}
542 if {$nOff<0} { incr nOff [expr (1<<16)] }
544 set idx [lsearch $liOff $nOff]
545 if {$idx<0} {error "malfunction generating aiOff"}
546 set flags [expr $flags + $idx*2]
548 set txt "{$iFirst, $flags, $nRange},"
549 if {$t==2} {
550 puts $txt
551 } else {
552 puts -nonewline [format "% -23s" $txt]
554 set t [expr ($t+1)%3]
556 return 0
559 proc tl_print_table_footer {togglevar} {
560 upvar $togglevar t
561 if {$t!=0} {puts ""}
562 puts " \};"
565 proc tl_print_if_entry {entry} {
566 foreach {iFirst nIncr nRange nOff} $entry {}
567 if {$nIncr==2} {error "tl_print_if_entry needs improvement!"}
569 puts " else if( c>=$iFirst && c<[expr $iFirst+$nRange] )\{"
570 puts " ret = c + $nOff;"
571 puts " \}"
574 proc tl_generate_ioff_table {lRecord} {
575 foreach entry $lRecord {
576 foreach {iFirst nIncr nRange iOff} $entry {}
577 if {$iOff<0} { incr iOff [expr (1<<16)] }
578 if {[info exists a($iOff)]} continue
579 set a($iOff) 1
582 set liOff [lsort -integer [array names a]]
583 if {[llength $liOff]>128} { error "Too many distinct ioffs" }
584 return $liOff
587 proc tl_print_ioff_table {liOff} {
588 puts -nonewline " static const unsigned short aiOff\[\] = \{"
589 set i 0
590 foreach off $liOff {
591 if {($i % 8)==0} {puts "" ; puts -nonewline " "}
592 puts -nonewline [format "% -7s" "$off,"]
593 incr i
595 puts ""
596 puts " \};"
600 proc print_fold {zFunc} {
602 set lRecord [tl_create_records]
604 set lHigh [list]
605 puts "/*"
606 puts "** Interpret the argument as a unicode codepoint. If the codepoint"
607 puts "** is an upper case character that has a lower case equivalent,"
608 puts "** return the codepoint corresponding to the lower case version."
609 puts "** Otherwise, return a copy of the argument."
610 puts "**"
611 puts "** The results are undefined if the value passed to this function"
612 puts "** is less than zero."
613 puts "*/"
614 puts "int ${zFunc}\(int c, int bRemoveDiacritic)\{"
616 set liOff [tl_generate_ioff_table $lRecord]
617 tl_print_table_header
618 foreach entry $lRecord {
619 if {[tl_print_table_entry toggle $entry $liOff]} {
620 lappend lHigh $entry
623 tl_print_table_footer toggle
624 tl_print_ioff_table $liOff
626 puts {
627 int ret = c;
629 assert( c>=0 );
630 assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );
632 if( c<128 ){
633 if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');
634 }else if( c<65536 ){
635 int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
636 int iLo = 0;
637 int iRes = -1;
639 while( iHi>=iLo ){
640 int iTest = (iHi + iLo) / 2;
641 int cmp = (c - aEntry[iTest].iCode);
642 if( cmp>=0 ){
643 iRes = iTest;
644 iLo = iTest+1;
645 }else{
646 iHi = iTest-1;
649 assert( iRes<0 || c>=aEntry[iRes].iCode );
651 if( iRes>=0 ){
652 const struct TableEntry *p = &aEntry[iRes];
653 if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){
654 ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;
655 assert( ret>0 );
659 if( bRemoveDiacritic ) ret = remove_diacritic(ret);
663 foreach entry $lHigh {
664 tl_print_if_entry $entry
667 puts ""
668 puts " return ret;"
669 puts "\}"
672 proc print_fold_test {zFunc mappings} {
673 global tl_lookup_table
675 foreach m $mappings {
676 set c [lindex $m 1]
677 if {$c == ""} {
678 set extra([lindex $m 0]) 0
679 } else {
680 scan $c %c i
681 set extra([lindex $m 0]) $i
685 puts "static int fold_test(int *piCode)\{"
686 puts -nonewline " static int aLookup\[\] = \{"
687 for {set i 0} {$i < 70000} {incr i} {
689 set expected $i
690 catch { set expected $tl_lookup_table($i) }
691 set expected2 $expected
692 catch { set expected2 $extra($expected2) }
694 if {($i % 4)==0} { puts "" ; puts -nonewline " " }
695 puts -nonewline "$expected, $expected2, "
697 puts " \};"
698 puts " int i;"
699 puts " for(i=0; i<sizeof(aLookup)/sizeof(aLookup\[0\]); i++)\{"
700 puts " int iCode = (i/2);"
701 puts " int bFlag = i & 0x0001;"
702 puts " if( ${zFunc}\(iCode, bFlag)!=aLookup\[i\] )\{"
703 puts " *piCode = iCode;"
704 puts " return 1;"
705 puts " \}"
706 puts " \}"
707 puts " return 0;"
708 puts "\}"
712 proc print_fileheader {} {
713 puts [string trim {
715 ** 2012 May 25
717 ** The author disclaims copyright to this source code. In place of
718 ** a legal notice, here is a blessing:
720 ** May you do good and not evil.
721 ** May you find forgiveness for yourself and forgive others.
722 ** May you share freely, never taking more than you give.
724 ******************************************************************************
728 ** DO NOT EDIT THIS MACHINE GENERATED FILE.
731 puts ""
732 puts "#if !defined(SQLITE_DISABLE_FTS3_UNICODE)"
733 puts "#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)"
734 puts ""
735 puts "#include <assert.h>"
736 puts ""
739 proc print_test_main {} {
740 puts ""
741 puts "#include <stdio.h>"
742 puts ""
743 puts "int main(int argc, char **argv)\{"
744 puts " int r1, r2;"
745 puts " int code;"
746 puts " r1 = isalnum_test(&code);"
747 puts " if( r1 ) printf(\"isalnum(): Problem with code %d\\n\",code);"
748 puts " else printf(\"isalnum(): test passed\\n\");"
749 puts " r2 = fold_test(&code);"
750 puts " if( r2 ) printf(\"fold(): Problem with code %d\\n\",code);"
751 puts " else printf(\"fold(): test passed\\n\");"
752 puts " return (r1 || r2);"
753 puts "\}"
756 # Proces the command line arguments. Exit early if they are not to
757 # our liking.
759 proc usage {} {
760 puts -nonewline stderr "Usage: $::argv0 ?-test? "
761 puts stderr "<CaseFolding.txt file> <UnicodeData.txt file>"
762 exit 1
764 if {[llength $argv]!=2 && [llength $argv]!=3} usage
765 if {[llength $argv]==3 && [lindex $argv 0]!="-test"} usage
766 set unicodedata.txt [lindex $argv end]
767 set casefolding.txt [lindex $argv end-1]
768 set generate_test_code [expr {[llength $argv]==3}]
770 print_fileheader
772 # Print the isalnum() function to stdout.
774 set lRange [an_load_separator_ranges]
775 print_isalnum sqlite3FtsUnicodeIsalnum $lRange
777 # Leave a gap between the two generated C functions.
779 puts ""
780 puts ""
782 # Load the fold data. This is used by the [rd_XXX] commands
783 # as well as [print_fold].
784 tl_load_casefolding_txt ${casefolding.txt}
786 set mappings [rd_load_unicodedata_text ${unicodedata.txt}]
787 print_rd $mappings
788 puts ""
789 puts ""
790 print_isdiacritic sqlite3FtsUnicodeIsdiacritic $mappings
791 puts ""
792 puts ""
794 # Print the fold() function to stdout.
796 print_fold sqlite3FtsUnicodeFold
798 # Print the test routines and main() function to stdout, if -test
799 # was specified.
801 if {$::generate_test_code} {
802 print_test_isalnum sqlite3FtsUnicodeIsalnum $lRange
803 print_fold_test sqlite3FtsUnicodeFold $mappings
804 print_test_main
807 puts "#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */"
808 puts "#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */"