Commit 9ac79498 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Correctly handle -1 index in regexp match result.

parent bd715dc8
......@@ -3349,8 +3349,13 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c
*parens_cnt = regexp->jsregexp->parenCount;
for(i=0; i < regexp->jsregexp->parenCount; i++) {
(*parens)[i].str = *cp + result->parens[i].index;
(*parens)[i].len = result->parens[i].length;
if(result->parens[i].index == -1) {
(*parens)[i].str = NULL;
(*parens)[i].len = 0;
}else {
(*parens)[i].str = *cp + result->parens[i].index;
(*parens)[i].len = result->parens[i].length;
}
}
}
......
......@@ -71,6 +71,11 @@ m = re.exec();
ok(m === null, "m is not null");
ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex);
m = /(a|b)+|(c)/.exec("aa");
ok(m[0] === "aa", "m[0] = " + m[0]);
ok(m[1] === "a", "m[1] = " + m[1]);
ok(m[2] === "", "m[2] = " + m[2]);
b = re.test(" a ");
ok(b === true, "re.test(' a ') returned " + b);
ok(re.lastIndex === 3, "re.lastIndex = " + re.lastIndex);
......
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