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

jscript: Use special case for lastIndex<0 only for global regexps in run_exec.

parent a924e54c
...@@ -3637,25 +3637,25 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce ...@@ -3637,25 +3637,25 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce
hres = to_string(ctx, arg, ei, &string); hres = to_string(ctx, arg, ei, &string);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
length = SysStringLen(string);
}else { }else {
string = SysAllocStringLen(NULL, 0); string = NULL;
if(!string) length = 0;
return E_OUTOFMEMORY;
} }
if(regexp->last_index < 0) { if(regexp->jsregexp->flags & JSREG_GLOB) {
SysFreeString(string); if(regexp->last_index < 0) {
set_last_index(regexp, 0); SysFreeString(string);
*ret = VARIANT_FALSE; set_last_index(regexp, 0);
if(input) { *ret = VARIANT_FALSE;
*input = NULL; if(input) {
*input = NULL;
}
return S_OK;
} }
return S_OK;
}
length = SysStringLen(string);
if(regexp->jsregexp->flags & JSREG_GLOB)
last_index = regexp->last_index; last_index = regexp->last_index;
}
cp = string + last_index; cp = string + last_index;
hres = regexp_match_next(ctx, &regexp->dispex, REM_RESET_INDEX, string, length, &cp, parens, hres = regexp_match_next(ctx, &regexp->dispex, REM_RESET_INDEX, string, length, &cp, parens,
......
...@@ -410,6 +410,19 @@ m = re.exec(" "); ...@@ -410,6 +410,19 @@ m = re.exec(" ");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0"); ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m === null, "m = " + m + " expected null"); ok(m === null, "m = " + m + " expected null");
re = /a/;
re.lastIndex = -3;
ok(re.lastIndex === -3, "re.lastIndex = " + re.lastIndex + " expected -3");
m = re.exec(" a a ");
ok(re.lastIndex === 2, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m.index === 1, "m = " + m + " expected 1");
re.lastIndex = -1;
ok(re.lastIndex === -1, "re.lastIndex = " + re.lastIndex + " expected -1");
m = re.exec(" ");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex + " expected 0");
ok(m === null, "m = " + m + " expected null");
re = /aa/g; re = /aa/g;
i = 'baacd'.search(re); i = 'baacd'.search(re);
ok(i === 1, "'baacd'.search(re) = " + i); ok(i === 1, "'baacd'.search(re) = " + i);
......
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