Title: [282533] releases/WebKitGTK/webkit-2.32
Revision
282533
Author
[email protected]
Date
2021-09-16 03:36:30 -0700 (Thu, 16 Sep 2021)

Log Message

Merge r278177 - Increase NumberToStringBuffer to account for negative number
https://bugs.webkit.org/show_bug.cgi?id=226014

Patch by Mikhail R. Gadelha <[email protected]> on 2021-05-27
Reviewed by Robin Morisset.

In r250389, NumberToStringBuffer length was increased from 96 to 123 because:

<21 digits> + decimal point + <100 digits> + null char = 123.

however,

a = -100000000000000000000
a.toFixed(100)

is a valid conversion and it is 124 chars long, because of the "-" sign.

So this patch increases the length of NumberToStringBuffer to 124 and adds new
test cases.

Source/WTF:

Reviewed by Ryosuke Niwa.

* wtf/dtoa.h:

LayoutTests:

* js/dom/number-tofixed-expected.txt:
* js/dom/script-tests/number-tofixed.js:
* js/kde/Number-expected.txt:
* js/kde/script-tests/Number.js:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog	2021-09-16 10:36:30 UTC (rev 282533)
@@ -1,3 +1,29 @@
+2021-05-27  Mikhail R. Gadelha  <[email protected]>
+
+        Increase NumberToStringBuffer to account for negative number
+        https://bugs.webkit.org/show_bug.cgi?id=226014
+
+        Reviewed by Robin Morisset.
+
+        In r250389, NumberToStringBuffer length was increased from 96 to 123 because:
+
+        <21 digits> + decimal point + <100 digits> + null char = 123.
+
+        however,
+
+        a = -100000000000000000000
+        a.toFixed(100)
+
+        is a valid conversion and it is 124 chars long, because of the "-" sign.
+
+        So this patch increases the length of NumberToStringBuffer to 124 and adds new
+        test cases.
+
+        * js/dom/number-tofixed-expected.txt:
+        * js/dom/script-tests/number-tofixed.js:
+        * js/kde/Number-expected.txt:
+        * js/kde/script-tests/Number.js:
+
 2021-04-27  Frédéric Wang  <[email protected]>
 
         [MathML] Assertion failure in RenderTreeNeedsLayoutChecker

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/number-tofixed-expected.txt (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/number-tofixed-expected.txt	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/number-tofixed-expected.txt	2021-09-16 10:36:30 UTC (rev 282533)
@@ -44,6 +44,7 @@
 PASS (1234.567).toFixed(20) is "1234.56700000000000727596"
 PASS (1234.567).toFixed(21) is "1234.567000000000007275958"
 PASS (1234.567).toFixed(100) is "1234.5670000000000072759576141834259033203125000000000000000000000000000000000000000000000000000000000000"
+PASS (-100000000000000000000).toFixed(100) is "-100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
 PASS (1234.567).toFixed(101) threw exception RangeError: toFixed() argument must be between 0 and 100.
 PASS (1234.567).toFixed(-1) threw exception RangeError: toFixed() argument must be between 0 and 100.
 PASS (1234.567).toFixed(-4) threw exception RangeError: toFixed() argument must be between 0 and 100.

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/script-tests/number-tofixed.js (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/script-tests/number-tofixed.js	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/js/dom/script-tests/number-tofixed.js	2021-09-16 10:36:30 UTC (rev 282533)
@@ -62,6 +62,7 @@
 shouldBeEqualToString("(1234.567).toFixed(20)", "1234.56700000000000727596");
 shouldBeEqualToString("(1234.567).toFixed(21)", "1234.567000000000007275958");
 shouldBeEqualToString("(1234.567).toFixed(100)", "1234.5670000000000072759576141834259033203125000000000000000000000000000000000000000000000000000000000000");
+shouldBeEqualToString("(-100000000000000000000).toFixed(100)", "-100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
 
 shouldThrow("(1234.567).toFixed(101)");
 shouldThrow("(1234.567).toFixed(-1)");

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/Number-expected.txt (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/Number-expected.txt	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/Number-expected.txt	2021-09-16 10:36:30 UTC (rev 282533)
@@ -42,6 +42,7 @@
 PASS Number(NaN).toFixed(7) is "NaN"
 PASS Number(Infinity).toFixed(7) is "Infinity"
 PASS Number(-Infinity).toFixed(7) is "-Infinity"
+PASS Number(-100000000000000000000).toFixed(100) is "-100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
 PASS Number(Math.pow(10,4)).toFixed(13) is "10000.0000000000000"
 PASS Number(Math.pow(10,17)).toFixed(16) is "100000000000000000.0000000000000000"
 PASS Number(Math.pow(10,18)).toFixed(17) is "1000000000000000000.00000000000000000"

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/script-tests/Number.js (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/script-tests/Number.js	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/js/kde/script-tests/Number.js	2021-09-16 10:36:30 UTC (rev 282533)
@@ -53,6 +53,7 @@
 shouldBe("Number(NaN).toFixed(7)","\"NaN\"");
 shouldBe("Number(Infinity).toFixed(7)","\"Infinity\"");
 shouldBe("Number(-Infinity).toFixed(7)","\"-Infinity\"");
+shouldBe("Number(-100000000000000000000).toFixed(100)","\"-100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"");
 shouldBe("Number(Math.pow(10,4)).toFixed(13)","\"10000.0000000000000\"");
 shouldBe("Number(Math.pow(10,17)).toFixed(16)","\"100000000000000000.0000000000000000\"");
 shouldBe("Number(Math.pow(10,18)).toFixed(17)","\"1000000000000000000.00000000000000000\"");

Modified: releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog	2021-09-16 10:36:30 UTC (rev 282533)
@@ -1,3 +1,28 @@
+2021-05-27  Mikhail R. Gadelha  <[email protected]>
+
+        Increase NumberToStringBuffer to account for negative number
+        https://bugs.webkit.org/show_bug.cgi?id=226014
+
+        Reviewed by Robin Morisset.
+
+        In r250389, NumberToStringBuffer length was increased from 96 to 123 because:
+
+        <21 digits> + decimal point + <100 digits> + null char = 123.
+
+        however,
+
+        a = -100000000000000000000
+        a.toFixed(100)
+
+        is a valid conversion and it is 124 chars long, because of the "-" sign.
+
+        So this patch increases the length of NumberToStringBuffer to 124 and adds new
+        test cases.
+
+        Reviewed by Ryosuke Niwa.
+
+        * wtf/dtoa.h:
+
 2021-05-26  Chris Dumez  <[email protected]>
 
         [Hardening] Have the Ref<> destructor null out its pointer

Modified: releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/dtoa.h (282532 => 282533)


--- releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/dtoa.h	2021-09-16 10:36:22 UTC (rev 282532)
+++ releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/dtoa.h	2021-09-16 10:36:30 UTC (rev 282533)
@@ -27,7 +27,9 @@
 
 namespace WTF {
 
-using NumberToStringBuffer = std::array<char, 123>;
+// Only toFixed() can use all the 124 positions. The format is:
+// <-> + <21 digits> + decimal point + <100 digits> + null char = 124.
+using NumberToStringBuffer = std::array<char, 124>;
 
 WTF_EXPORT_PRIVATE const char* numberToString(float, NumberToStringBuffer&);
 WTF_EXPORT_PRIVATE const char* numberToFixedPrecisionString(float, unsigned significantFigures, NumberToStringBuffer&, bool truncateTrailingZeros = false);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to