oleaut32: use setlocale() around sprintfW to force use of period as decimal separator (RESEND)

Alex Villací­s Lasso a_villacis at palosanto.com
Fri Nov 17 12:32:38 CST 2006


On 0.9.25, oleaut32 tests are failing at vartest.c with Spanish locale:

vartest.c:2062: Test failed: VarSub: DECIMAL value 31,000000, expected 
-15,200000
fixme:variant:VarMod Could not convert left type 4096 to 20? rc == 
0x80020008
fixme:variant:VarMod Could not convert left type 8192 to 20? rc == 
0x80020008
fixme:variant:VarMod Could not convert left type 16384 to 20? rc == 
0x80020008
vartest.c:4779: Test failed: VarMul: DECIMAL value 462,000000, expected 
46,200000
fixme:variant:VarAdd cannot handle variant type VT_DISPATCH
fixme:variant:VarAdd cannot handle variant type VT_DISPATCH
fixme:variant:VarAdd cannot handle variant type VT_DISPATCH
...
fixme:variant:VarAdd cannot handle variant type VT_DISPATCH
vartest.c:4979: Test failed: VarAdd: DECIMAL value -53,000000, expected 
-15,200000
make: *** [vartest.ok] Error 3

I think the root cause of this is that kernel32/locale.c does an 
setlocale(LC_ALL, "") on startup. This causes all uses of *printf() from 
glibc to use the decimal separator from the current locale (which is a 
comma in Spanish locales). This, in turn, causes sprintfW to produce, 
say "0,25", when given 0.25 as the input to %f. All functions that 
depend on sprintfW behaving as in an English locale (the "C" locale) 
break because of this. Here is a patch to fix some of the breakage in 
oleaut32.

BTW, I see many attempts of VarAdd(VT_DISPATCH, ...) tested. All of them 
are expected to fail. However, the tax app does just that 
(VarAdd(VT_DISPATCH, ...)) and fails to display a print preview because 
of this. I think that native oleaut32 fails these tests, not because it 
does not support VarAdd(VT_DISPATCH) at all, but because these 
VT_DISPATCHs are incorrectly formed (as in, just zeroing the variant, 
then assigning VT_DISPATCH as variant type). I need to confirm this with 
a test program.

Changelog:
* Bracket uses of sprintfW with calls to setlocale(LC_ALL) in order to 
guarantee that sprintfW actually uses a period as a decimal separator. 
Fixes number formatting on Spanish locales.

-- 
The following cryptic message was allegedly found in the inner edge of a Windows
XP installation CD:

4F6E65204F5320746F2072756C65207468656D20616C6C2C204F6E65204F5320746F2066696E6420
7468656D2C0D0A4F6E65204F5320746F206272696E67207468656D20616C6C20616E6420696E2074
6865206461726B6E6573732062696E64207468656D2E0A

It is rumored that only a true Unix Wizard can decypher this mysterious message,
which supposedly encodes the true nature and purpose of the software.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-oleaut32-vartype-setlocale-bracket.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20061117/eed1c413/wine-oleaut32-vartype-setlocale-bracket.bin


More information about the wine-patches mailing list