Commit fe0bd340 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Support passing non-string flags to RegExp constructor.

parent 4e887493
......@@ -671,7 +671,7 @@ HRESULT create_regexp(script_ctx_t *ctx, jsstr_t *src, DWORD flags, jsdisp_t **r
HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg, jsdisp_t **ret)
{
unsigned flags, opt_len = 0;
unsigned flags = 0;
const WCHAR *opt = NULL;
jsstr_t *src;
HRESULT hres = S_OK;
......@@ -700,24 +700,20 @@ HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg
if(FAILED(hres))
return hres;
if(flags_arg) {
if(flags_arg && !is_undefined(*flags_arg)) {
jsstr_t *opt_str;
if(!is_string(*flags_arg)) {
FIXME("unimplemented for %s\n", debugstr_jsval(*flags_arg));
return E_NOTIMPL;
}
opt_str = get_string(*flags_arg);
opt = jsstr_flatten(opt_str);
if(!opt) {
jsstr_release(src);
return E_OUTOFMEMORY;
hres = to_string(ctx, *flags_arg, &opt_str);
if(SUCCEEDED(hres)) {
opt = jsstr_flatten(opt_str);
if(opt)
hres = parse_regexp_flags(opt, jsstr_length(opt_str), &flags);
else
hres = E_OUTOFMEMORY;
jsstr_release(opt_str);
}
opt_len = jsstr_length(opt_str);
}
hres = parse_regexp_flags(opt, opt_len, &flags);
if(SUCCEEDED(hres))
hres = create_regexp(ctx, src, flags, ret);
jsstr_release(src);
......
......@@ -701,4 +701,16 @@ ok(re.ignoreCase === false, "re.ignoreCase = " + re.ignoreCase);
ok(re.multiline === false, "re.multiline = " + re.multiline);
ok(re.global === false, "re.global = " + re.global);
re = new RegExp("test", undefined);
ok(re.source === "test", "re.source = " + re.source);
ok(re.ignoreCase === false, "re.ignoreCase = " + re.ignoreCase);
ok(re.multiline === false, "re.multiline = " + re.multiline);
ok(re.global === false, "re.global = " + re.global);
re = new RegExp("test", { toString: function() { return "mg"; } });
ok(re.source === "test", "re.source = " + re.source);
ok(re.ignoreCase === false, "re.ignoreCase = " + re.ignoreCase);
ok(re.multiline === true, "re.multiline = " + re.multiline);
ok(re.global === true, "re.global = " + re.global);
reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment