[PATCH 01/10] vbscript: Fixed CBool(try 3)

Shuai Meng mengshuaicalendr at gmail.com
Mon Apr 28 22:21:19 CDT 2014


2014-04-29 0:04 GMT+08:00 Piotr Caban <piotr.caban at gmail.com>:

> On 04/28/14 17:26, Shuai Meng wrote:
>
>>
>>
>>
>> 2014-04-21 17:18 GMT+08:00 Jacek Caban <jacek at codeweavers.com
>> <mailto:jacek at codeweavers.com>>:
>>
>>
>>     Hi Shuai,
>>
>>     On 04/21/14 03:45, Shuai Meng wrote:
>>      > -
>>      > -    return return_bool(res, val);
>>      > +    V_VT(res) = VT_EMPTY;
>>      > +    return VariantChangeType(res, arg, VARIANT_LOCALBOOL,
>> VT_BOOL);
>>
>>     You can't assume that res is not NULL. If result of the function is
>> not
>>     used, it will be NULL. A simple test case is like this:
>>
>>     call CBool(0)
>>
>>     Also, are you sure we want VARIANT_LOCALBOOL here? Did you test it
>>     (probably by running tests on localized Windows with translated string
>>     "False")?
>>
>>   I don't quite understand what this parameter means, in fact I just
>> copy it from to_string(). If not VARIANT_LOCALBOOL, waht esle should be
>> filled here?
>>
>
> I've checked what happens on non-english locale and CStr(True) = "True".
> So the flag is used incorrectly in CStr implementation. CBool is also
> failing when localized string is passed.
>
> You can use 0 as flag in VariantChangeType.
>

I've fixed this, but another problem appears. I put my new patch in the
attachment, along with the test result of wine. It fails when tested in
wine, while normal in my windows. I can't understand, this patch is almost
the same with the previous one.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140429/ee52c59d/attachment.html>
-------------- next part --------------
From 0aa2a29a3103ae5a7cbdb7c8ac50f1551f7db69c Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Tue, 29 Apr 2014 11:09:49 +0800
Subject: [PATCH] vbscript: Fixed CBool
To: wine-patches <wine-patches at winehq.org>
Reply-To: wine-devel <wine-devel at winehq.org>
Cc: Shuai Meng<mengshuaicalendr at gmail.com>

---
 dlls/vbscript/global.c      | 33 ++++-----------------------------
 dlls/vbscript/tests/api.vbs | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 9983509..8eab9e6 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -114,16 +114,6 @@ static HRESULT return_int(VARIANT *res, int val)
     return S_OK;
 }
 
-static HRESULT return_bool(VARIANT *res, int val)
-{
-    if(res) {
-        V_VT(res) = VT_BOOL;
-        V_BOOL(res) = val != 0 ? VARIANT_TRUE : VARIANT_FALSE;
-    }
-
-    return S_OK;
-}
-
 static inline HRESULT return_double(VARIANT *res, double val)
 {
     if(res) {
@@ -413,30 +403,15 @@ static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    int val;
     TRACE("%s\n", debugstr_variant(arg));
 
     assert(args_cnt == 1);
 
-    switch(V_VT(arg)) {
-    case VT_I2:
-        val = V_I2(arg);
-        break;
-    case VT_I4:
-        val = V_I4(arg);
-        break;
-    case VT_R4:
-	val = V_R4(arg) > 0.0 || V_R4(arg) < 0.0;
-        break;
-    case VT_R8:
-        val = V_R8(arg) > 0.0 || V_R8(arg) < 0.0;
-        break;
-    default:
-        ERR("Not a numeric value: %s\n", debugstr_variant(arg));
-        return E_FAIL;
-    }
+    if(!res)
+        return S_OK;
 
-    return return_bool(res, val);
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, 0, VT_BOOL);
 }
 
 static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 3c496b1..ea698b0 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -464,4 +464,28 @@ Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
 Call ok(CBool(-5) = true, "CBool(-5) = " & CBool(-5))
 Call ok(getVT(CBool(-5)) = "VT_BOOL", "getVT(CBool(-5)) = " & getVT(CBool(-5)))
 
+Class ValClass
+    Public myval
+
+    Public default Property Get defprop
+        defprop = myval
+    End Property
+End Class
+
+Dim MyObject
+Set MyObject = New ValClass
+
+Call ok(CBool(Empty) = False, "CBool(Empty) = " & CBool(Empty))
+Call ok(getVT(CBool(Empty)) = "VT_BOOL", "getVT(CBool(Empty)) = " & getVT(CBool(Empty)))
+Call ok(CBool(1) = True, "CBool(1) = " & CBool(1))
+Call ok(getVT(CBool(1)) = "VT_BOOL", "getVT(CBool(1)) = " & getVT(CBool(1)))
+Call ok(CBool(0) = False, "CBool(0) = " & CBool(0))
+Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
+Call ok(CBool(-0.56) = True, "CBool(-0.56) = " & CBool(-0.56))
+Call ok(getVT(CBool(-0.56)) = "VT_BOOL", "getVT(CBool(-0.56)) = " & getVT(CBool(-0.56)))
+Call ok(CBool("-1") = True, "CBool(""-1"") = " & CBool("-1"))
+Call ok(getVT(CBool("-1")) = "VT_BOOL", "getVT(CBool(""-1"")) = " & getVT(CBool("-1")))
+Call ok(CBool(MyObject) = False, "CBool(MyObject) = " & CBool(MyObject))
+Call ok(getVT(CBool(MyObject)) = "VT_BOOL", "getVT(CBool(MyObject)) = " & getVT(CBool(MyObject)))
+
 Call reportSuccess()
-- 
1.8.1.2

-------------- next part --------------
fixme:thread:GetThreadUILanguage : stub, returning default language.
run.c:2056: Tests skipped: Skipping some tests in non-English locale
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
run.c:1172: Test marked todo: rgvarg == NULL
fixme:vbscript:parse_script parser failed around L"<!--"
fixme:vbscript:do_icall L"y" not found
fixme:vbscript:DispatchEx_InvokeEx flags 2
fixme:vbscript:DispatchEx_InvokeEx flags 2
fixme:vbscript:DispatchEx_InvokeEx no letter/setter
run.c:445: Test marked todo: safearray->fFeatures = 880
run.c:445: Test marked todo: safearray->fFeatures = 880
run.c:445: Test marked todo: safearray->fFeatures = 880
run.c:445: Test marked todo: safearray->fFeatures = 880
fixme:vbscript:DispatchEx_Invoke (0x17d1b8)->(0 {00000000-0000-0000-0000-000000000000} 1024 2 0x7ebe8d10 0x32f650 (nil) (nil))
run.c:1871: Test failed: expected global_success_d
run.c:1872: Test failed: expected global_success_i
run.c:1874: Test failed: parse_script failed: 800a000d
fixme:vbscript:ClassFactory_QueryInterface (0x7d1de2ec)->({342d1ea0-ae25-11d1-89c5-006008c3fbfc} 0x32f79c)
fixme:vbscript:RegExp2_QueryInterface (0x131978)->({fc4801a3-2ba9-11cf-a229-00aa003d7352} 0x32f72c)
fixme:vbscript:interp_enumnext uninitialized
fixme:vbscript:interp_newenum Unsupported for {VT_EMPTY}
fixme:vbscript:interp_enumnext uninitialized
fixme:vbscript:show_msgbox failed: 80004005
fixme:vbscript:show_msgbox blocked
run: 16659 tests executed (14 marked as todo, 3 failures), 1 skipped.


More information about the wine-devel mailing list