Commit 3805eef4 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Initialize source and lastIndex for RegExp.prototype.

parent f8a0d965
......@@ -585,7 +585,7 @@ static const builtin_info_t RegExpInst_info = {
NULL
};
static HRESULT alloc_regexp(script_ctx_t *ctx, jsdisp_t *object_prototype, RegExpInstance **ret)
static HRESULT alloc_regexp(script_ctx_t *ctx, jsstr_t *str, jsdisp_t *object_prototype, RegExpInstance **ret)
{
RegExpInstance *regexp;
HRESULT hres;
......@@ -604,6 +604,9 @@ static HRESULT alloc_regexp(script_ctx_t *ctx, jsdisp_t *object_prototype, RegEx
return hres;
}
regexp->str = jsstr_addref(str);
regexp->last_index_val = jsval_number(0);
*ret = regexp;
return S_OK;
}
......@@ -620,13 +623,10 @@ HRESULT create_regexp(script_ctx_t *ctx, jsstr_t *src, DWORD flags, jsdisp_t **r
TRACE("%s %lx\n", debugstr_wn(str, jsstr_length(src)), flags);
hres = alloc_regexp(ctx, NULL, &regexp);
hres = alloc_regexp(ctx, src, NULL, &regexp);
if(FAILED(hres))
return hres;
regexp->str = jsstr_addref(src);
regexp->last_index_val = jsval_number(0);
regexp->jsregexp = regexp_new(ctx, &ctx->tmp_heap, str, jsstr_length(regexp->str), flags, FALSE);
if(!regexp->jsregexp) {
WARN("regexp_new failed\n");
......@@ -959,10 +959,12 @@ static const builtin_info_t RegExpConstr_info = {
HRESULT create_regexp_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
{
jsstr_t *str = jsstr_empty();
RegExpInstance *regexp;
HRESULT hres;
hres = alloc_regexp(ctx, object_prototype, &regexp);
hres = alloc_regexp(ctx, str, object_prototype, &regexp);
jsstr_release(str);
if(FAILED(hres))
return hres;
......
......@@ -335,6 +335,8 @@ ok(obj.hasOwnProperty('source'), "obj.hasOwnProperty('source') is false");
ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true");
ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true");
ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
ok(RegExp.prototype.source === "", "RegExp.prototype.source = " + RegExp.prototype.source);
ok(RegExp.prototype.lastIndex === 0, "RegExp.prototype.lastIndex = " + RegExp.prototype.lastIndex);
String();
new String();
......
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