Skip to content

Commit 2709761

Browse files
committed
regen/mk_invlists.pl: Add \p{nv=float} data
The previous commit revised how nv=float is handled. This commit adds data for handling that to charclass_invlists.h, so that the next commit can use that and avoid swash creation.
1 parent 0426f63 commit 2709761

File tree

3 files changed

+6631
-6514
lines changed

3 files changed

+6631
-6514
lines changed

charclass_invlists.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374327,5 +374327,5 @@ static const U8 WB_table[24][24] = {
374327374327
* 21653d2744fdd071f9ef138c805393901bb9547cf3e777ebf50215a191f986ea lib/unicore/version
374328374328
* 4bb677187a1a64e39d48f2e341b5ecb6c99857e49d7a79cf503bd8a3c709999b regen/charset_translations.pl
374329374329
* 03e51b0f07beebd5da62ab943899aa4934eee1f792fa27c1fb638c33bf4ac6ea regen/mk_PL_charclass.pl
374330-
* 73aac899bb14ca992caa3ecbcc4206aff28ba64bd60da565bd32f268df5dbdc7 regen/mk_invlists.pl
374330+
* fc8aa04d5de962f6debe46edbdef7fe4402bf9a3ad199c199c44cf1b08b20c79 regen/mk_invlists.pl
374331374331
* ex: set ro: */

regen/mk_invlists.pl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,27 @@ ($)
21892189
my @deprecated_messages = ""; # Element [0] is a placeholder
21902190
my %deprecated_tags;
21912191

2192+
my $float_e_format = qr/ ^ -? \d \. \d+ e [-+] \d+ $ /x;
2193+
2194+
# Create another hash that maps floating point x.yyEzz representation to what
2195+
# %stricter_to_file_of does for the equivalent rational. A typical entry in
2196+
# the latter hash is
2197+
#
2198+
# 'nv=1/2' => 'Nv/1_2',
2199+
#
2200+
# From that, this loop creates an entry
2201+
#
2202+
# 'nv=5.00e-01' => 'Nv/1_2',
2203+
#
2204+
# %stricter_to_file_of contains far more than just the rationals. Instead we
2205+
# use %utf8::nv_floating_to_rational which should have an entry for each
2206+
# nv in the former hash.
2207+
my %floating_to_file_of;
2208+
foreach my $key (keys %utf8::nv_floating_to_rational) {
2209+
my $value = $utf8::nv_floating_to_rational{$key};
2210+
$floating_to_file_of{$key} = $utf8::stricter_to_file_of{"nv=$value"};
2211+
}
2212+
21922213
# Collect all the binary properties from data in lib/unicore
21932214
# Sort so that complements come after the main table, and the shortest
21942215
# names first, finally alphabetically. Also, sort together the tables we want
@@ -2198,23 +2219,29 @@ ($)
21982219
{ exists $keep_together{lc $b} <=> exists $keep_together{lc $a}
21992220
or $b =~ /posix/i <=> $a =~ /posix/i
22002221
or $b =~ /perl/i <=> $a =~ /perl/i
2222+
or $a =~ $float_e_format <=> $b =~ $float_e_format
22012223
or $a =~ /!/ <=> $b =~ /!/
22022224
or length $a <=> length $b
22032225
or $a cmp $b
22042226
} keys %utf8::loose_to_file_of,
2205-
keys %utf8::stricter_to_file_of
2227+
keys %utf8::stricter_to_file_of,
2228+
keys %floating_to_file_of
22062229
) {
22072230

22082231
# These two hashes map properties to values that can be considered to
22092232
# be checksums. If two properties have the same checksum, they have
22102233
# identical entries. Otherwise they differ in some way.
22112234
my $tag = $utf8::loose_to_file_of{$property};
22122235
$tag = $utf8::stricter_to_file_of{$property} unless defined $tag;
2236+
$tag = $floating_to_file_of{$property} unless defined $tag;
22132237

22142238
# The tag may contain an '!' meaning it is identical to the one formed
22152239
# by removing the !, except that it is inverted.
22162240
my $inverted = $tag =~ s/!//;
22172241

2242+
# This hash is lacking the property name
2243+
$property = "nv=$property" if $property =~ $float_e_format;
2244+
22182245
# The list of 'prop=value' entries that this single entry expands to
22192246
my @this_entries;
22202247

@@ -2803,6 +2830,13 @@ sub token_name
28032830
{style => '*', by => 'regen/mk_invlists.pl',
28042831
from => "mph.pl"});
28052832

2833+
no warnings 'once';
2834+
print $keywords_fh <<"EOF";
2835+
/* The precisionn to use in "%.*e" formats */
2836+
#define PL_E_FORMAT_PRECISION $utf8::e_precision
2837+
2838+
EOF
2839+
28062840
my ($second_level, $seed1, $length_all_keys, $smart_blob, $rows) = MinimalPerfectHash::make_mph_from_hash(\%keywords);
28072841
print $keywords_fh MinimalPerfectHash::make_algo($second_level, $seed1, $length_all_keys, $smart_blob, $rows, undef, undef, undef, 'match_uniprop' );
28082842

0 commit comments

Comments
 (0)