OLEAUT32: Implement VarIdiv

Daniel Remenak dtremenak at gmail.com
Tue Apr 12 14:44:49 CDT 2005


ChangeLog:
Implement VarIdiv

This patch implements variant integer-converted division.
Correctness verified with a small test program at
http://dtremenak.bakadigital.com/varidivtest-bin.zip (binary and
output on w2k and wine)
http://dtremenak.bakadigital.com/varidivtest.zip (vc7.1 source)

There are four sources of differences visible when comparing the outputs:
1. Windows' VariantChangeType is buggy, and does not correctly convert
VT_I8 to VT_BSTR, but wine's does.
2. Windows returns DISP_E_BADTYPE when given a VT_I8, while wine
returns DISP_E_OVERFLOW.
3. Windows returns DISP_E_BADTYPE and a VT_EMPTY when given a
non-numeric VT_BSTR and a VT_NULL to divide.  This implementation
returns S_OK and VT_NULL (as per MSDN).
4. Windows will return the quotient of two small types in a VT_I2,
while wine always returns a VT_I4.

#1 is not our problem.  #2 is a trivial difference that I seriously
doubt any application depends on (they're both errors, for goodness
sake).  For #3, this implementation complies with MSDN, which quite
clearly states "If either expression is NULL, NULL is returned". 
Windows also complies with this for everything I've tested EXCEPT
non-numeric bstrings.  #4 is due to wine's existing VarDiv routine
doing the same thing; if this needs to be fixed I can do so in another
patch, but it probably won't be pretty.

All that said, this implementation does match Windows' for all
reasonable values (integers, floats, doubles, empties, numbers as
strings, etc), and it lets the app I have that uses VarIdiv crash a
little bit later rather than sooner.

Oh; this patch also corrects the ordinal number in VarMod's
descriptive comment to match the specfile.

--Daniel Remenak
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varidiv.patch
Type: text/x-patch
Size: 2867 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050412/ced72232/varidiv.bin


More information about the wine-patches mailing list