Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
9afc2094
Commit
9afc2094
authored
May 03, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Reimplement GetCurrencyFormatW/Ex() using get_locale_info().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
56099a31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
229 additions
and
4 deletions
+229
-4
kernel32.spec
dlls/kernel32/kernel32.spec
+2
-2
lcformat.c
dlls/kernel32/lcformat.c
+0
-0
locale.c
dlls/kernel32/tests/locale.c
+20
-0
kernelbase.spec
dlls/kernelbase/kernelbase.spec
+2
-2
locale.c
dlls/kernelbase/locale.c
+205
-0
No files found.
dlls/kernel32/kernel32.spec
View file @
9afc2094
...
...
@@ -621,8 +621,8 @@
@ stdcall -import GetConsoleTitleW(ptr long)
@ stdcall -import GetConsoleWindow()
@ stdcall GetCurrencyFormatA(long long str ptr ptr long)
@ stdcall GetCurrencyFormatEx(wstr long wstr ptr ptr long)
@ stdcall GetCurrencyFormatW(long long wstr ptr ptr long)
@ stdcall
-import
GetCurrencyFormatEx(wstr long wstr ptr ptr long)
@ stdcall
-import
GetCurrencyFormatW(long long wstr ptr ptr long)
@ stdcall -import GetCurrentActCtx(ptr)
@ stdcall -import GetCurrentConsoleFont(long long ptr)
@ stdcall -import GetCurrentConsoleFontEx(long long ptr)
...
...
dlls/kernel32/lcformat.c
View file @
9afc2094
This diff is collapsed.
Click to expand it.
dlls/kernel32/tests/locale.c
View file @
9afc2094
...
...
@@ -1307,6 +1307,18 @@ static void test_GetCurrencyFormatA(void)
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"235"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$235.0"
);
format
.
Grouping
=
31
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"1234567890"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$1,2,3,4,5,6,7,890.0"
);
format
.
Grouping
=
312
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"1234567890"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$12,34,56,7,890.0"
);
format
.
Grouping
=
310
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"1234567890"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$123456,7,890.0"
);
/* Grouping of a negative number */
format
.
NegativeOrder
=
2
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"-235"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
...
...
@@ -1316,6 +1328,14 @@ static void test_GetCurrencyFormatA(void)
format
.
LeadingZero
=
1
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
".5"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$0.5"
);
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"0.5"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$0.5"
);
format
.
LeadingZero
=
0
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"0.5"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$.5"
);
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"0.5"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
expect_str
(
ret
,
buffer
,
"$.5"
);
format
.
PositiveOrder
=
CY_POS_RIGHT
;
ret
=
GetCurrencyFormatA
(
lcid
,
0
,
"1"
,
&
format
,
buffer
,
ARRAY_SIZE
(
buffer
));
...
...
dlls/kernelbase/kernelbase.spec
View file @
9afc2094
...
...
@@ -473,8 +473,8 @@
@ stdcall GetConsoleTitleA(ptr long)
@ stdcall GetConsoleTitleW(ptr long)
@ stdcall GetConsoleWindow()
@ stdcall GetCurrencyFormatEx(wstr long wstr ptr ptr long)
kernel32.GetCurrencyFormatEx
@ stdcall GetCurrencyFormatW(long long wstr ptr ptr long)
kernel32.GetCurrencyFormatW
@ stdcall GetCurrencyFormatEx(wstr long wstr ptr ptr long)
@ stdcall GetCurrencyFormatW(long long wstr ptr ptr long)
@ stdcall GetCurrentActCtx(ptr)
# @ stub GetCurrentApplicationUserModelId
@ stdcall GetCurrentConsoleFont(long long ptr)
...
...
dlls/kernelbase/locale.c
View file @
9afc2094
...
...
@@ -6655,6 +6655,172 @@ static int get_number_format( const NLS_LOCALE_DATA *locale, DWORD flags, const
}
static
int
get_currency_format
(
const
NLS_LOCALE_DATA
*
locale
,
DWORD
flags
,
const
WCHAR
*
value
,
const
CURRENCYFMTW
*
format
,
WCHAR
*
buffer
,
int
len
)
{
WCHAR
*
num
,
fmt_decimal
[
4
],
fmt_thousand
[
4
],
fmt_symbol
[
13
],
fmt_neg
[
5
],
grouping
[
20
],
output
[
256
];
const
WCHAR
*
decimal_sep
=
fmt_decimal
,
*
thousand_sep
=
fmt_thousand
,
*
symbol
=
fmt_symbol
;
DWORD
digits
,
lzero
,
pos_order
,
neg_order
;
int
ret
=
0
;
BOOL
negative
=
(
*
value
==
'-'
);
flags
&=
LOCALE_NOUSEROVERRIDE
;
if
(
!
format
)
{
get_locale_info
(
locale
,
0
,
LOCALE_SCURRENCY
|
flags
,
fmt_symbol
,
ARRAY_SIZE
(
fmt_symbol
)
);
get_locale_info
(
locale
,
0
,
LOCALE_SMONGROUPING
|
flags
,
grouping
,
ARRAY_SIZE
(
grouping
)
);
get_locale_info
(
locale
,
0
,
LOCALE_SMONDECIMALSEP
|
flags
,
fmt_decimal
,
ARRAY_SIZE
(
fmt_decimal
)
);
get_locale_info
(
locale
,
0
,
LOCALE_SMONTHOUSANDSEP
|
flags
,
fmt_thousand
,
ARRAY_SIZE
(
fmt_thousand
)
);
get_locale_info
(
locale
,
0
,
LOCALE_ICURRDIGITS
|
LOCALE_RETURN_NUMBER
|
flags
,
(
WCHAR
*
)
&
digits
,
sizeof
(
DWORD
)
/
sizeof
(
WCHAR
)
);
get_locale_info
(
locale
,
0
,
LOCALE_ILZERO
|
LOCALE_RETURN_NUMBER
|
flags
,
(
WCHAR
*
)
&
lzero
,
sizeof
(
DWORD
)
/
sizeof
(
WCHAR
)
);
get_locale_info
(
locale
,
0
,
LOCALE_ICURRENCY
|
LOCALE_RETURN_NUMBER
|
flags
,
(
WCHAR
*
)
&
pos_order
,
sizeof
(
DWORD
)
/
sizeof
(
WCHAR
)
);
get_locale_info
(
locale
,
0
,
LOCALE_INEGCURR
|
LOCALE_RETURN_NUMBER
|
flags
,
(
WCHAR
*
)
&
neg_order
,
sizeof
(
DWORD
)
/
sizeof
(
WCHAR
)
);
}
else
{
if
(
flags
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
decimal_sep
=
format
->
lpDecimalSep
;
thousand_sep
=
format
->
lpThousandSep
;
symbol
=
format
->
lpCurrencySymbol
;
grouping_to_string
(
format
->
Grouping
,
grouping
);
digits
=
format
->
NumDigits
;
lzero
=
format
->
LeadingZero
;
pos_order
=
format
->
PositiveOrder
;
neg_order
=
format
->
NegativeOrder
;
if
(
!
decimal_sep
||
!
thousand_sep
||
!
symbol
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
}
if
(
negative
)
{
value
++
;
get_locale_info
(
locale
,
0
,
LOCALE_SNEGATIVESIGN
|
flags
,
fmt_neg
,
ARRAY_SIZE
(
fmt_neg
)
);
}
if
(
!
(
num
=
format_number
(
output
+
ARRAY_SIZE
(
output
)
-
20
,
value
,
decimal_sep
,
thousand_sep
,
grouping
,
digits
,
lzero
)))
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
negative
)
{
switch
(
neg_order
)
{
case
14
:
/* ($ 1.1) */
num
=
prepend_str
(
num
,
L" "
);
/* fall through */
case
0
:
/* ($1.1) */
num
=
prepend_str
(
num
,
symbol
);
num
=
prepend_str
(
num
,
L"("
);
wcscat
(
num
,
L")"
);
break
;
case
9
:
/* -$ 1.1 */
num
=
prepend_str
(
num
,
L" "
);
/* fall through */
case
1
:
/* -$1.1 */
num
=
prepend_str
(
num
,
symbol
);
num
=
prepend_str
(
num
,
fmt_neg
);
break
;
case
2
:
/* $-1.1 */
num
=
prepend_str
(
num
,
fmt_neg
);
num
=
prepend_str
(
num
,
symbol
);
break
;
case
11
:
/* $ 1.1- */
num
=
prepend_str
(
num
,
L" "
);
/* fall through */
case
3
:
/* $1.1- */
num
=
prepend_str
(
num
,
symbol
);
wcscat
(
num
,
fmt_neg
);
break
;
case
15
:
/* (1.1 $) */
wcscat
(
num
,
L" "
);
/* fall through */
case
4
:
/* (1.1$) */
wcscat
(
num
,
symbol
);
num
=
prepend_str
(
num
,
L"("
);
wcscat
(
num
,
L")"
);
break
;
case
8
:
/* -1.1 $ */
wcscat
(
num
,
L" "
);
/* fall through */
case
5
:
/* -1.1$ */
num
=
prepend_str
(
num
,
fmt_neg
);
wcscat
(
num
,
symbol
);
break
;
case
6
:
/* 1.1-$ */
wcscat
(
num
,
fmt_neg
);
wcscat
(
num
,
symbol
);
break
;
case
10
:
/* 1.1 $- */
wcscat
(
num
,
L" "
);
/* fall through */
case
7
:
/* 1.1$- */
wcscat
(
num
,
symbol
);
wcscat
(
num
,
fmt_neg
);
break
;
case
12
:
/* $ -1.1 */
num
=
prepend_str
(
num
,
fmt_neg
);
num
=
prepend_str
(
num
,
L" "
);
num
=
prepend_str
(
num
,
symbol
);
break
;
case
13
:
/* 1.1- $ */
wcscat
(
num
,
fmt_neg
);
wcscat
(
num
,
L" "
);
wcscat
(
num
,
symbol
);
break
;
default
:
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
}
else
{
switch
(
pos_order
)
{
case
2
:
/* $ 1.1 */
num
=
prepend_str
(
num
,
L" "
);
/* fall through */
case
0
:
/* $1.1 */
num
=
prepend_str
(
num
,
symbol
);
break
;
case
3
:
/* 1.1 $ */
wcscat
(
num
,
L" "
);
/* fall through */
case
1
:
/* 1.1$ */
wcscat
(
num
,
symbol
);
break
;
default
:
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
}
ret
=
wcslen
(
num
)
+
1
;
if
(
!
len
)
return
ret
;
lstrcpynW
(
buffer
,
num
,
len
);
if
(
ret
>
len
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
return
ret
;
}
/**************************************************************************
* GetNumberFormatW (kernelbase.@)
*/
...
...
@@ -6692,3 +6858,42 @@ int WINAPI GetNumberFormatEx( const WCHAR *name, DWORD flags, const WCHAR *value
TRACE
(
"(%s,%lx,%s,%p,%p,%d)
\n
"
,
debugstr_w
(
name
),
flags
,
debugstr_w
(
value
),
format
,
buffer
,
len
);
return
get_number_format
(
locale
,
flags
,
value
,
format
,
buffer
,
len
);
}
/***********************************************************************
* GetCurrencyFormatW (kernelbase.@)
*/
int
WINAPI
GetCurrencyFormatW
(
LCID
lcid
,
DWORD
flags
,
const
WCHAR
*
value
,
const
CURRENCYFMTW
*
format
,
WCHAR
*
buffer
,
int
len
)
{
const
NLS_LOCALE_DATA
*
locale
=
NlsValidateLocale
(
&
lcid
,
0
);
if
(
len
<
0
||
(
len
&&
!
buffer
)
||
!
value
||
!
locale
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
TRACE
(
"(%04lx,%lx,%s,%p,%p,%d)
\n
"
,
lcid
,
flags
,
debugstr_w
(
value
),
format
,
buffer
,
len
);
return
get_currency_format
(
locale
,
flags
,
value
,
format
,
buffer
,
len
);
}
/***********************************************************************
* GetCurrencyFormatEx (kernelbase.@)
*/
int
WINAPI
GetCurrencyFormatEx
(
const
WCHAR
*
name
,
DWORD
flags
,
const
WCHAR
*
value
,
const
CURRENCYFMTW
*
format
,
WCHAR
*
buffer
,
int
len
)
{
LCID
lcid
;
const
NLS_LOCALE_DATA
*
locale
=
get_locale_by_name
(
name
,
&
lcid
);
if
(
len
<
0
||
(
len
&&
!
buffer
)
||
!
value
||
!
locale
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
TRACE
(
"(%s,%lx,%s,%p,%p,%d)
\n
"
,
debugstr_w
(
name
),
flags
,
debugstr_w
(
value
),
format
,
buffer
,
len
);
return
get_currency_format
(
locale
,
flags
,
value
,
format
,
buffer
,
len
);
}
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