Closed Bug 1769755 Opened 2 years ago Closed 2 years ago

Improve decimal parsing code in TokenStream

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I've been looking into using the double-conversion library for string-to-double conversion instead of dtoa.c and noticed some issues.

If the tokenizer sees a number like 0., it currently starts at the '.' and discards
the '0'. This relies on GetDecimalNonInteger => js_strtod_harder returning 0
for invalid strings (such as "." in this case). This patch fixes this so that we
handle 0.x similar to 1.x for example.

In GetDecimalNonInteger we can now assert the whole string was parsed.

This also fixes the decimalNumber comment:

  • Case 3 no longer exists with this change, '0' is now handled similar to case 1.
  • Case 2 didn't match the code after bug 1609547. Fix the comment.
  • Case 4 (now case 3) didn't match the code after bug 1421400. Fix the comment.
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/12cafc8df1ca
Clean up TokenStream code for numbers starting with '0'. r=arai
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: