-
Notifications
You must be signed in to change notification settings - Fork 677
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
Use code unit instead of code point #961
Use code unit instead of code point #961
Conversation
lit_read_code_point_from_hex (lit_utf8_byte_t *buf_p, /**< buffer with characters */ | ||
lit_utf8_size_t number_of_characters, /**< number of characters to be read */ | ||
lit_code_point_t *out_code_point_p) /**< [out] decoded result */ | ||
lit_read_code_unit_from_hex (lit_utf8_byte_t *buf_p, /**< buffer with characters */ |
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.
The doc still refers to code points.
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.
With the help of the non-character markers (as in my previous comment), couldn't we just return a code unit from this function and compare it to U+FFFF to see whether we succeeded or not? (I'm really against out parameters given with pointers, so prefer to replace them wherever possible.)
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.
No. The helper must be able to read "FFFF"
and does not have to deal with it a valid code unit or not. Currently it might work on the test suite but this change would be dangerous.
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 just sweeped through the call sites of this function, and it seems that only three functions call it with number_of_characters
being 4: ecma_builtin_json_parse_string
, re_parse_char_class
, and re_parse_next_token
. (Where the param is 2, there can be no possible way of getting a valid value of 0xFFFF.) Also, in a valid json, there must not be a U+FFFF according to the unicode specs. Where I'm not completely sure is the regexes. :/ While googling around I've seen some artificial examples with regex character classes where the upper limit was \uFFFF
. What I couldn't find out with certainty is whether they are valid examples.
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.
JS supports all characters between 0-0xffff. JS was not designed to be UTF compatible, every character is a two byte number.
5aa4211
to
0698912
Compare
@akiss77, @zherczeg, updated. Please check. |
@zherczeg, related discussion: #938 (diff) |
Ok. LGTM |
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
0698912
to
e1f20ad
Compare
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]