6 ## mktables -- create the runtime Perl Unicode files (lib/unicore/**/*.pl)
7 ## from the Unicode database files (lib/unicore/*.txt).
11 mkdir("lib/gc_sc", 0755);
18 my $MakeTestScript = 0;
22 my $arg = shift @ARGV;
25 } elsif ($arg eq '-q') {
27 } elsif ($arg eq '-maketest') {
30 die "usage: $0 [-v|-q] [-maketest]";
34 my $LastUnicodeCodepoint = 0x10FFFF; # As of Unicode 3.1.1.
37 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
38 # This file is built by $0 from e.g. UnicodeData.txt.
39 # Any changes made here will be lost!
45 ## Given a filename and a reference to an array of lines,
46 ## write the lines to the file only if the contents have not changed.
48 sub WriteIfChanged($\@)
53 my $TextToWrite = join '', @$lines;
56 my $PreviousText = <IN>;
58 if ($PreviousText eq $TextToWrite) {
59 print "$file unchanged.\n" if $Verbose;
63 if (not open OUT, ">$file") {
64 die "$0: can't open $file for output: $!\n";
66 print "$file written.\n" if $Verbose;
68 print OUT $TextToWrite;
73 ## The main datastructure (a "Table") represents a set of code points that
74 ## are part of a particular quality (that are part of \pL, \p{InGreek},
75 ## etc.). They are kept as ranges of code points (starting and ending of
78 ## For example, a range ASCII LETTERS would be represented as:
79 ## [ [ 0x41 => 0x5A, 'UPPER' ],
80 ## [ 0x61 => 0x7A, 'LOWER, ] ]
82 sub RANGE_START() { 0 } ## index into range element
83 sub RANGE_END() { 1 } ## index into range element
84 sub RANGE_NAME() { 2 } ## index into range element
86 ## Conceptually, these should really be folded into the 'Table' objects
94 ## Turn something like
103 $name =~ s/(?<![a-z])(\w)/\u$1/g;
104 $name =~ s/[-_\s]+//g;
106 $CanonicalToOrig{$name} = $orig if not $CanonicalToOrig{$name};
112 ## Store the alias definitions for later use.
123 ## Most of the work with aliases doesn't occur here,
124 ## but rather in utf8_heavy.pl, which uses utf8_pva.pl,
125 ## which contains just this function. However, this one
127 ## -- japhy (2004/04/13)
129 open PA, "< PropertyAliases.txt"
130 or confess "Can't open PropertyAliases.txt: $!";
136 my ($abbrev, $name) = split /\s*;\s*/;
137 next if $abbrev eq "n/a";
138 $PropertyAlias{$abbrev} = $name;
139 $PA_reverse{$name} = $abbrev;
143 open PVA, "< PropValueAliases.txt"
144 or confess "Can't open PropValueAliases.txt: $!";
150 my ($prop, @data) = split /\s*;\s*/;
152 if ($prop eq 'ccc') {
153 $PropValueAlias{$prop}{$data[1]} = [ @data[0,2] ];
154 $PVA_reverse{$prop}{$data[2]} = [ @data[0,1] ];
157 next if $data[0] eq "n/a";
158 $PropValueAlias{$prop}{$data[0]} = $data[1];
159 $PVA_reverse{$prop}{$data[1]} = $data[0];
167 ## Associates a property ("Greek", "Lu", "Assigned",...) with a Table.
170 ## New_Prop(In => 'Greek', $Table, Desc => 'Greek Block', Fuzzy => 1);
172 ## Normally, these parameters are set when the Table is created (when the
173 ## Table->New constructor is called), but there are times when it needs to
174 ## be done after-the-fact...)
178 my $Type = shift; ## "Is" or "In";
182 ## remaining args are optional key/val
185 my $Fuzzy = delete $Args{Fuzzy};
186 my $Desc = delete $Args{Desc}; # description
188 $Name = CanonicalName($Name) if $Fuzzy;
190 ## sanity check a few args
191 if (%Args or ($Type ne 'Is' and $Type ne 'In') or not ref $Table) {
192 confess "$0: bad args to New_Prop"
195 if (not $TableInfo{$Type}->{$Name})
197 $TableInfo{$Type}->{$Name} = $Table;
198 $TableDesc{$Type}->{$Name} = $Desc;
200 $FuzzyNames{$Type}->{$Name} = $Name;
207 ## Creates a new Table object.
209 ## Args are key/value pairs:
210 ## In => Name -- Name of "In" property to be associated with
211 ## Is => Name -- Name of "Is" property to be associated with
212 ## Fuzzy => Boolean -- True if name can be accessed "fuzzily"
213 ## Desc => String -- Description of the property
215 ## No args are required.
222 my $Table = bless [], $class;
224 my $Fuzzy = delete $Args{Fuzzy};
225 my $Desc = delete $Args{Desc};
227 for my $Type ('Is', 'In')
229 if (my $Name = delete $Args{$Type}) {
230 New_Prop($Type => $Name, $Table, Desc => $Desc, Fuzzy => $Fuzzy);
234 ## shouldn't have any left over
236 confess "$0: bad args to Table->New"
243 ## Returns true if the Table has no code points
247 my $Table = shift; #self
252 ## Returns true if the Table has code points
256 my $Table = shift; #self
261 ## Returns the maximum code point currently in the table.
265 my $Table = shift; #self
266 confess "oops" if $Table->IsEmpty; ## must have code points to have a max
267 return $Table->[-1]->[RANGE_END];
271 ## Replaces the codepoints in the Table with those in the Table given
272 ## as an arg. (NOTE: this is not a "deep copy").
274 sub Table::Replace($$)
276 my $Table = shift; #self
283 ## Given a new code point, make the last range of the Table extend to
284 ## include the new (and all intervening) code points.
288 my $Table = shift; #self
289 my $codepoint = shift;
291 my $PrevMax = $Table->Max;
293 confess "oops ($codepoint <= $PrevMax)" if $codepoint <= $PrevMax;
295 $Table->[-1]->[RANGE_END] = $codepoint;
299 ## Given a code point range start and end (and optional name), blindly
300 ## append them to the list of ranges for the Table.
302 ## NOTE: Code points must be added in strictly ascending numeric order.
304 sub Table::RawAppendRange
306 my $Table = shift; #self
310 $name = "" if not defined $name; ## warning: $name can be "0"
312 push @$Table, [ $start, # RANGE_START
314 $name ]; # RANGE_NAME
318 ## Given a code point (and optional name), add it to the Table.
320 ## NOTE: Code points must be added in strictly ascending numeric order.
324 my $Table = shift; #self
325 my $codepoint = shift;
327 $name = "" if not defined $name; ## warning: $name can be "0"
330 ## If we've already got a range working, and this code point is the next
331 ## one in line, and if the name is the same, just extend the current range.
335 $Table->Max == $codepoint - 1
337 $Table->[-1]->[RANGE_NAME] eq $name)
339 $Table->Extend($codepoint);
343 $Table->RawAppendRange($codepoint, $codepoint, $name);
348 ## Given a code point range starting value and ending value (and name),
349 ## Add the range to teh Table.
351 ## NOTE: Code points must be added in strictly ascending numeric order.
353 sub Table::AppendRange
355 my $Table = shift; #self
359 $name = "" if not defined $name; ## warning: $name can be "0"
361 $Table->Append($start, $name);
362 $Table->Extend($end) if $end > $start;
366 ## Return a new Table that represents all code points not in the Table.
370 my $Table = shift; #self
372 my $New = Table->New();
374 for my $range (@$Table)
376 my $start = $range->[RANGE_START];
377 my $end = $range->[RANGE_END];
378 if ($start-1 >= $max+1) {
379 $New->AppendRange($max+1, $start-1, "");
383 if ($max+1 < $LastUnicodeCodepoint) {
384 $New->AppendRange($max+1, $LastUnicodeCodepoint);
390 ## Merges any number of other tables with $self, returning the new table.
391 ## (existing tables are not modified)
394 ## Args may be Tables, or individual code points (as integers).
396 ## Can be called as either a constructor or a method.
400 shift(@_) if not ref $_[0]; ## if called as a constructor, lose the class
403 ## Accumulate all records from all tables
405 for my $Arg (@Tables)
408 ## arg is a table -- get its ranges
409 push @Records, @$Arg;
411 ## arg is a codepoint, make a range
412 push @Records, [ $Arg, $Arg ]
416 ## sort by range start, with longer ranges coming first.
417 my ($first, @Rest) = sort {
418 ($a->[RANGE_START] <=> $b->[RANGE_START])
420 ($b->[RANGE_END] <=> $b->[RANGE_END])
423 my $New = Table->New();
425 ## Ensuring the first range is there makes the subsequent loop easier
426 $New->AppendRange($first->[RANGE_START],
427 $first->[RANGE_END]);
429 ## Fold in records so long as they add new information.
432 my $start = $set->[RANGE_START];
433 my $end = $set->[RANGE_END];
434 if ($start > $New->Max) {
435 $New->AppendRange($start, $end);
436 } elsif ($end > $New->Max) {
445 ## Given a filename, write a representation of the Table to a file.
446 ## May have an optional comment as a 2nd arg.
450 my $Table = shift; #self
451 my $filename = shift;
455 if (defined $comment) {
456 $comment =~ s/\s+\Z//;
457 $comment =~ s/^/# /gm;
458 push @OUT, "#\n$comment\n#\n";
460 push @OUT, "return <<'END';\n";
462 for my $set (@$Table)
464 my $start = $set->[RANGE_START];
465 my $end = $set->[RANGE_END];
466 my $name = $set->[RANGE_NAME];
468 if ($start == $end) {
469 push @OUT, sprintf "%04X\t\t%s\n", $start, $name;
471 push @OUT, sprintf "%04X\t%04X\t%s\n", $start, $end, $name;
477 WriteIfChanged($filename, @OUT);
480 ## This used only for making the test script.
485 return 0 if $code <= 0x0000; ## don't use null
486 return 0 if $code >= $LastUnicodeCodepoint; ## keep in range
487 return 0 if ($code >= 0xD800 and $code <= 0xDFFF); ## no surrogates
488 return 0 if ($code >= 0xFDD0 and $code <= 0xFDEF); ## utf8.c says no good
489 return 0 if (($code & 0xFFFF) == 0xFFFE); ## utf8.c says no good
490 return 0 if (($code & 0xFFFF) == 0xFFFF); ## utf8.c says no good
494 ## Return a code point that's part of the table.
495 ## Returns nothing if the table is empty (or covers only surrogates).
496 ## This used only for making the test script.
499 my $Table = shift; #self
500 for my $set (@$Table) {
501 return $set->[RANGE_END] if IsUsable($set->[RANGE_END]);
506 ## Return a code point that's not part of the table
507 ## Returns nothing if the table covers all code points.
508 ## This used only for making the test script.
509 sub Table::InvalidCode
511 my $Table = shift; #self
513 return 0x1234 if $Table->IsEmpty();
515 for my $set (@$Table)
517 if (IsUsable($set->[RANGE_END] + 1))
519 return $set->[RANGE_END] + 1;
522 if (IsUsable($set->[RANGE_START] - 1))
524 return $set->[RANGE_START] - 1;
530 ###########################################################################
531 ###########################################################################
532 ###########################################################################
537 ## New_Alias(Is => 'All', SameAs => 'Any', Fuzzy => 1);
539 ## The args must be in that order, although the Fuzzy pair may be omitted.
541 ## This creates 'IsAll' as an alias for 'IsAny'
545 my $Type = shift; ## "Is" or "In"
547 my $SameAs = shift; # expecting "SameAs" -- just ignored
550 ## remaining args are optional key/val
553 my $Fuzzy = delete $Args{Fuzzy};
555 ## sanity check a few args
556 if (%Args or ($Type ne 'Is' and $Type ne 'In') or $SameAs ne 'SameAs') {
557 confess "$0: bad args to New_Alias"
560 $Alias = CanonicalName($Alias) if $Fuzzy;
562 if (not $TableInfo{$Type}->{$Name})
564 my $CName = CanonicalName($Name);
565 if ($TableInfo{$Type}->{$CName}) {
566 confess "$0: Use canonical form '$CName' instead of '$Name' for alias.";
568 confess "$0: don't have original $Type => $Name to make alias\n";
571 if ($TableInfo{$Alias}) {
572 confess "$0: already have original $Type => $Alias; can't make alias";
574 $AliasInfo{$Type}->{$Name} = $Alias;
576 $FuzzyNames{$Type}->{$Alias} = $Name;
582 ## All assigned code points
583 my $Assigned = Table->New(Is => 'Assigned',
584 Desc => "All assigned code points",
587 my $Name = Table->New(); ## all characters, individually by name
588 my $General = Table->New(); ## all characters, grouped by category
593 ## Process UnicodeData.txt (Categories, etc.)
595 sub UnicodeData_Txt()
597 my $Bidi = Table->New();
598 my $Deco = Table->New();
599 my $Comb = Table->New();
600 my $Number = Table->New();
601 my $Mirrored = Table->New();#Is => 'Mirrored',
602 #Desc => "Mirrored in bidirectional text",
608 $DC{can} = Table->New();
609 $DC{com} = Table->New();
611 ## Initialize Perl-generated categories
612 ## (Categories from UnicodeData.txt are auto-initialized in gencat)
614 Table->New(Is => 'Alnum', Desc => "[[:Alnum:]]", Fuzzy => 0);
616 Table->New(Is => 'Alpha', Desc => "[[:Alpha:]]", Fuzzy => 0);
618 Table->New(Is => 'ASCII', Desc => "[[:ASCII:]]", Fuzzy => 0);
620 Table->New(Is => 'Blank', Desc => "[[:Blank:]]", Fuzzy => 0);
622 Table->New(Is => 'Cntrl', Desc => "[[:Cntrl:]]", Fuzzy => 0);
624 Table->New(Is => 'Digit', Desc => "[[:Digit:]]", Fuzzy => 0);
626 Table->New(Is => 'Graph', Desc => "[[:Graph:]]", Fuzzy => 0);
628 Table->New(Is => 'Lower', Desc => "[[:Lower:]]", Fuzzy => 0);
630 Table->New(Is => 'Print', Desc => "[[:Print:]]", Fuzzy => 0);
632 Table->New(Is => 'Punct', Desc => "[[:Punct:]]", Fuzzy => 0);
634 Table->New(Is => 'Space', Desc => "[[:Space:]]", Fuzzy => 0);
636 Table->New(Is => 'Title', Desc => "[[:Title:]]", Fuzzy => 0);
638 Table->New(Is => 'Upper', Desc => "[[:Upper:]]", Fuzzy => 0);
640 Table->New(Is => 'XDigit', Desc => "[[:XDigit:]]", Fuzzy => 0);
642 Table->New(Is => 'Word', Desc => "[[:Word:]]", Fuzzy => 0);
644 Table->New(Is => 'SpacePerl', Desc => '\s', Fuzzy => 0);
647 $To{Upper} = Table->New();
648 $To{Lower} = Table->New();
649 $To{Title} = Table->New();
650 $To{Digit} = Table->New();
654 my ($name, ## Name ("LATIN CAPITAL LETTER A")
655 $cat, ## Category ("Lu", "Zp", "Nd", etc.)
656 $code, ## Code point (as an integer)
659 my $MajorCat = substr($cat, 0, 1); ## L, M, Z, S, etc
661 $Assigned->$op($code);
662 $Name->$op($code, $name);
663 $General->$op($code, $cat);
665 ## add to the sub category (e.g. "Lu", "Nd", "Cf", ..)
666 $Cat{$cat} ||= Table->New(Is => $cat,
667 Desc => "General Category '$cat'",
669 $Cat{$cat}->$op($code);
671 ## add to the major category (e.g. "L", "N", "C", ...)
672 $Cat{$MajorCat} ||= Table->New(Is => $MajorCat,
673 Desc => "Major Category '$MajorCat'",
675 $Cat{$MajorCat}->$op($code);
677 ($General{$name} ||= Table->New)->$op($code, $name);
679 # 005F: SPACING UNDERSCORE
680 $Cat{Word}->$op($code) if $cat =~ /^[LMN]|Pc/;
681 $Cat{Alnum}->$op($code) if $cat =~ /^[LM]|Nd/;
682 $Cat{Alpha}->$op($code) if $cat =~ /^[LM]/;
685 ($cat =~ /Zs|Zl|Zp/ &&
686 $code != 0x200B) # 200B is ZWSP which is for line break control
687 # and therefore it is not part of "space" even while it is "Zs".
688 || $code == 0x0009 # 0009: HORIZONTAL TAB
689 || $code == 0x000A # 000A: LINE FEED
690 || $code == 0x000B # 000B: VERTICAL TAB
691 || $code == 0x000C # 000C: FORM FEED
692 || $code == 0x000D # 000D: CARRIAGE RETURN
693 || $code == 0x0085 # 0085: NEL
697 $Cat{Space}->$op($code) if $isspace;
699 $Cat{SpacePerl}->$op($code) if $isspace
700 && $code != 0x000B; # Backward compat.
702 $Cat{Blank}->$op($code) if $isspace
703 && !($code == 0x000A ||
710 $Cat{Digit}->$op($code) if $cat eq "Nd";
711 $Cat{Upper}->$op($code) if $cat eq "Lu";
712 $Cat{Lower}->$op($code) if $cat eq "Ll";
713 $Cat{Title}->$op($code) if $cat eq "Lt";
714 $Cat{ASCII}->$op($code) if $code <= 0x007F;
715 $Cat{Cntrl}->$op($code) if $cat =~ /^C/;
716 my $isgraph = !$isspace && $cat !~ /Cc|Cs|Cn/;
717 $Cat{Graph}->$op($code) if $isgraph;
718 $Cat{Print}->$op($code) if $isgraph || $isspace;
719 $Cat{Punct}->$op($code) if $cat =~ /^P/;
721 $Cat{XDigit}->$op($code) if ($code >= 0x30 && $code <= 0x39) ## 0..9
722 || ($code >= 0x41 && $code <= 0x46) ## A..F
723 || ($code >= 0x61 && $code <= 0x66); ## a..f
726 ## open ane read file.....
727 if (not open IN, "UnicodeData.txt") {
728 die "$0: UnicodeData.txt: $!\n";
732 ## For building \p{_CombAbove} and \p{_CanonDCIJ}
734 my %_Above_HexCodes; ## Hexcodes for chars with $comb == 230 ("ABOVE")
736 my %CodeToDeco; ## Maps code to decomp. list for chars with first
737 ## decomp. char an "i" or "j" (for \p{_CanonDCIJ})
739 ## This is filled in as we go....
740 my $CombAbove = Table->New(Is => '_CombAbove',
741 Desc => '(for internal casefolding use)',
746 next unless /^[0-9A-Fa-f]+;/;
749 my ($hexcode, ## code point in hex (e.g. "0041")
750 $name, ## character name (e.g. "LATIN CAPITAL LETTER A")
751 $cat, ## category (e.g. "Lu")
752 $comb, ## Canonical combining class (e.t. "230")
753 $bidi, ## directional category (e.g. "L")
754 $deco, ## decomposition mapping
755 $decimal, ## decimal digit value
756 $digit, ## digit value
757 $number, ## numeric value
758 $mirrored, ## mirrored
759 $unicode10, ## name in Unicode 1.0
760 $comment, ## comment field
761 $upper, ## uppercase mapping
762 $lower, ## lowercase mapping
763 $title, ## titlecase mapping
764 ) = split(/\s*;\s*/);
766 # Note that in Unicode 3.2 there will be names like
767 # LINE FEED (LF), which probably means that \N{} needs
768 # to cope also with LINE FEED and LF.
769 $name = $unicode10 if $name eq '<control>' && $unicode10 ne '';
771 my $code = hex($hexcode);
773 if ($comb and $comb == 230) {
774 $CombAbove->Append($code);
775 $_Above_HexCodes{$hexcode} = 1;
778 ## Used in building \p{_CanonDCIJ}
779 if ($deco and $deco =~ m/^006[9A]\b/) {
780 $CodeToDeco{$code} = $deco;
784 ## There are a few pairs of lines like:
785 ## AC00;<Hangul Syllable, First>;Lo;0;L;;;;;N;;;;;
786 ## D7A3;<Hangul Syllable, Last>;Lo;0;L;;;;;N;;;;;
787 ## that define ranges.
789 if ($name =~ /^<(.+), (First|Last)>$/)
792 gencat($name, $cat, $code, $2 eq 'First' ? 'Append' : 'Extend');
793 #New_Prop(In => $name, $General{$name}, Fuzzy => 1);
797 ## normal (single-character) lines
798 gencat($name, $cat, $code, 'Append');
800 # No Append() here since since several codes may map into one.
801 $To{Upper}->RawAppendRange($code, $code, $upper) if $upper;
802 $To{Lower}->RawAppendRange($code, $code, $lower) if $lower;
803 $To{Title}->RawAppendRange($code, $code, $title) if $title;
804 $To{Digit}->Append($code, $decimal) if length $decimal;
806 $Bidi->Append($code, $bidi);
807 $Comb->Append($code, $comb) if $comb;
808 $Number->Append($code, $number) if length $number;
810 length($decimal) and ($Number{De} ||= Table->New())->Append($code)
812 length($digit) and ($Number{Di} ||= Table->New())->Append($code)
814 length($number) and ($Number{Nu} ||= Table->New())->Append($code);
816 $Mirrored->Append($code) if $mirrored eq "Y";
818 $Bidi{$bidi} ||= Table->New();#Is => "bt/$bidi",
819 #Desc => "Bi-directional category '$bidi'",
821 $Bidi{$bidi}->Append($code);
825 $Deco->Append($code, $deco);
826 if ($deco =~/^<(\w+)>/)
828 my $dshort = $PVA_reverse{dt}{ucfirst lc $1};
829 $DC{com}->Append($code);
831 $DC{$dshort} ||= Table->New();
832 $DC{$dshort}->Append($code);
836 $DC{can}->Append($code);
844 ## Tidy up a few special cases....
847 $Cat{Cn} = $Assigned->Invert; ## Cn is everything that doesn't exist
850 Desc => "General Category 'Cn' [not functional in Perl]",
853 ## Unassigned is the same as 'Cn'
854 New_Alias(Is => 'Unassigned', SameAs => 'Cn', Fuzzy => 0);
856 $Cat{C}->Replace($Cat{C}->Merge($Cat{Cn})); ## Now merge in Cn into C
859 # LC is Ll, Lu, and Lt.
860 # (used to be L& or L_, but PropValueAliases.txt defines it as LC)
862 Table->Merge(@Cat{qw[Ll Lu Lt]}),
863 Desc => '[\p{Ll}\p{Lu}\p{Lt}]',
866 ## Any and All are all code points.
867 my $Any = Table->New(Is => 'Any',
868 Desc => sprintf("[\\x{0000}-\\x{%X}]",
869 $LastUnicodeCodepoint),
871 $Any->RawAppendRange(0, $LastUnicodeCodepoint);
873 New_Alias(Is => 'All', SameAs => 'Any', Fuzzy => 0);
876 ## Build special properties for Perl's internal case-folding needs:
877 ## \p{_CaseIgnorable}
880 ## _CombAbove was built above. Others are built here....
883 ## \p{_CaseIgnorable} is [\p{Mn}\0x00AD\x2010]
884 New_Prop(Is => '_CaseIgnorable',
885 Table->Merge($Cat{Mn},
888 Desc => '(for internal casefolding use)',
892 ## \p{_CanonDCIJ} is fairly complex...
893 my $CanonCDIJ = Table->New(Is => '_CanonDCIJ',
894 Desc => '(for internal casefolding use)',
896 ## It contains the ASCII 'i' and 'j'....
897 $CanonCDIJ->Append(0x0069); # ASCII ord("i")
898 $CanonCDIJ->Append(0x006A); # ASCII ord("j")
899 ## ...and any character with a decomposition that starts with either of
900 ## those code points, but only if the decomposition does not have any
901 ## combining character with the "ABOVE" canonical combining class.
902 for my $code (sort { $a <=> $b} keys %CodeToDeco)
904 ## Need to ensure that all decomposition characters do not have
905 ## a %HexCodeToComb in %AboveCombClasses.
907 for my $deco_hexcode (split / /, $CodeToDeco{$code})
909 if (exists $_Above_HexCodes{$deco_hexcode}) {
910 ## one of the decmposition chars has an ABOVE combination
911 ## class, so we're not interested in this one
917 $CanonCDIJ->Append($code);
924 ## Now dump the files.
926 $Name->Write("Name.pl");
928 # $Bidi->Write("Bidirectional.pl");
929 mkdir("lib/bc", 0755);
933 "BidiClass category '$PropValueAlias{bc}{$_}'"
937 $Comb->Write("CombiningClass.pl");
938 mkdir("lib/ccc", 0755);
939 for (keys %{ $PropValueAlias{ccc} }) {
940 my ($code, $name) = @{ $PropValueAlias{ccc}{$_} };
941 (my $c = Table->New())->Append($code);
944 "CombiningClass category '$name'"
948 $Deco->Write("Decomposition.pl");
949 mkdir("lib/dt", 0755);
953 "DecompositionType category '$PropValueAlias{dt}{$_}'"
957 # $Number->Write("Number.pl");
958 mkdir("lib/nt", 0755);
962 "NumericType category '$PropValueAlias{nt}{$_}'"
966 # $General->Write("Category.pl");
968 for my $to (sort keys %To) {
969 $To{$to}->Write("To/$to.pl");
972 for (keys %{ $PropValueAlias{gc} }) {
973 New_Alias(Is => $PropValueAlias{gc}{$_}, SameAs => $_, Fuzzy => 1);
978 ## Process LineBreak.txt
982 if (not open IN, "LineBreak.txt") {
983 die "$0: LineBreak.txt: $!\n";
986 my $Lbrk = Table->New();
991 next unless /^([0-9A-Fa-f]+)(?:\.\.([0-9A-Fa-f]+))?\s*;\s*(\w+)/;
993 my ($first, $last, $lbrk) = (hex($1), hex($2||""), $3);
995 $Lbrk->Append($first, $lbrk);
997 $Lbrk{$lbrk} ||= Table->New();
998 $Lbrk{$lbrk}->Append($first);
1001 $Lbrk->Extend($last);
1002 $Lbrk{$lbrk}->Extend($last);
1007 # $Lbrk->Write("Lbrk.pl");
1009 mkdir("lib/lb", 0755);
1014 "Linebreak category '$PropValueAlias{lb}{$_}'"
1020 ## Process ArabicShaping.txt.
1022 sub ArabicShaping_txt()
1024 if (not open IN, "ArabicShaping.txt") {
1025 die "$0: ArabicShaping.txt: $!\n";
1028 my $ArabLink = Table->New();
1029 my $ArabLinkGroup = Table->New();
1035 next unless /^[0-9A-Fa-f]+;/;
1038 my ($hexcode, $name, $link, $linkgroup) = split(/\s*;\s*/);
1039 my $code = hex($hexcode);
1040 $ArabLink->Append($code, $link);
1041 $ArabLinkGroup->Append($code, $linkgroup);
1043 $JoinType{$link} ||= Table->New(Is => "JoinType$link");
1044 $JoinType{$link}->Append($code);
1048 # $ArabLink->Write("ArabLink.pl");
1049 # $ArabLinkGroup->Write("ArabLnkGrp.pl");
1051 mkdir("lib/jt", 0755);
1053 for (keys %JoinType) {
1054 $JoinType{$_}->Write(
1056 "JoiningType category '$PropValueAlias{jt}{$_}'"
1062 ## Process EastAsianWidth.txt.
1064 sub EastAsianWidth_txt()
1066 if (not open IN, "EastAsianWidth.txt") {
1067 die "$0: EastAsianWidth.txt: $!\n";
1074 next unless /^[0-9A-Fa-f]+;/;
1078 my ($hexcode, $pv) = split(/\s*;\s*/);
1079 my $code = hex($hexcode);
1080 $EAW{$pv} ||= Table->New(Is => "EastAsianWidth$pv");
1081 $EAW{$pv}->Append($code);
1085 mkdir("lib/ea", 0755);
1090 "EastAsianWidth category '$PropValueAlias{ea}{$_}'"
1096 ## Process HangulSyllableType.txt.
1098 sub HangulSyllableType_txt()
1100 if (not open IN, "HangulSyllableType.txt") {
1101 die "$0: HangulSyllableType.txt: $!\n";
1108 next unless /^([0-9A-Fa-f]+)(?:\.\.([0-9A-Fa-f]+))?\s*;\s*(\w+)/;
1109 my ($first, $last, $pv) = (hex($1), hex($2||""), $3);
1111 $HST{$pv} ||= Table->New(Is => "HangulSyllableType$pv");
1112 $HST{$pv}->Append($first);
1114 if ($last) { $HST{$pv}->Extend($last) }
1118 mkdir("lib/hst", 0755);
1123 "HangulSyllableType category '$PropValueAlias{hst}{$_}'"
1129 ## Process Jamo.txt.
1133 if (not open IN, "Jamo.txt") {
1134 die "$0: Jamo.txt: $!\n";
1136 my $Short = Table->New();
1140 next unless /^([0-9A-Fa-f]+)\s*;\s*(\w*)/;
1141 my ($code, $short) = (hex($1), $2);
1143 $Short->Append($code, $short);
1146 # $Short->Write("JamoShort.pl");
1150 ## Process Scripts.txt.
1156 if (not open(IN, "Scripts.txt")) {
1157 die "$0: Scripts.txt: $!\n";
1160 next unless /^([0-9A-Fa-f]+)(?:\.\.([0-9A-Fa-f]+))?\s*;\s*(.+?)\s*\#/;
1162 # Wait until all the scripts have been read since
1163 # they are not listed in numeric order.
1164 push @ScriptInfo, [ hex($1), hex($2||""), $3 ];
1168 # Now append the scripts properties in their code point order.
1171 my $Scripts = Table->New();
1173 for my $script (sort { $a->[0] <=> $b->[0] } @ScriptInfo)
1175 my ($first, $last, $name) = @$script;
1176 $Scripts->Append($first, $name);
1178 $Script{$name} ||= Table->New(Is => $name,
1179 Desc => "Script '$name'",
1181 $Script{$name}->Append($first, $name);
1184 $Scripts->Extend($last);
1185 $Script{$name}->Extend($last);
1189 # $Scripts->Write("Scripts.pl");
1191 ## Common is everything not explicitly assigned to a Script
1193 ## ***shouldn't this be intersected with \p{Assigned}? ******
1195 New_Prop(Is => 'Common',
1197 Desc => 'Pseudo-Script of codepoints not in other Unicode scripts',
1202 ## Given a name like "Close Punctuation", return a regex (that when applied
1203 ## with /i) matches any valid form of that name (e.g. "ClosePunctuation",
1204 ## "Close-Punctuation", etc.)
1206 ## Accept any space, dash, or underbar where in the official name there is
1207 ## space or a dash (or underbar, but there never is).
1213 $Name =~ s/[- _]/(?:[-_]|\\s+)?/g;
1218 ## Process Blocks.txt.
1222 my $Blocks = Table->New();
1225 if (not open IN, "Blocks.txt") {
1226 die "$0: Blocks.txt: $!\n";
1231 #next if not /Private Use$/;
1232 next if not /^([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+)\s*;\s*(.+?)\s*$/;
1234 my ($first, $last, $name) = (hex($1), hex($2), $3);
1236 $Blocks->Append($first, $name);
1238 $Blocks{$name} ||= Table->New(In => $name,
1239 Desc => "Block '$name'",
1241 $Blocks{$name}->Append($first, $name);
1243 if ($last and $last != $first) {
1244 $Blocks->Extend($last);
1245 $Blocks{$name}->Extend($last);
1250 # $Blocks->Write("Blocks.pl");
1254 ## Read in the PropList.txt. It contains extended properties not
1255 ## listed in the UnicodeData.txt, such as 'Other_Alphabetic':
1256 ## alphabetic but not of the general category L; many modifiers
1257 ## belong to this extended property category: while they are not
1258 ## alphabets, they are alphabetic in nature.
1264 if (not open IN, "PropList.txt") {
1265 die "$0: PropList.txt: $!\n";
1270 next unless /^([0-9A-Fa-f]+)(?:\.\.([0-9A-Fa-f]+))?\s*;\s*(.+?)\s*\#/;
1272 # Wait until all the extended properties have been read since
1273 # they are not listed in numeric order.
1274 push @PropInfo, [ hex($1), hex($2||""), $3 ];
1278 # Now append the extended properties in their code point order.
1279 my $Props = Table->New();
1282 for my $prop (sort { $a->[0] <=> $b->[0] } @PropInfo)
1284 my ($first, $last, $name) = @$prop;
1285 $Props->Append($first, $name);
1287 $Prop{$name} ||= Table->New(Is => $name,
1288 Desc => "Extended property '$name'",
1290 $Prop{$name}->Append($first, $name);
1293 $Props->Extend($last);
1294 $Prop{$name}->Extend($last);
1299 (my $file = $PA_reverse{$_}) =~ tr/_//d;
1301 "lib/gc_sc/$file.pl",
1302 "Binary property '$_'"
1306 # Alphabetic is L and Other_Alphabetic.
1307 New_Prop(Is => 'Alphabetic',
1308 Table->Merge($Cat{L}, $Prop{Other_Alphabetic}),
1309 Desc => '[\p{L}\p{OtherAlphabetic}]', # use canonical names here
1312 # Lowercase is Ll and Other_Lowercase.
1313 New_Prop(Is => 'Lowercase',
1314 Table->Merge($Cat{Ll}, $Prop{Other_Lowercase}),
1315 Desc => '[\p{Ll}\p{OtherLowercase}]', # use canonical names here
1318 # Uppercase is Lu and Other_Uppercase.
1319 New_Prop(Is => 'Uppercase',
1320 Table->Merge($Cat{Lu}, $Prop{Other_Uppercase}),
1321 Desc => '[\p{Lu}\p{Other_Uppercase}]', # use canonical names here
1324 # Math is Sm and Other_Math.
1325 New_Prop(Is => 'Math',
1326 Table->Merge($Cat{Sm}, $Prop{Other_Math}),
1327 Desc => '[\p{Sm}\p{OtherMath}]', # use canonical names here
1330 # ID_Start is Ll, Lu, Lt, Lm, Lo, and Nl.
1331 New_Prop(Is => 'ID_Start',
1332 Table->Merge(@Cat{qw[Ll Lu Lt Lm Lo Nl]}),
1333 Desc => '[\p{Ll}\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{Nl}]',
1336 # ID_Continue is ID_Start, Mn, Mc, Nd, and Pc.
1337 New_Prop(Is => 'ID_Continue',
1338 Table->Merge(@Cat{qw[Ll Lu Lt Lm Lo Nl Mn Mc Nd Pc ]}),
1339 Desc => '[\p{ID_Start}\p{Mn}\p{Mc}\p{Nd}\p{Pc}]',
1345 ## These are used in:
1346 ## MakePropTestScript()
1347 ## WriteAllMappings()
1348 ## for making the test script.
1350 my %FuzzyNameToTest;
1351 my %ExactNameToTest;
1354 ## This used only for making the test script
1359 my $MatchCode = shift;
1360 my $FailCode = shift;
1362 if (defined $MatchCode) {
1363 printf $FH qq/Expect(1, "\\x{%04X}", '\\p{$Prop}' );\n/, $MatchCode;
1364 printf $FH qq/Expect(0, "\\x{%04X}", '\\p{^$Prop}');\n/, $MatchCode;
1365 printf $FH qq/Expect(0, "\\x{%04X}", '\\P{$Prop}' );\n/, $MatchCode;
1366 printf $FH qq/Expect(1, "\\x{%04X}", '\\P{^$Prop}');\n/, $MatchCode;
1368 if (defined $FailCode) {
1369 printf $FH qq/Expect(0, "\\x{%04X}", '\\p{$Prop}' );\n/, $FailCode;
1370 printf $FH qq/Expect(1, "\\x{%04X}", '\\p{^$Prop}');\n/, $FailCode;
1371 printf $FH qq/Expect(1, "\\x{%04X}", '\\P{$Prop}' );\n/, $FailCode;
1372 printf $FH qq/Expect(0, "\\x{%04X}", '\\P{^$Prop}');\n/, $FailCode;
1376 ## This used only for making the test script
1382 print $FH qq/Error('\\p{$prop}');\n/;
1383 print $FH qq/Error('\\P{$prop}');\n/;
1386 ## This used only for making the test script
1402 ## This used only for making the test script
1403 sub RandomlyFuzzifyName($;$)
1406 my $WantError = shift; ## if true, make an error
1409 for my $part (split /[-\s_]+/, $Name)
1412 if ($WantError and rand() < 0.3) {
1413 push @parts, $BadSeps[rand(@BadSeps)];
1416 push @parts, $GoodSeps[rand(@GoodSeps)];
1419 my $switch = int rand(4);
1421 push @parts, uc $part;
1422 } elsif ($switch == 1) {
1423 push @parts, lc $part;
1424 } elsif ($switch == 2) {
1425 push @parts, ucfirst $part;
1430 my $new = join('', @parts);
1433 if (rand() >= 0.5) {
1434 $new .= $BadSeps[rand(@BadSeps)];
1436 $new = $BadSeps[rand(@BadSeps)] . $new;
1442 ## This used only for making the test script
1443 sub MakePropTestScript()
1445 ## this written directly -- it's huge.
1446 if (not open OUT, ">TestProp.pl") {
1447 die "$0: TestProp.pl: $!\n";
1451 while (my ($Name, $Table) = each %ExactNameToTest)
1453 GenTests(*OUT, $Name, $Table->ValidCode, $Table->InvalidCode);
1454 ExpectError(*OUT, uc $Name) if uc $Name ne $Name;
1455 ExpectError(*OUT, lc $Name) if lc $Name ne $Name;
1459 while (my ($Name, $Table) = each %FuzzyNameToTest)
1461 my $Orig = $CanonicalToOrig{$Name};
1465 RandomlyFuzzifyName($Orig) => 1
1468 for my $N (keys %Names) {
1469 GenTests(*OUT, $N, $Table->ValidCode, $Table->InvalidCode);
1472 ExpectError(*OUT, RandomlyFuzzifyName($Orig, 'ERROR'));
1475 print OUT "Finished();\n";
1481 ## These are used only in:
1482 ## RegisterFileForName()
1483 ## WriteAllMappings()
1485 my %Exact; ## will become %utf8::Exact;
1486 my %Canonical; ## will become %utf8::Canonical;
1487 my %CaComment; ## Comment for %Canonical entry of same key
1490 ## Given info about a name and a datafile that it should be associated with,
1491 ## register that assocation in %Exact and %Canonical.
1492 sub RegisterFileForName($$$$)
1496 my $IsFuzzy = shift;
1497 my $filename = shift;
1500 ## Now in details for the mapping. $Type eq 'Is' has the
1501 ## Is removed, as it will be removed in utf8_heavy when this
1502 ## data is being checked. In keeps its "In", but a second
1503 ## sans-In record is written if it doesn't conflict with
1504 ## anything already there.
1508 if ($Type eq 'Is') {
1509 die "oops[$Name]" if $Exact{$Name};
1510 $Exact{$Name} = $filename;
1512 die "oops[$Type$Name]" if $Exact{"$Type$Name"};
1513 $Exact{"$Type$Name"} = $filename;
1514 $Exact{$Name} = $filename if not $Exact{$Name};
1519 my $CName = lc $Name;
1520 if ($Type eq 'Is') {
1521 die "oops[$CName]" if $Canonical{$CName};
1522 $Canonical{$CName} = $filename;
1523 $CaComment{$CName} = $Name if $Name =~ tr/A-Z// >= 2;
1525 die "oops[$Type$CName]" if $Canonical{lc "$Type$CName"};
1526 $Canonical{lc "$Type$CName"} = $filename;
1527 $CaComment{lc "$Type$CName"} = "$Type$Name";
1528 if (not $Canonical{$CName}) {
1529 $Canonical{$CName} = $filename;
1530 $CaComment{$CName} = "$Type$Name";
1537 ## Writes the info accumulated in
1544 sub WriteAllMappings()
1548 my %BaseNames; ## Base names already used (for avoiding 8.3 conflicts)
1550 ## 'Is' *MUST* come first, so its names have precidence over 'In's
1551 for my $Type ('Is', 'In')
1553 my %RawNameToFile; ## a per-$Type cache
1555 for my $Name (sort {length $a <=> length $b} keys %{$TableInfo{$Type}})
1557 ## Note: $Name is already canonical
1558 my $Table = $TableInfo{$Type}->{$Name};
1559 my $IsFuzzy = $FuzzyNames{$Type}->{$Name};
1561 ## Need an 8.3 safe filename (which means "an 8 safe" $filename)
1564 ## 'Is' items lose 'Is' from the basename.
1565 $filename = $Type eq 'Is' ?
1566 ($PVA_reverse{sc}{$Name} || $Name) :
1569 $filename =~ s/[^\w_]+/_/g; # "L&" -> "L_"
1570 substr($filename, 8) = '' if length($filename) > 8;
1573 ## Make sure the basename doesn't conflict with something we
1574 ## might have already written. If we have, say,
1581 while (my $num = $BaseNames{lc $filename}++)
1583 $num++; ## so basenames with numbers start with '2', which
1584 ## just looks more natural.
1585 ## Want to append $num, but if it'll make the basename longer
1586 ## than 8 characters, pre-truncate $filename so that the result
1588 my $delta = length($filename) + length($num) - 8;
1590 substr($filename, -$delta) = $num;
1598 ## Construct a nice comment to add to the file, and build data
1599 ## for the "./Properties" file along the way.
1603 my $Desc = $TableDesc{$Type}->{$Name} || "";
1604 ## get list of names this table is reference by
1605 my @Supported = $Name;
1606 while (my ($Orig, $Alias) = each %{ $AliasInfo{$Type} })
1608 if ($Orig eq $Name) {
1609 push @Supported, $Alias;
1613 my $TypeToShow = $Type eq 'Is' ? "" : $Type;
1616 $Comment = "This file supports:\n";
1617 for my $N (@Supported)
1619 my $IsFuzzy = $FuzzyNames{$Type}->{$N};
1620 my $Prop = "\\p{$TypeToShow$Name}";
1621 $OrigProp = $Prop if not $OrigProp; #cache for aliases
1623 $Comment .= "\t$Prop (and fuzzy permutations)\n";
1625 $Comment .= "\t$Prop\n";
1627 my $MyDesc = ($N eq $Name) ? $Desc : "Alias for $OrigProp ($Desc)";
1629 push @MAP, sprintf("%s %-42s %s\n",
1630 $IsFuzzy ? '*' : ' ', $Prop, $MyDesc);
1633 $Comment .= "\nMeaning: $Desc\n";
1638 ## Okay, write the file...
1640 $Table->Write("lib/gc_sc/$filename.pl", $Comment);
1643 $RawNameToFile{$Name} = $filename;
1644 RegisterFileForName($Type => $Name, $IsFuzzy, $filename);
1648 my $CName = CanonicalName($Type . '_'. $Name);
1649 $FuzzyNameToTest{$Name} = $Table if !$FuzzyNameToTest{$Name};
1650 $FuzzyNameToTest{$CName} = $Table if !$FuzzyNameToTest{$CName};
1652 $ExactNameToTest{$Name} = $Table;
1657 ## Register aliase info
1658 for my $Name (sort {length $a <=> length $b} keys %{$AliasInfo{$Type}})
1660 my $Alias = $AliasInfo{$Type}->{$Name};
1661 my $IsFuzzy = $FuzzyNames{$Type}->{$Alias};
1662 my $filename = $RawNameToFile{$Name};
1663 die "oops [$Alias]->[$Name]" if not $filename;
1664 RegisterFileForName($Type => $Alias, $IsFuzzy, $filename);
1666 my $Table = $TableInfo{$Type}->{$Name};
1667 die "oops" if not $Table;
1670 my $CName = CanonicalName($Type .'_'. $Alias);
1671 $FuzzyNameToTest{$Alias} = $Table if !$FuzzyNameToTest{$Alias};
1672 $FuzzyNameToTest{$CName} = $Table if !$FuzzyNameToTest{$CName};
1674 $ExactNameToTest{$Alias} = $Table;
1680 ## Write out the property list
1685 "## This file created by $0\n",
1686 "## List of built-in \\p{...}/\\P{...} properties.\n",
1688 "## '*' means name may be 'fuzzy'\n",
1690 sort { substr($a,2) cmp substr($b, 2) } @MAP,
1692 WriteIfChanged('Properties', @OUT);
1695 use Text::Tabs (); ## using this makes the files about half the size
1702 "## Data in this file used by ../utf8_heavy.pl\n",
1704 "## Mapping from name to filename in ./lib/gc_sc\n",
1705 "%utf8::Exact = (\n",
1708 $Exact{InGreek} = 'InGreekA'; # this is evil kludge
1709 for my $Name (sort keys %Exact)
1711 my $File = $Exact{$Name};
1712 $Name = $Name =~ m/\W/ ? qq/'$Name'/ : " $Name ";
1713 my $Text = sprintf("%-15s => %s,\n", $Name, qq/'$File'/);
1714 push @OUT, Text::Tabs::unexpand($Text);
1716 push @OUT, ");\n1;\n";
1718 WriteIfChanged('Exact.pl', @OUT);
1721 ## Write Canonical.pl
1726 "## Data in this file used by ../utf8_heavy.pl\n",
1728 "## Mapping from lc(canonical name) to filename in ./lib\n",
1729 "%utf8::Canonical = (\n",
1731 my $Trail = ""; ## used just to keep the spacing pretty
1732 for my $Name (sort keys %Canonical)
1734 my $File = $Canonical{$Name};
1735 if ($CaComment{$Name}) {
1736 push @OUT, "\n" if not $Trail;
1737 push @OUT, " # $CaComment{$Name}\n";
1742 $Name = $Name =~ m/\W/ ? qq/'$Name'/ : " $Name ";
1743 my $Text = sprintf(" %-41s => %s,\n$Trail", $Name, qq/'$File'/);
1744 push @OUT, Text::Tabs::unexpand($Text);
1746 push @OUT, ");\n1\n";
1747 WriteIfChanged('Canonical.pl', @OUT);
1750 MakePropTestScript() if $MakeTestScript;
1754 sub SpecialCasing_txt()
1757 # Read in the special cases.
1762 if (not open IN, "SpecialCasing.txt") {
1763 die "$0: SpecialCasing.txt: $!\n";
1766 next unless /^[0-9A-Fa-f]+;/;
1770 my ($code, $lower, $title, $upper, $condition) = split(/\s*;\s*/);
1772 if ($condition) { # not implemented yet
1773 print "# SKIPPING $_\n" if $Verbose;
1777 # Wait until all the special cases have been read since
1778 # they are not listed in numeric order.
1779 my $ix = hex($code);
1780 push @{$CaseInfo{Lower}}, [ $ix, $code, $lower ]
1781 unless $code eq $lower;
1782 push @{$CaseInfo{Title}}, [ $ix, $code, $title ]
1783 unless $code eq $title;
1784 push @{$CaseInfo{Upper}}, [ $ix, $code, $upper ]
1785 unless $code eq $upper;
1789 # Now write out the special cases properties in their code point order.
1790 # Prepend them to the To/{Upper,Lower,Title}.pl.
1792 for my $case (qw(Lower Title Upper))
1794 my $NormalCase = do "To/$case.pl" || die "$0: $@\n";
1799 "# The key UTF-8 _bytes_, the value UTF-8 (speed hack)\n",
1800 "%utf8::ToSpec$case =\n(\n",
1803 for my $prop (sort { $a->[0] <=> $b->[0] } @{$CaseInfo{$case}}) {
1804 my ($ix, $code, $to) = @$prop;
1806 join "", map { sprintf "\\x{%s}", $_ } split ' ', $to;
1807 push @OUT, sprintf qq["%s" => "$tostr",\n], join("", map { sprintf "\\x%02X", $_ } unpack("U0C*", pack("U", $ix)));
1808 # Remove any single-character mappings for
1809 # the same character since we are going for
1810 # the special casing rules.
1811 $NormalCase =~ s/^$code\t\t\w+\n//m;
1815 "return <<'END';\n",
1819 WriteIfChanged("To/$case.pl", @OUT);
1824 # Read in the case foldings.
1826 # We will do full case folding, C + F + I (see CaseFolding.txt).
1828 sub CaseFolding_txt()
1830 if (not open IN, "CaseFolding.txt") {
1831 die "$0: CaseFolding.txt: $!\n";
1834 my $Fold = Table->New();
1838 # Skip status 'S', simple case folding
1839 next unless /^([0-9A-Fa-f]+)\s*;\s*([CFI])\s*;\s*([0-9A-Fa-f]+(?: [0-9A-Fa-f]+)*)\s*;/;
1841 my ($code, $status, $fold) = (hex($1), $2, $3);
1843 if ($status eq 'C') { # Common: one-to-one folding
1844 # No append() since several codes may fold into one.
1845 $Fold->RawAppendRange($code, $code, $fold);
1846 } else { # F: full, or I: dotted uppercase I -> dotless lowercase I
1847 $Fold{$code} = $fold;
1852 $Fold->Write("To/Fold.pl");
1855 # Prepend the special foldings to the common foldings.
1857 my $CommonFold = do "To/Fold.pl" || die "$0: To/Fold.pl: $!\n";
1862 "# The ke UTF-8 _bytes_, the value UTF-8 (speed hack)\n",
1863 "%utf8::ToSpecFold =\n(\n",
1865 for my $code (sort { $a <=> $b } keys %Fold) {
1867 join "", map { sprintf "\\x{%s}", $_ } split ' ', $Fold{$code};
1868 push @OUT, sprintf qq["%s" => "$foldstr",\n], join("", map { sprintf "\\x%02X", $_ } unpack("U0C*", pack("U", $code)));
1872 "return <<'END';\n",
1877 WriteIfChanged("To/Fold.pl", @OUT);
1892 ArabicShaping_txt();
1893 EastAsianWidth_txt();
1894 HangulSyllableType_txt();
1896 SpecialCasing_txt();
1901 ## TRAILING CODE IS USED BY MakePropTestScript()
1914 my $Line = (caller)[2];
1919 $RegObj = qr/$Regex/;
1920 $String =~ $RegObj ? 1 : 0
1923 if (not defined $result) {
1924 print "couldn't compile /$Regex/ on $0 line $Line: $@\n";
1926 } elsif ($result ^ $Expect) {
1927 print "bad result (expected $Expect) on $0 line $Line: $@\n";
1936 if (eval { 'x' =~ qr/$Regex/; 1 }) {
1938 my $Line = (caller)[2];
1939 print "expected error for /$Regex/ on $0 line $Line: $@\n";
1946 print "All $Tests tests passed.\n";
1949 print "$Tests tests, $Fails failed!\n";