From 0f6f7bc2429cb650be08dc33216fc4f347559a14 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 4 Oct 2011 12:14:07 -0600 Subject: [PATCH] mktables: Copy code to new location. This is simply a straight copy of code that currently gets put into Name.pl into the subroutine that creates Name.pm. The only other change is to define and set $pre_body to the empty string, so that this code will compile in the new place, but the results are discarded. --- lib/unicore/mktables | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) diff --git a/lib/unicore/mktables b/lib/unicore/mktables index 3d7760f..27cdc2b 100644 --- a/lib/unicore/mktables +++ b/lib/unicore/mktables @@ -13908,6 +13908,243 @@ sub make_Name_pm () { $HEADER $INTERNAL_ONLY END + my $pre_body = ""; + # Only write out to files that need them + if (($has_hangul_syllables || @code_points_ending_in_code_point) + && ($self->property == $perl_charname + ||$self->property == main::property_ref('Name'))) + { + + # Convert these structures to output format. + my $code_points_ending_in_code_point = + main::simple_dumper(\@code_points_ending_in_code_point, + ' ' x 8); + my $names = main::simple_dumper(\%names_ending_in_code_point, + ' ' x 8); + my $loose_names = main::simple_dumper(\%loose_names_ending_in_code_point, + ' ' x 8); + + # Do the same with the Hangul names, + my $jamo; + my $jamo_l; + my $jamo_v; + my $jamo_t; + my $jamo_re; + if ($has_hangul_syllables) { + + # Construct a regular expression of all the possible + # combinations of the Hangul syllables. + my @L_re; # Leading consonants + for my $i ($LBase .. $LBase + $LCount - 1) { + push @L_re, $Jamo{$i} + } + my @V_re; # Middle vowels + for my $i ($VBase .. $VBase + $VCount - 1) { + push @V_re, $Jamo{$i} + } + my @T_re; # Trailing consonants + for my $i ($TBase + 1 .. $TBase + $TCount - 1) { + push @T_re, $Jamo{$i} + } + + # The whole re is made up of the L V T combination. + $jamo_re = '(' + . join ('|', sort @L_re) + . ')(' + . join ('|', sort @V_re) + . ')(' + . join ('|', sort @T_re) + . ')?'; + + # These hashes needed by the algorithm were generated + # during reading of the Jamo.txt file + $jamo = main::simple_dumper(\%Jamo, ' ' x 8); + $jamo_l = main::simple_dumper(\%Jamo_L, ' ' x 8); + $jamo_v = main::simple_dumper(\%Jamo_V, ' ' x 8); + $jamo_t = main::simple_dumper(\%Jamo_T, ' ' x 8); + } + + $pre_body .= <{$base}; + + # Look through the list of ranges that apply to this name to see if + # the code point is in one of them. + for (my $i = 0; $i < scalar @{$names_ref->{$base}{'low'}}; $i++) { + return if $names_ref->{$base}{'low'}->[$i] > $code_point; + next if $names_ref->{$base}{'high'}->[$i] < $code_point; + + # Here, the code point is in the range. + return $code_point; + } + + # Here, looked like the name had a code point number in it, but + # did not match one of the valid ones. + return; + } + + sub code_point_to_name_special { + my $code_point = shift; + + # Returns the name of a code point if algorithmically determinable; + # undef if not +END + if ($has_hangul_syllables) { + $pre_body .= << 'END'; + + # If in the Hangul range, calculate the name based on Unicode's + # algorithm + if ($code_point >= $SBase && $code_point <= $SBase + $SCount -1) { + use integer; + my $SIndex = $code_point - $SBase; + my $L = $LBase + $SIndex / $NCount; + my $V = $VBase + ($SIndex % $NCount) / $TCount; + my $T = $TBase + $SIndex % $TCount; + $name = "$HANGUL_SYLLABLE$Jamo{$L}$Jamo{$V}"; + $name .= $Jamo{$T} if $T != $TBase; + return $name; + } +END + } + $pre_body .= << 'END'; + + # Look through list of these code points for one in range. + foreach my $hash (@code_points_ending_in_code_point) { + return if $code_point < $hash->{'low'}; + if ($code_point <= $hash->{'high'}) { + return sprintf("%s-%04X", $hash->{'name'}, $code_point); + } + } + return; # None found + } +} # End closure + +END + } # End of has hangul or code point in name maps. main::write("Name.pm", 0, \@name); # The 0 means no utf8. return; -- 2.7.4