jscript: Correctly handle empty matches in String.replace.

This commit is contained in:
Jacek Caban 2012-04-18 13:50:19 +02:00 committed by Alexandre Julliard
parent e21588aef7
commit c1cb8f29b0
2 changed files with 12 additions and 0 deletions

View File

@ -868,6 +868,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
}
if(FAILED(hres))
break;
if(!match.len)
cp++;
}else {
match.str = strstrW(cp, match_str);
if(!match.str)

View File

@ -583,4 +583,13 @@ ok(i === null, "' undefined '.search() = " + i);
tmp = "=)".replace(/=/, "?");
ok(tmp === "?)", "'=)'.replace(/=/, '?') = " + tmp);
tmp = " ".replace(/^\s*|\s*$/g, "y");
ok(tmp === "yy", '" ".replace(/^\s*|\s*$/g, "y") = ' + tmp);
tmp = "xxx".replace(/^\s*|\s*$/g, "");
ok(tmp === "xxx", '"xxx".replace(/^\s*|\s*$/g, "y") = ' + tmp);
tmp = "xxx".replace(/^\s*|\s*$/g, "y");
ok(tmp === "yxxxy", '"xxx".replace(/^\s*|\s*$/g, "y") = ' + tmp);
reportSuccess();