From a03f0b9fc88f383466124c0fba3dd41d5c76b99e Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 4 Oct 2011 11:58:52 -0600 Subject: [PATCH] Use newly created Name.pm file Name.pm has been populated in an earlier commit. This removes the now redundant information in Name.pl, and changes charnames to include the new Name.pm --- lib/charnames.pm | 9 +- lib/unicore/mktables | 244 ++------------------------------------------------- 2 files changed, 12 insertions(+), 241 deletions(-) diff --git a/lib/charnames.pm b/lib/charnames.pm index f3894f1..d88ede0 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -2,7 +2,8 @@ package charnames; use strict; use warnings; use File::Spec; -our $VERSION = '1.23'; +our $VERSION = '1.24'; +use unicore::Name; # mktables-generated algorithmically-defined names use bytes (); # for $bytes::hint_bits @@ -12,9 +13,9 @@ use bytes (); # for $bytes::hint_bits # lib/unicore/Name.pl which is read in as a large string (almost 3/4 Mb in # Unicode 6.0). Each code point/name combination is separated by a \n in the # string. (Some of the CJK and the Hangul syllable names are determined -# instead algorithmically via subroutines also stored in Name.pl). Because of -# the large size of this table, it isn't converted into hashes for faster -# lookup. +# instead algorithmically via subroutines stored instead in +# lib/unicore/Name.pm). Because of the large size of this table, it isn't +# converted into hashes for faster lookup. # # But, user defined aliases are stored in their own hashes, as are Perl # extensions to the official names. These are checked first before looking at diff --git a/lib/unicore/mktables b/lib/unicore/mktables index b2c06dd..a9b82bf 100644 --- a/lib/unicore/mktables +++ b/lib/unicore/mktables @@ -6091,243 +6091,6 @@ END $pre_body .= join("\n", @multi_code_point_maps) . "\n);\n"; } - # 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. - my $format = $self->format; my $return = <add_comment(join_lines( <