Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -40489,24 +40489,31 @@ static JSValue js_regexp_Symbol_match(JSContext *ctx, JSValueConst this_val,
{
// [Symbol.match](str)
JSValueConst rx = this_val;
JSValue A, S, result, matchStr;
JSValue A, S, flags, result, matchStr;
int global, n, fullUnicode, isEmpty;
JSString *p;

if (!JS_IsObject(rx))
return JS_ThrowTypeErrorNotAnObject(ctx);

A = JS_UNDEFINED;
flags = JS_UNDEFINED;
result = JS_UNDEFINED;
matchStr = JS_UNDEFINED;
S = JS_ToString(ctx, argv[0]);
if (JS_IsException(S))
goto exception;

global = JS_ToBoolFree(ctx, JS_GetProperty(ctx, rx, JS_ATOM_global));
if (global < 0)
flags = JS_GetProperty(ctx, rx, JS_ATOM_flags);
if (JS_IsException(flags))
goto exception;
flags = JS_ToStringFree(ctx, flags);
if (JS_IsException(flags))
goto exception;
p = JS_VALUE_GET_STRING(flags);

// TODO(bnoordhuis) query 'u' flag the same way?
global = (-1 != string_indexof_char(p, 'g', 0));
if (!global) {
A = JS_RegExpExec(ctx, rx, S);
} else {
Expand Down Expand Up @@ -40550,12 +40557,14 @@ static JSValue js_regexp_Symbol_match(JSContext *ctx, JSValueConst this_val,
}
}
JS_FreeValue(ctx, result);
JS_FreeValue(ctx, flags);
JS_FreeValue(ctx, S);
return A;

exception:
JS_FreeValue(ctx, A);
JS_FreeValue(ctx, result);
JS_FreeValue(ctx, flags);
JS_FreeValue(ctx, S);
return JS_EXCEPTION;
}
Expand Down Expand Up @@ -40798,8 +40807,8 @@ static JSValue js_regexp_Symbol_replace(JSContext *ctx, JSValueConst this_val,
// [Symbol.replace](str, rep)
JSValueConst rx = this_val, rep = argv[1];
JSValueConst args[6];
JSValue str, rep_val, matched, tab, rep_str, namedCaptures, res;
JSString *sp, *rp;
JSValue flags, str, rep_val, matched, tab, rep_str, namedCaptures, res;
JSString *p, *sp, *rp;
StringBuffer b_s, *b = &b_s;
ValueBuffer v_b, *results = &v_b;
int nextSourcePosition, n, j, functionalReplace, is_global, fullUnicode;
Expand All @@ -40815,6 +40824,7 @@ static JSValue js_regexp_Symbol_replace(JSContext *ctx, JSValueConst this_val,
rep_val = JS_UNDEFINED;
matched = JS_UNDEFINED;
tab = JS_UNDEFINED;
flags = JS_UNDEFINED;
rep_str = JS_UNDEFINED;
namedCaptures = JS_UNDEFINED;

Expand All @@ -40831,10 +40841,18 @@ static JSValue js_regexp_Symbol_replace(JSContext *ctx, JSValueConst this_val,
goto exception;
rp = JS_VALUE_GET_STRING(rep_val);
}
fullUnicode = 0;
is_global = JS_ToBoolFree(ctx, JS_GetProperty(ctx, rx, JS_ATOM_global));
if (is_global < 0)

flags = JS_GetProperty(ctx, rx, JS_ATOM_flags);
if (JS_IsException(flags))
goto exception;
flags = JS_ToStringFree(ctx, flags);
if (JS_IsException(flags))
goto exception;
p = JS_VALUE_GET_STRING(flags);

// TODO(bnoordhuis) query 'u' flag the same way?
fullUnicode = 0;
is_global = (-1 != string_indexof_char(p, 'g', 0));
if (is_global) {
fullUnicode = JS_ToBoolFree(ctx, JS_GetProperty(ctx, rx, JS_ATOM_unicode));
if (fullUnicode < 0)
Expand Down Expand Up @@ -40968,6 +40986,7 @@ static JSValue js_regexp_Symbol_replace(JSContext *ctx, JSValueConst this_val,
value_buffer_free(results);
JS_FreeValue(ctx, rep_val);
JS_FreeValue(ctx, matched);
JS_FreeValue(ctx, flags);
JS_FreeValue(ctx, tab);
JS_FreeValue(ctx, rep_str);
JS_FreeValue(ctx, namedCaptures);
Expand Down
12 changes: 0 additions & 12 deletions test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-r
test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: strict mode: Test262Error: Expected a ReferenceError but got a different error constructor with the same name
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: strict mode: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
test262/test/built-ins/RegExp/prototype/Symbol.match/flags-tostring-error.js:22: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.match/flags-tostring-error.js:22: strict mode: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.match/get-flags-err.js:23: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.match/get-flags-err.js:23: strict mode: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.match/get-unicode-error.js:22: Test262Error: Expected a Test262Error to be thrown but no exception was thrown at all
test262/test/built-ins/RegExp/prototype/Symbol.match/get-unicode-error.js:22: strict mode: Test262Error: Expected a Test262Error to be thrown but no exception was thrown at all
test262/test/built-ins/RegExp/prototype/Symbol.replace/flags-tostring-error.js:26: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.replace/flags-tostring-error.js:26: strict mode: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.replace/get-flags-err.js:27: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.replace/get-flags-err.js:27: strict mode: Test262Error: Expected a CustomError but got a Test262Error
test262/test/built-ins/RegExp/prototype/Symbol.replace/get-unicode-error.js:26: Test262Error: Expected a Test262Error to be thrown but no exception was thrown at all
test262/test/built-ins/RegExp/prototype/Symbol.replace/get-unicode-error.js:26: strict mode: Test262Error: Expected a Test262Error to be thrown but no exception was thrown at all
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: strict mode: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js:30: TypeError: out-of-bound numeric index (Testing with Float64Array.)
Expand Down