mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
!7491 string.replace compressed 断言失败
Merge pull request !7491 from zhangyouyou/master
This commit is contained in:
commit
191dc31469
@ -1153,7 +1153,7 @@ JSTaggedValue BuiltinsRegExp::ReplaceInternal(JSThread *thread,
|
||||
}
|
||||
}
|
||||
// 14. Let accumulatedResult be the empty String value.
|
||||
bool isUtf8 = EcmaStringAccessor(srcString).IsUtf8();
|
||||
bool isUtf8 = true;
|
||||
uint32_t resultStrLength = 0;
|
||||
uint32_t resultArrayLength = (static_cast<uint32_t>(resultsIndex) + 1) * 2;
|
||||
JSHandle<TaggedArray> resultArray = factory->NewTaggedArray(resultArrayLength);
|
||||
@ -1296,6 +1296,9 @@ JSTaggedValue BuiltinsRegExp::ReplaceInternal(JSThread *thread,
|
||||
// store position and length bits in resultLengthArray
|
||||
resultLengthArray[REPLACE_RESULT_VAL * i] = bits;
|
||||
resultStrLength += (position - nextSourcePosition);
|
||||
auto subString = EcmaStringAccessor::FastSubString(
|
||||
thread->GetEcmaVM(), srcString, nextSourcePosition, position - nextSourcePosition);
|
||||
isUtf8 &= EcmaStringAccessor(subString).IsUtf8();
|
||||
// store replacement string in resultArray
|
||||
resultArray->Set(thread, REPLACE_RESULT_VAL * i + 1, replacementString.GetTaggedValue());
|
||||
uint32_t replacementLength = EcmaStringAccessor(replacementString).GetLength();
|
||||
@ -1315,6 +1318,9 @@ JSTaggedValue BuiltinsRegExp::ReplaceInternal(JSThread *thread,
|
||||
uint64_t bits = 0;
|
||||
bits |= ReplaceLengthField::Encode(length - nextSourcePosition);
|
||||
bits |= ReplacePositionField::Encode(nextSourcePosition);
|
||||
auto subStringEnd = EcmaStringAccessor::FastSubString(
|
||||
thread->GetEcmaVM(), srcString, nextSourcePosition, length - nextSourcePosition);
|
||||
isUtf8 &= EcmaStringAccessor(subStringEnd).IsUtf8();
|
||||
// store position and length bits in resultLengthArray
|
||||
resultLengthArray[REPLACE_RESULT_VAL * resultsIndex] = bits;
|
||||
resultStrLength += (length - nextSourcePosition);
|
||||
|
@ -26,3 +26,5 @@ aaaa哈哈哈哈哈哈哈嘻嘻嘻嘻嘻嘻嘻嘻嘻bbbb哈哈哈哈哈哈哈嘻
|
||||
aaaa哈哈哈哈哈哈哈哈哈哈哈哈哈哈bbbb哈哈哈哈哈哈哈哈哈哈哈哈哈哈cccc哈哈哈哈哈哈哈哈哈哈哈哈哈哈aaaabbbbcccc
|
||||
aaaa哈哈哈哈哈哈哈哈哈嘻嘻嘻嘻嘻嘻嘻bbbb哈哈哈哈哈哈哈哈哈嘻嘻嘻嘻嘻嘻嘻cccc哈哈哈哈哈哈哈哈哈嘻嘻嘻嘻嘻嘻嘻aaaabbbbcccc
|
||||
aaaa哈哈哈哈哈哈哈哈哈嘻bbbb哈哈哈哈哈哈哈哈哈嘻cccc哈哈哈哈哈哈哈哈哈嘻aaaabbbbcccc
|
||||
undefinedss
|
||||
undefinedss
|
||||
|
@ -100,4 +100,8 @@ function func8() {
|
||||
return "哈哈哈哈哈哈哈哈哈".concat("嘻")
|
||||
}
|
||||
res = lineString2.replace(re2, func8);
|
||||
print(res)
|
||||
print(res)
|
||||
|
||||
let v5 = String.fromCharCode(0).replaceAll(/(?<a>.)/ug);
|
||||
print("undefinedss".replace(undefined,v5));
|
||||
print("undefinedss".replaceAll(undefined,v5));
|
Loading…
Reference in New Issue
Block a user