mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-19 04:43:19 +00:00
jscript: Initialize source and lastIndex for RegExp.prototype.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
parent
f8a0d96567
commit
3805eef49a
|
@ -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, ®exp);
|
||||
hres = alloc_regexp(ctx, src, NULL, ®exp);
|
||||
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, ®exp);
|
||||
hres = alloc_regexp(ctx, str, object_prototype, ®exp);
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue