-
Notifications
You must be signed in to change notification settings - Fork 683
Handle Unicode characters in parseFloat() #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle Unicode characters in parseFloat() #481
Conversation
/* Check if string is equal to "Infinity". */ | ||
while (!lit_utf8_iterator_is_eos (&iter) | ||
&& (lit_utf8_iterator_read_next (&iter) == lit_utf8_iterator_read_next (&infinity_iter))) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its better to use lit_compare_utf8_string_and_magic_string
to compare with "Infinity", the code would be more compact:
if (lit_compare_utf8_string_and_magic_string (iter.buf_p + start.offset,
iter.buf_size - start.offset,
LIT_MAGIC_STRING_INFINITY_UL))
{
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use lit_compare_utf8_string_and_magic_string
here, because we have to check if a prefix of the string contains "Infinity". For example, "Infinityfoo" should also be valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see.
dab789d
to
759ac46
Compare
Thanks for the tests, |
} | ||
else | ||
{ | ||
lit_utf8_iterator_read_prev (&iter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please, replace lit_utf8_iterato_read_prev
with lit_utf8_iterator_decr
when you don't use return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
6712f54
to
e898950
Compare
LGTM. |
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
e898950
to
c17197d
Compare
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com