Bugfix for string replace. (#1409)
Some test cases were failed with enabled show-opcodes build option.
Example source:
"98765".replace(76)
print ("\ud801\udc00".replace("\ud801", "#") === "#\udc00");
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
@@ -875,8 +875,19 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
|
|||||||
{
|
{
|
||||||
ecma_char_t action = LIT_CHAR_NULL;
|
ecma_char_t action = LIT_CHAR_NULL;
|
||||||
|
|
||||||
if (*replace_str_curr_p++ == LIT_CHAR_DOLLAR_SIGN)
|
if (*replace_str_curr_p != LIT_CHAR_DOLLAR_SIGN)
|
||||||
{
|
{
|
||||||
|
/* if not a continuation byte */
|
||||||
|
if ((*replace_str_curr_p & LIT_UTF8_EXTRA_BYTE_MASK) != LIT_UTF8_EXTRA_BYTE_MARKER)
|
||||||
|
{
|
||||||
|
current_position++;
|
||||||
|
}
|
||||||
|
replace_str_curr_p++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
replace_str_curr_p++;
|
||||||
|
|
||||||
if (replace_str_curr_p < replace_str_end_p)
|
if (replace_str_curr_p < replace_str_end_p)
|
||||||
{
|
{
|
||||||
action = *replace_str_curr_p;
|
action = *replace_str_curr_p;
|
||||||
@@ -925,7 +936,6 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
|
|||||||
action = LIT_CHAR_NULL;
|
action = LIT_CHAR_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (action != LIT_CHAR_NULL)
|
if (action != LIT_CHAR_NULL)
|
||||||
{
|
{
|
||||||
@@ -935,6 +945,7 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
|
|||||||
current_position,
|
current_position,
|
||||||
true);
|
true);
|
||||||
replace_str_curr_p++;
|
replace_str_curr_p++;
|
||||||
|
current_position++;
|
||||||
|
|
||||||
if (action == LIT_CHAR_DOLLAR_SIGN)
|
if (action == LIT_CHAR_DOLLAR_SIGN)
|
||||||
{
|
{
|
||||||
@@ -1015,11 +1026,9 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
|
|||||||
}
|
}
|
||||||
|
|
||||||
current_position++;
|
current_position++;
|
||||||
previous_start = current_position + 1;
|
previous_start = current_position;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* if not a continuation byte */
|
|
||||||
if ((*replace_str_curr_p & LIT_UTF8_EXTRA_BYTE_MASK) != LIT_UTF8_EXTRA_BYTE_MARKER)
|
|
||||||
{
|
{
|
||||||
current_position++;
|
current_position++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user