Jacek Caban : jscript: Replace only the first match for non-regexp pattern in String.replace.
Alexandre Julliard
julliard at winehq.org
Mon Apr 9 13:09:15 CDT 2012
Module: wine
Branch: master
Commit: 78fc648dec5218dbb1290ee99907e78a08af7cc8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=78fc648dec5218dbb1290ee99907e78a08af7cc8
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Apr 9 14:02:35 2012 +0200
jscript: Replace only the first match for non-regexp pattern in String.replace.
---
dlls/jscript/string.c | 3 +++
dlls/jscript/tests/api.js | 9 +++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index df44db9..17f6c2f 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -961,6 +961,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(FAILED(hres))
break;
}
+
+ if(!regexp)
+ break;
}
if(SUCCEEDED(hres))
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index be49179..ffc1c48 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -414,6 +414,15 @@ ok(r === "-ret-", "r = " + r + " expected '-ret-'");
r = "-[test]-".replace("[test]", replaceFunc3, "test");
ok(r === "-ret-", "r = " + r + " expected '-ret-'");
+r = "x,x,x".replace("x", "y");
+ok(r === "y,x,x", "r = " + r + " expected 'y,x,x'");
+
+r = "x,x,x".replace("", "y");
+ok(r === "yx,x,x", "r = " + r + " expected 'yx,x,x'");
+
+r = "x,x,x".replace("", "");
+ok(r === "x,x,x", "r = " + r + " expected 'x,x,x'");
+
r = "1,2,3".split(",");
ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
ok(r.length === 3, "r.length = " + r.length);
More information about the wine-cvs
mailing list