Alistair Leslie-Hughes : vbscript: Coerce datatype in StrComp.
Alexandre Julliard
julliard at winehq.org
Thu Nov 10 14:37:53 CST 2016
Module: wine
Branch: master
Commit: 73924a45d6c674ae6eb729fb10207d896a1a8c72
URL: http://source.winehq.org/git/wine.git/?a=commit;h=73924a45d6c674ae6eb729fb10207d896a1a8c72
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Tue Nov 8 07:06:15 2016 +0000
vbscript: Coerce datatype in StrComp.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vbscript/global.c | 20 +++++++++++++-------
dlls/vbscript/tests/api.vbs | 9 +++++++++
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index a1ffa50..7e14776 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -1038,11 +1038,6 @@ static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *args, unsigned args_cnt,
assert(args_cnt == 2 || args_cnt == 3);
- if(V_VT(args) != VT_BSTR || V_VT(args+1) != VT_BSTR) {
- FIXME("args[0] = %s, args[1] = %s\n", debugstr_variant(args), debugstr_variant(args+1));
- return E_NOTIMPL;
- }
-
if (args_cnt == 3) {
hres = to_int(args+2, &mode);
if(FAILED(hres))
@@ -1056,11 +1051,22 @@ static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *args, unsigned args_cnt,
else
mode = 0;
- left = V_BSTR(args);
- right = V_BSTR(args+1);
+ hres = to_string(args, &left);
+ if(FAILED(hres))
+ return hres;
+
+ hres = to_string(args+1, &right);
+ if(FAILED(hres))
+ {
+ SysFreeString(left);
+ return hres;
+ }
ret = mode ? strcmpiW(left, right) : strcmpW(left, right);
val = ret < 0 ? -1 : (ret > 0 ? 1 : 0);
+
+ SysFreeString(left);
+ SysFreeString(right);
return return_short(res, val);
}
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 91d34ce..f6b6f69 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -459,6 +459,15 @@ TestStrComp "ABCD", "ABC", 1, 1
TestStrComp "ABC", "ABCD", 1, -1
TestStrComp "ABC", "ABCD", "0", -1
TestStrComp "ABC", "ABCD", "1", -1
+TestStrComp 1, 1, 1, 0
+TestStrComp "1", 1, 1, 0
+TestStrComp "1", 1.0, 1, 0
+TestStrComp Empty, Empty, 1, 0
+TestStrComp Empty, "", 1, 0
+TestStrComp Empty, "ABC", 1, -1
+TestStrComp "ABC", Empty, 1, 1
+TestStrComp vbNull, vbNull, 1, 0
+TestStrComp "", vbNull, 1, -1
Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
Call ok(Len("") = 0, "Len() = " & Len(""))
More information about the wine-cvs
mailing list