From 66b00aab2aa350e77fb96dc44942cb95fe2b0c13 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 9 Apr 2019 12:09:34 -0600 Subject: [PATCH] mktables: Generalize handling of [perl #133979] I realized that commit f9c1e7e9ed13a16099c8471c2030b93deb482571 works now, but future Unicode versions may add fractions that fool it. This commit should handle any such event --- charclass_invlists.h | 2 +- lib/unicore/mktables | 16 +++++++++++----- lib/unicore/uni_keywords.pl | 2 +- regcharclass.h | 2 +- uni_keywords.h | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/charclass_invlists.h b/charclass_invlists.h index 641a8cc..b8e1b14 100644 --- a/charclass_invlists.h +++ b/charclass_invlists.h @@ -395301,7 +395301,7 @@ static const U8 WB_table[23][23] = { * 78e2600e24fa7d5ab62117de50b382f8b31b08401c37a0782c38dacb340b64e7 lib/unicore/extracted/DLineBreak.txt * 1bde4ad73e271c6349fbd1972e54f38bba5cc1900c28f678e79b9e8909b31793 lib/unicore/extracted/DNumType.txt * 6278722699123f3890e4b1cc42011e96d8960e4958a3b93484361530983d2611 lib/unicore/extracted/DNumValues.txt - * 2109fe6697a0cca88cede7477f9e3818e358605c430f9e21b6297653a1217713 lib/unicore/mktables + * 0361666b8b957b7d50ed80a464742b2a979e2a387c5715f5e28b3a39bc149f6e lib/unicore/mktables * a712c758275b460d18fa77a26ed3589689bb3f69dcc1ea99b913e32db92a5cd2 lib/unicore/version * 2680b9254eb236c5c090f11b149605043e8c8433661b96efc4a42fb4709342a5 regen/charset_translations.pl * 03e51b0f07beebd5da62ab943899aa4934eee1f792fa27c1fb638c33bf4ac6ea regen/mk_PL_charclass.pl diff --git a/lib/unicore/mktables b/lib/unicore/mktables index e67fa74..de90c05 100644 --- a/lib/unicore/mktables +++ b/lib/unicore/mktables @@ -12975,11 +12975,17 @@ sub register_fraction($) { my $denominator = $1; if (defined $denominator && (($denominator & ($denominator - 1)) == 0)) { - # These have an exact representation in binary, so rounding could go - # either way. It turns out that Windows doesn't necessarily round - # towards even, so output an extra entry - my $extra_digit_float = sprintf "%.*e", $E_FLOAT_PRECISION + 1, $floating; - if ($extra_digit_float =~ / ( .* ) ( [02468] ) 5 ( e .*) /ix) { + # Here the denominator is a power of 2. This means it has an exact + # representation in binary, so rounding could go either way. It turns + # out that Windows doesn't necessarily round towards even, so output + # an extra entry. This happens when the final digit we output is even + # and the next digits would be 50* to the precision of the machine. + my $extra_digit_float = sprintf "%e", $floating; + my $q = $E_FLOAT_PRECISION - 1; + if ($extra_digit_float =~ / ( .* \. \d{$q} ) + ( [02468] ) 5 0* ( e .*) + /ix) + { push @floats, $1 . ($2 + 1) . $3; } } diff --git a/lib/unicore/uni_keywords.pl b/lib/unicore/uni_keywords.pl index 21fdcc9..50d480e 100644 --- a/lib/unicore/uni_keywords.pl +++ b/lib/unicore/uni_keywords.pl @@ -1261,7 +1261,7 @@ # 78e2600e24fa7d5ab62117de50b382f8b31b08401c37a0782c38dacb340b64e7 lib/unicore/extracted/DLineBreak.txt # 1bde4ad73e271c6349fbd1972e54f38bba5cc1900c28f678e79b9e8909b31793 lib/unicore/extracted/DNumType.txt # 6278722699123f3890e4b1cc42011e96d8960e4958a3b93484361530983d2611 lib/unicore/extracted/DNumValues.txt -# 2109fe6697a0cca88cede7477f9e3818e358605c430f9e21b6297653a1217713 lib/unicore/mktables +# 0361666b8b957b7d50ed80a464742b2a979e2a387c5715f5e28b3a39bc149f6e lib/unicore/mktables # a712c758275b460d18fa77a26ed3589689bb3f69dcc1ea99b913e32db92a5cd2 lib/unicore/version # 2680b9254eb236c5c090f11b149605043e8c8433661b96efc4a42fb4709342a5 regen/charset_translations.pl # 03e51b0f07beebd5da62ab943899aa4934eee1f792fa27c1fb638c33bf4ac6ea regen/mk_PL_charclass.pl diff --git a/regcharclass.h b/regcharclass.h index 44fe72c..e3fdea1 100644 --- a/regcharclass.h +++ b/regcharclass.h @@ -1901,7 +1901,7 @@ * 78e2600e24fa7d5ab62117de50b382f8b31b08401c37a0782c38dacb340b64e7 lib/unicore/extracted/DLineBreak.txt * 1bde4ad73e271c6349fbd1972e54f38bba5cc1900c28f678e79b9e8909b31793 lib/unicore/extracted/DNumType.txt * 6278722699123f3890e4b1cc42011e96d8960e4958a3b93484361530983d2611 lib/unicore/extracted/DNumValues.txt - * 2109fe6697a0cca88cede7477f9e3818e358605c430f9e21b6297653a1217713 lib/unicore/mktables + * 0361666b8b957b7d50ed80a464742b2a979e2a387c5715f5e28b3a39bc149f6e lib/unicore/mktables * a712c758275b460d18fa77a26ed3589689bb3f69dcc1ea99b913e32db92a5cd2 lib/unicore/version * 2680b9254eb236c5c090f11b149605043e8c8433661b96efc4a42fb4709342a5 regen/charset_translations.pl * 830144f6afdd047b009754ffa06134397268f6638837fe85283483eb0cfdd558 regen/regcharclass.pl diff --git a/uni_keywords.h b/uni_keywords.h index fb94596..540aeb7 100644 --- a/uni_keywords.h +++ b/uni_keywords.h @@ -7284,7 +7284,7 @@ MPH_VALt match_uniprop( const unsigned char * const key, const U16 key_len ) { * 78e2600e24fa7d5ab62117de50b382f8b31b08401c37a0782c38dacb340b64e7 lib/unicore/extracted/DLineBreak.txt * 1bde4ad73e271c6349fbd1972e54f38bba5cc1900c28f678e79b9e8909b31793 lib/unicore/extracted/DNumType.txt * 6278722699123f3890e4b1cc42011e96d8960e4958a3b93484361530983d2611 lib/unicore/extracted/DNumValues.txt - * 2109fe6697a0cca88cede7477f9e3818e358605c430f9e21b6297653a1217713 lib/unicore/mktables + * 0361666b8b957b7d50ed80a464742b2a979e2a387c5715f5e28b3a39bc149f6e lib/unicore/mktables * a712c758275b460d18fa77a26ed3589689bb3f69dcc1ea99b913e32db92a5cd2 lib/unicore/version * 2680b9254eb236c5c090f11b149605043e8c8433661b96efc4a42fb4709342a5 regen/charset_translations.pl * 03e51b0f07beebd5da62ab943899aa4934eee1f792fa27c1fb638c33bf4ac6ea regen/mk_PL_charclass.pl -- 1.8.3.1