mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
1. When 'writable' property of array length turned into 'false', convert it into NonFastMode
2. If RegExp's source needs escapeSlash process, it should count the number of leading backSlashs Signed-off-by: Saebom Kim sae-bom.kim@samsung.com
This commit is contained in:
parent
74805fddd8
commit
6d4ed41488
5 changed files with 107 additions and 410 deletions
|
|
@ -80,15 +80,31 @@ static String* escapeSlashInPattern(String* patternStr)
|
|||
StringBuilder builder;
|
||||
while (true) {
|
||||
for (i = 0; start + i < len; i++) {
|
||||
if (UNLIKELY(patternStr->charAt(start + i) == '/' && (i == 0 || patternStr->charAt(start + i - 1) != '\\'))) {
|
||||
slashFlag = true;
|
||||
builder.appendSubString(patternStr, start, start + i);
|
||||
builder.appendChar('\\');
|
||||
builder.appendChar('/');
|
||||
if (UNLIKELY(patternStr->charAt(start + i) == '/')) {
|
||||
size_t backSlashCount = 0;
|
||||
size_t s = start + i - 1;
|
||||
while (true) {
|
||||
if (patternStr->charAt(s) == '\\') {
|
||||
backSlashCount++;
|
||||
if (s == 0) {
|
||||
break;
|
||||
}
|
||||
s--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (backSlashCount % 2 == 0) {
|
||||
slashFlag = true;
|
||||
builder.appendSubString(patternStr, start, start + i);
|
||||
builder.appendChar('\\');
|
||||
builder.appendChar('/');
|
||||
|
||||
start = start + i + 1;
|
||||
i = 0;
|
||||
break;
|
||||
start = start + i + 1;
|
||||
i = 0;
|
||||
backSlashCount = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start + i >= len) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue