[PATCH] vbscript: Fixed CBool

Piotr Caban piotr.caban at gmail.com
Tue Apr 29 09:25:10 CDT 2014


On 04/29/14 16:04, Shuai Meng wrote:
>
> Thank you for commenting.
>
> 2014-04-29 21:30 GMT+08:00 Piotr Caban <piotr.caban at gmail.com
> <mailto:piotr.caban at gmail.com>>:
>
>     On 04/29/14 15:06, Shuai Meng wrote:
>
>         +    if(!res)
>         +        return S_OK;
>
>     You can't return early if res is NULL. You still need to do the
>     conversion and return error if it fails.
>
> I  don't quite get it, do you mean I should do like this:
> if(res)
> {
> ....
> }
> return S_OK;
No, I mean that you should do something like this:
VARIANT v;
...
V_VT(&v) = VT_EMPTY;
hr = VariantChangeType(..., &v);
if(FAILED(hr))
     return hr;
...
if(res)
     *res = v;
else
     VariantClear(&v);

>     It would be nice to add following tests (these are the tests Jacek
>     was asking for):
>
>     Call ok(CBool("True") = true, "CBool(""True"") = " & CBool("True"))
>     Call ok(CBool("fAlSe") = false, "CBool(""fAlSe"") = " & CBool("fAlSe"))
>
>
>   I do notice it, but they failed in testbot. Just as MSDN says, If
> /expression/ can't be interpreted as a numeric value, a run-time error
> occurs.
You must have done something else incorrectly. Here's a run that 
succeeded: https://testbot.winehq.org/JobDetails.pl?Key=6665. It shows 
that CBool("True") returns true.

>     sub testCBoolError
>          on error resume next
>
>          call Err.clear()
>          call CBool("#FALSE#")
>          call ok(Err.number = 458, "Err.number = " & Err.number)
>     end sub
>     Call testCBoolError
>
> Is this function written to provoke an error on purpose in order to test
> CBool("#FALSE#")?
It's meant to handle error returned by CBool("#FALSE#"). Other invalid 
parameters may be tested in the same way.

Cheers,
Piotr



More information about the wine-devel mailing list