Skip to content

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

Merged

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Jul 27, 2015

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com

@dbatyai dbatyai added bug Undesired behaviour ecma builtins Related to ECMA built-in routines labels Jul 27, 2015
@dbatyai dbatyai added this to the ECMA builtins milestone Jul 27, 2015
/* 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)))
{
Copy link
Contributor

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))
{
  ...
}

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see.

@dbatyai dbatyai force-pushed the global_parsefloat_unicode branch from dab789d to 759ac46 Compare July 30, 2015 07:43
@galpeter
Copy link
Contributor

Thanks for the tests,
lgtm

@dbatyai dbatyai assigned sand1k and unassigned galpeter Jul 30, 2015
}
else
{
lit_utf8_iterator_read_prev (&iter);
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@dbatyai dbatyai force-pushed the global_parsefloat_unicode branch 2 times, most recently from 6712f54 to e898950 Compare August 5, 2015 12:37
@sand1k
Copy link
Contributor

sand1k commented Aug 5, 2015

LGTM.

@sand1k sand1k assigned dbatyai and unassigned sand1k Aug 5, 2015
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
@dbatyai dbatyai force-pushed the global_parsefloat_unicode branch from e898950 to c17197d Compare August 6, 2015 08:38
@dbatyai dbatyai merged commit c17197d into jerryscript-project:master Aug 6, 2015
@dbatyai dbatyai deleted the global_parsefloat_unicode branch August 11, 2015 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants