Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1516)

Unified Diff: src/regexp/regexp-utils.cc

Issue 2415383002: [regexp] Match spec semantics in AdvanceStringIndex (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/regexp/regexp-utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-utils.cc
diff --git a/src/regexp/regexp-utils.cc b/src/regexp/regexp-utils.cc
index 963bb68b7f9749ac47893415352afcad6b2da6ed..c02eb533b841bf616bf127f621c1e5408cc37f96 100644
--- a/src/regexp/regexp-utils.cc
+++ b/src/regexp/regexp-utils.cc
@@ -188,23 +188,19 @@ bool RegExpUtils::IsBuiltinExec(Handle<Object> exec) {
return (code->builtin_index() == Builtins::kRegExpPrototypeExec);
}
-// ES#sec-advancestringindex
-// AdvanceStringIndex ( S, index, unicode )
int RegExpUtils::AdvanceStringIndex(Isolate* isolate, Handle<String> string,
int index, bool unicode) {
- int increment = 1;
-
if (unicode && index < string->length()) {
const uint16_t first = string->Get(index);
if (first >= 0xD800 && first <= 0xDBFF && string->length() > index + 1) {
const uint16_t second = string->Get(index + 1);
if (second >= 0xDC00 && second <= 0xDFFF) {
- increment = 2;
+ return index + 2;
}
}
}
- return increment;
+ return index + 1;
}
MaybeHandle<Object> RegExpUtils::SetAdvancedStringIndex(
@@ -221,7 +217,7 @@ MaybeHandle<Object> RegExpUtils::SetAdvancedStringIndex(
const int last_index = Handle<Smi>::cast(last_index_obj)->value();
const int new_last_index =
- last_index + AdvanceStringIndex(isolate, string, last_index, unicode);
+ AdvanceStringIndex(isolate, string, last_index, unicode);
return SetLastIndex(isolate, regexp, new_last_index);
}
« no previous file with comments | « src/regexp/regexp-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698