Refactor builtins to handle CESU-8 encoded strings.
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
@@ -354,15 +354,16 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
return ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
lit_utf8_iterator_t iter = lit_utf8_iterator_create (str_p, str_size);
|
||||
lit_utf8_byte_t *str_curr_p = (lit_utf8_byte_t *) str_p;
|
||||
const lit_utf8_byte_t *str_end_p = str_p + str_size;
|
||||
ecma_char_t code_unit;
|
||||
|
||||
while (!lit_utf8_iterator_is_eos (&iter))
|
||||
while (str_curr_p < str_end_p)
|
||||
{
|
||||
code_unit = lit_utf8_iterator_peek_next (&iter);
|
||||
code_unit = lit_utf8_peek_next (str_curr_p);
|
||||
if (lit_char_is_white_space (code_unit) || lit_char_is_line_terminator (code_unit))
|
||||
{
|
||||
lit_utf8_iterator_incr (&iter);
|
||||
lit_utf8_incr (&str_curr_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -370,17 +371,15 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT (!iter.buf_pos.is_non_bmp_middle);
|
||||
const lit_utf8_byte_t *begin_p = iter.buf_p + iter.buf_pos.offset;
|
||||
const lit_utf8_byte_t *begin_p = str_curr_p;
|
||||
str_curr_p = (lit_utf8_byte_t *) str_end_p;
|
||||
|
||||
iter = lit_utf8_iterator_create (iter.buf_p + iter.buf_pos.offset, str_size - iter.buf_pos.offset);
|
||||
lit_utf8_iterator_seek_eos (&iter);
|
||||
while (!lit_utf8_iterator_is_bos (&iter))
|
||||
while (str_curr_p > str_p)
|
||||
{
|
||||
code_unit = lit_utf8_iterator_peek_prev (&iter);
|
||||
code_unit = lit_utf8_peek_prev (str_curr_p);
|
||||
if (lit_char_is_white_space (code_unit) || lit_char_is_line_terminator (code_unit))
|
||||
{
|
||||
lit_utf8_iterator_decr (&iter);
|
||||
lit_utf8_decr (&str_curr_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -388,8 +387,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT (!iter.buf_pos.is_non_bmp_middle);
|
||||
const lit_utf8_byte_t *end_p = iter.buf_p + iter.buf_pos.offset - 1;
|
||||
const lit_utf8_byte_t *end_p = str_curr_p - 1;
|
||||
|
||||
if (begin_p > end_p)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user