Piotr Caban : jscript: Make compare2_values working with NULL BSTR's.
Alexandre Julliard
julliard at winehq.org
Thu Aug 6 10:49:10 CDT 2009
Module: wine
Branch: master
Commit: 9d23f8a771a0a4b31784bfdfff6da948a490812a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9d23f8a771a0a4b31784bfdfff6da948a490812a
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Wed Aug 5 23:27:31 2009 +0200
jscript: Make compare2_values working with NULL BSTR's.
---
dlls/jscript/engine.c | 7 ++++++-
dlls/jscript/tests/lang.js | 2 ++
dlls/jscript/tests/run.c | 12 ++++++++++++
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index ff5e6a8..f120cc6 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -304,7 +304,12 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
*ret = V_R8(lval) == V_R8(rval);
break;
case VT_BSTR:
- *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
+ if(!V_BSTR(lval))
+ *ret = SysStringLen(V_BSTR(rval))?FALSE:TRUE;
+ else if(!V_BSTR(rval))
+ *ret = SysStringLen(V_BSTR(lval))?FALSE:TRUE;
+ else
+ *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
break;
case VT_DISPATCH:
return disp_cmp(V_DISPATCH(lval), V_DISPATCH(rval), ret);
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index a9e0459..8150d65 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -896,4 +896,6 @@ ok(""+str === "test", "''+str = " + str);
ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
+ok(createNullBSTR() === '', "createNullBSTR() !== ''");
+
reportSuccess();
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index a1fe3b6..ffbbde3 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -73,6 +73,7 @@ DEFINE_EXPECT(GetItemInfo_testVal);
#define DISPID_GLOBAL_OK 0x1004
#define DISPID_GLOBAL_GETVT 0x1005
#define DISPID_GLOBAL_TESTOBJ 0x1006
+#define DISPID_GLOBAL_NULL_BSTR 0x1007
static const WCHAR testW[] = {'t','e','s','t',0};
static const CHAR testA[] = "test";
@@ -283,6 +284,10 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
*pid = DISPID_GLOBAL_TESTOBJ;
return S_OK;
}
+ if(!strcmp_wa(bstrName, "createNullBSTR")) {
+ *pid = DISPID_GLOBAL_NULL_BSTR;
+ return S_OK;
+ }
if(strict_dispid_check)
ok(0, "unexpected call %s\n", debugstr_w(bstrName));
@@ -429,6 +434,13 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
V_VT(pvarRes) = VT_DISPATCH;
V_DISPATCH(pvarRes) = (IDispatch*)&testObj;
return S_OK;
+
+ case DISPID_GLOBAL_NULL_BSTR:
+ if(pvarRes) {
+ V_VT(pvarRes) = VT_BSTR;
+ V_BSTR(pvarRes) = NULL;
+ }
+ return S_OK;
}
ok(0, "unexpected call %x\n", id);
More information about the wine-cvs
mailing list