Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
10f0ace4
Commit
10f0ace4
authored
Sep 09, 2005
by
Alex Villacís Lasso
Committed by
Alexandre Julliard
Sep 09, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Single|Double->BSTR conversion use the specified locale for the
decimal point even without the LOCALE_USE_NLS flag. Test supplied.
parent
840eca52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletion
+68
-1
vartype.c
dlls/oleaut32/tests/vartype.c
+20
-0
vartype.c
dlls/oleaut32/vartype.c
+48
-1
No files found.
dlls/oleaut32/tests/vartype.c
View file @
10f0ace4
...
...
@@ -4596,7 +4596,10 @@ static void test_VarBstrFromR4(void)
{
static
const
WCHAR
szNative
[]
=
{
'6'
,
'5'
,
'4'
,
'3'
,
'2'
,
'2'
,
'.'
,
'3'
,
'\0'
};
static
const
WCHAR
szZero
[]
=
{
'0'
,
'\0'
};
static
const
WCHAR
szOneHalf_English
[]
=
{
'0'
,
'.'
,
'5'
,
'\0'
};
/* uses period */
static
const
WCHAR
szOneHalf_Spanish
[]
=
{
'0'
,
','
,
'5'
,
'\0'
};
/* uses comma */
LCID
lcid
;
LCID
lcid_spanish
;
HRESULT
hres
;
BSTR
bstr
=
NULL
;
...
...
@@ -4605,6 +4608,7 @@ static void test_VarBstrFromR4(void)
CHECKPTR
(
VarBstrFromR4
);
lcid
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
lcid_spanish
=
MAKELCID
(
MAKELANGID
(
LANG_SPANISH
,
SUBLANG_SPANISH
),
SORT_DEFAULT
);
f
=
654322
.
23456
f
;
hres
=
pVarBstrFromR4
(
f
,
lcid
,
0
,
&
bstr
);
ok
(
hres
==
S_OK
,
"got hres 0x%08lx
\n
"
,
hres
);
...
...
@@ -4626,6 +4630,22 @@ static void test_VarBstrFromR4(void)
{
ok
(
memcmp
(
bstr
,
szZero
,
sizeof
(
szZero
))
==
0
,
"negative zero (got %s)
\n
"
,
wtoascii
(
bstr
));
}
/* The following tests that lcid is used for decimal separator even without LOCALE_USE_NLS */
f
=
0
.
5
;
hres
=
pVarBstrFromR4
(
f
,
lcid
,
0
,
&
bstr
);
ok
(
hres
==
S_OK
,
"got hres 0x%08lx
\n
"
,
hres
);
if
(
bstr
)
{
ok
(
memcmp
(
bstr
,
szOneHalf_English
,
sizeof
(
szOneHalf_English
))
==
0
,
"English locale failed (got %s)
\n
"
,
wtoascii
(
bstr
));
}
f
=
0
.
5
;
hres
=
pVarBstrFromR4
(
f
,
lcid_spanish
,
0
,
&
bstr
);
ok
(
hres
==
S_OK
,
"got hres 0x%08lx
\n
"
,
hres
);
if
(
bstr
)
{
ok
(
memcmp
(
bstr
,
szOneHalf_Spanish
,
sizeof
(
szOneHalf_Spanish
))
==
0
,
"Spanish locale failed (got %s)
\n
"
,
wtoascii
(
bstr
));
}
}
#define BSTR_DATE(dt,str) SysFreeString(bstr); bstr = NULL; \
...
...
dlls/oleaut32/vartype.c
View file @
10f0ace4
...
...
@@ -5442,7 +5442,54 @@ static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
*
pbstrOut
=
SysAllocString
(
numbuff
);
}
else
*
pbstrOut
=
SysAllocString
(
buff
);
{
WCHAR
lpDecimalSep
[
16
];
/* Native oleaut32 uses the locale-specific decimal separator even in the
absence of the LOCALE_USE_NLS flag. For example, the Spanish/Latin
American locales will see "one thousand and one tenth" as "1000,1"
instead of "1000.1" (notice the comma). The following code checks for
the need to replace the decimal separator, and if so, will prepare an
appropriate NUMBERFMTW structure to do the job via GetNumberFormatW().
*/
GetLocaleInfoW
(
lcid
,
LOCALE_SDECIMAL
,
lpDecimalSep
,
sizeof
(
lpDecimalSep
)
/
sizeof
(
WCHAR
));
if
(
lpDecimalSep
[
0
]
==
'.'
&&
lpDecimalSep
[
1
]
==
'\0'
)
{
/* locale is compatible with English - return original string */
*
pbstrOut
=
SysAllocString
(
buff
);
}
else
{
WCHAR
*
p
;
WCHAR
numbuff
[
256
];
WCHAR
empty
[
1
]
=
{
'\0'
};
NUMBERFMTW
minFormat
;
minFormat
.
NumDigits
=
0
;
minFormat
.
LeadingZero
=
0
;
minFormat
.
Grouping
=
0
;
minFormat
.
lpDecimalSep
=
lpDecimalSep
;
minFormat
.
lpThousandSep
=
empty
;
minFormat
.
NegativeOrder
=
1
;
/* NLS_NEG_LEFT */
/* count number of decimal digits in string */
p
=
strchrW
(
buff
,
'.'
);
if
(
p
)
minFormat
.
NumDigits
=
strlenW
(
p
+
1
);
numbuff
[
0
]
=
'\0'
;
if
(
!
GetNumberFormatW
(
lcid
,
dwFlags
&
LOCALE_NOUSEROVERRIDE
,
buff
,
&
minFormat
,
numbuff
,
sizeof
(
numbuff
)
/
sizeof
(
WCHAR
)))
{
WARN
(
"GetNumberFormatW() failed, returning raw number string instead
\n
"
);
*
pbstrOut
=
SysAllocString
(
buff
);
}
else
{
TRACE
(
"created minimal NLS string %s
\n
"
,
debugstr_w
(
numbuff
));
*
pbstrOut
=
SysAllocString
(
numbuff
);
}
}
}
return
*
pbstrOut
?
S_OK
:
E_OUTOFMEMORY
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment