OLEAUT32: VarDecFromR[4|8] must use same locale through conversion.

Alex Villaci­s Lasso a_villacis at palosanto.com
Thu Mar 24 09:50:00 CST 2005


 > BTW, in Wine-20050310, the Float->Decimal conversion tests all fail, 
can somebody look into this?

I should have made myself clearer. The Float->Decimal conversion tests 
all fail *in my locale*. They "pass" when the locale is set to en_US.

I cheched into the VarDecFromR[4|8] functions in 
dlls/oleaut32/vartype.c, and found the following: the conversion from 
Float|Double -> Decimal variant types is implemented as a conversion 
from Float|Double to a string, followed by a parsing of the resulting 
string in order to fill the Decimal. The routines use sprintfW() for the 
float to string conversion, and then _VarDecFromStr() for the 
string->Decimal conversion. In both cases, the second conversion is 
instructed to use LOCALE_USER_DEFAULT or LOCALE_SYSTEM_DEFAULT.

The catch is, sprintfW() seems to format the float with a period as a 
decimal separator, regardless of the locale setting. This poses no 
problem to the en_US locale, but breaks the conversion in locales like 
my own (es_EC) which reverse the characters used as the thousand 
separator and the decimal separator. IMHO, the quick-and-dirty solution 
to this is to force the string->Decimal conversion to use the en_US 
locale, since the temporary string is not meant to be displayed by the 
calling application. I was thinking about modifying sprintfW() to obey 
the locale, but there seems to be code elsewhere that assumes sprintfW() 
will use a fixed convention for floating-point numbers. The attached 
patch implements the en_US locale solution.

Changelog:
* After Float->string conversion via sprintfW(), VarDecFromR[4|8] is 
forced to use US locale for string->Decimal conversion, to agree with 
sprintfW().

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-oleaut32-vartype-sync-temp-locale.patch
Type: text/x-patch
Size: 990 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050324/16736783/wine-oleaut32-vartype-sync-temp-locale.bin


More information about the wine-patches mailing list