Fix case where mergeComplexNumberFormatMasks would get stuck in endless-loop (#1793)

* Fix case where mergeComplexNumberFormatMasks would get stuck in endless-loop if $numbers had many decimals
This commit is contained in:
Mats Sibelius 2021-02-08 20:26:11 +02:00 committed by GitHub
parent b068639513
commit f60f37c362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View File

@ -563,9 +563,11 @@ class NumberFormat extends Supervisor
do {
$tempMask = array_pop($masks);
if ($tempMask !== null) {
$postDecimalMasks[] = $tempMask;
$decimalCount -= strlen($tempMask);
} while ($decimalCount > 0);
}
} while ($tempMask !== null && $decimalCount > 0);
return [
implode('.', $masks),

View File

@ -362,4 +362,24 @@ return [
25,
'[Green][<>25]"<>25 green";[Red]"else red"',
],
[
'pfx. 25.00',
25,
'"pfx." 0.00;"pfx." -0.00;"pfx." 0.00;',
],
[
'pfx. 25.20',
25.2,
'"pfx." 0.00;"pfx." -0.00;"pfx." 0.00;',
],
[
'pfx. -25.20',
-25.2,
'"pfx." 0.00;"pfx." -0.00;"pfx." 0.00;',
],
[
'pfx. 25.26',
25.255555555555555,
'"pfx." 0.00;"pfx." -0.00;"pfx." 0.00;',
],
];