[PATCH] vbscript: Coerce datatype in StrComp

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Nov 8 01:06:15 CST 2016


Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 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(""))
-- 
2.7.4




More information about the wine-patches mailing list