Jacek Caban : jscript: Treat no argument as "undefined" in RegExp.test.
Alexandre Julliard
julliard at winehq.org
Thu May 27 10:46:39 CDT 2010
Module: wine
Branch: master
Commit: fe86330d7e0df03ae1deb08e258dcd96f0e76e6f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fe86330d7e0df03ae1deb08e258dcd96f0e76e6f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 26 19:17:58 2010 +0200
jscript: Treat no argument as "undefined" in RegExp.test.
---
dlls/jscript/regexp.c | 15 ++++++++++++++-
dlls/jscript/tests/regexp.js | 6 ++++++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c
index 2abf1f8..da23f5c 100644
--- a/dlls/jscript/regexp.c
+++ b/dlls/jscript/regexp.c
@@ -101,6 +101,7 @@ static const WCHAR leftContextW[] =
static const WCHAR rightContextW[] =
{'r','i','g','h','t','C','o','n','t','e','x','t',0};
+static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
static const WCHAR emptyW[] = {0};
/* FIXME: Better error handling */
@@ -3717,12 +3718,24 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
match_result_t match;
+ VARIANT undef_var;
VARIANT_BOOL b;
+ DWORD argc;
HRESULT hres;
TRACE("\n");
- hres = run_exec(ctx, jsthis, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, NULL, &match, NULL, NULL, &b);
+ argc = arg_cnt(dp);
+ if(!argc) {
+ V_VT(&undef_var) = VT_BSTR;
+ V_BSTR(&undef_var) = SysAllocString(undefinedW);
+ if(!V_BSTR(&undef_var))
+ return E_OUTOFMEMORY;
+ }
+
+ hres = run_exec(ctx, jsthis, argc ? get_arg(dp,0) : &undef_var, ei, NULL, &match, NULL, NULL, &b);
+ if(!argc)
+ SysFreeString(V_BSTR(&undef_var));
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js
index 7b74cb1..eb9a81a 100644
--- a/dlls/jscript/tests/regexp.js
+++ b/dlls/jscript/tests/regexp.js
@@ -96,6 +96,12 @@ ok(m[1] === "test", "m[1] = " + m[1]);
b = /a*/.test();
ok(b === true, "/a*/.test() returned " + b);
+b = /f/.test();
+ok(b === true, "/f/.test() returned " + b);
+
+b = /abc/.test();
+ok(b === false, "/abc/.test() returned " + b);
+
m = "abcabc".match(re = /ca/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
More information about the wine-cvs
mailing list