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
292e4153
Commit
292e4153
authored
Nov 08, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Simplify EnumDateFormats & EnumDateFormatsEx.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f1324529
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
119 deletions
+100
-119
lcformat.c
dlls/kernel32/lcformat.c
+100
-119
No files found.
dlls/kernel32/lcformat.c
View file @
292e4153
...
...
@@ -1742,93 +1742,126 @@ error:
* alternate calendars is determined.
*/
/**************************************************************************
* EnumDateFormatsExA (KERNEL32.@)
enum
enum_callback_type
{
CALLBACK_ENUMPROC
,
CALLBACK_ENUMPROCEX
,
CALLBACK_ENUMPROCEXEX
};
struct
enumdateformats_context
{
enum
enum_callback_type
type
;
/* callback kind */
union
{
DATEFMT_ENUMPROCW
callback
;
/* user callback pointer */
DATEFMT_ENUMPROCEXW
callbackex
;
}
u
;
LCID
lcid
;
/* locale of interest */
DWORD
flags
;
BOOL
unicode
;
/* A vs W callback type, only for regular and Ex callbacks */
};
/******************************************************************************
* NLS_EnumDateFormats <internal>
* Enumerates date formats for a specified locale.
*
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
* LOCALE_NOUSEROVERRIDE here as well?
* PARAMS
* ctxt [I] enumeration context, see 'struct enumdateformats_context'
*
* RETURNS
* Success: TRUE.
* Failure: FALSE. Use GetLastError() to determine the cause.
*/
BOOL
WINAPI
EnumDateFormatsExA
(
DATEFMT_ENUMPROCEXA
proc
,
LCID
lcid
,
DWORD
flags
)
static
BOOL
NLS_EnumDateFormats
(
const
struct
enumdateformats_context
*
ctxt
)
{
WCHAR
bufW
[
256
];
char
bufA
[
256
];
LCTYPE
lctype
;
CALID
cal_id
;
char
buf
[
256
]
;
INT
ret
;
if
(
!
proc
)
if
(
!
ctxt
->
u
.
callback
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
!
GetLocaleInfoW
(
lcid
,
LOCALE_ICALENDARTYPE
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
cal_id
,
sizeof
(
cal_id
)
/
sizeof
(
WCHAR
)))
if
(
!
GetLocaleInfoW
(
ctxt
->
lcid
,
LOCALE_ICALENDARTYPE
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
cal_id
,
sizeof
(
cal_id
)
/
sizeof
(
WCHAR
)))
return
FALSE
;
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
switch
(
ctxt
->
flags
&
~
LOCALE_USE_CP_ACP
)
{
case
0
:
case
DATE_SHORTDATE
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SSHORTDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
lctype
=
LOCALE_SSHORTDATE
;
break
;
case
DATE_LONGDATE
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SLONGDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
lctype
=
LOCALE_SLONGDATE
;
break
;
case
DATE_YEARMONTH
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SYEARMONTH
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
lctype
=
LOCALE_SYEARMONTH
;
break
;
default:
FIXME
(
"Unknown date format (
%d)
\n
"
,
flags
);
FIXME
(
"Unknown date format (
0x%08x)
\n
"
,
ctxt
->
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
lctype
|=
ctxt
->
flags
&
LOCALE_USE_CP_ACP
;
if
(
ctxt
->
unicode
)
ret
=
GetLocaleInfoW
(
ctxt
->
lcid
,
lctype
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
bufW
[
0
]));
else
ret
=
GetLocaleInfoA
(
ctxt
->
lcid
,
lctype
,
bufA
,
sizeof
(
bufA
)
/
sizeof
(
bufA
[
0
]));
if
(
ret
)
{
switch
(
ctxt
->
type
)
{
case
CALLBACK_ENUMPROC
:
ctxt
->
u
.
callback
(
ctxt
->
unicode
?
bufW
:
(
WCHAR
*
)
bufA
);
break
;
case
CALLBACK_ENUMPROCEX
:
ctxt
->
u
.
callbackex
(
ctxt
->
unicode
?
bufW
:
(
WCHAR
*
)
bufA
,
cal_id
);
break
;
default:
;
}
}
return
TRUE
;
}
/**************************************************************************
* EnumDateFormatsExW (KERNEL32.@)
* EnumDateFormatsExA (KERNEL32.@)
*
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
* LOCALE_NOUSEROVERRIDE here as well?
*/
BOOL
WINAPI
EnumDateFormatsEx
W
(
DATEFMT_ENUMPROCEXW
proc
,
LCID
lcid
,
DWORD
flags
)
BOOL
WINAPI
EnumDateFormatsEx
A
(
DATEFMT_ENUMPROCEXA
proc
,
LCID
lcid
,
DWORD
flags
)
{
CALID
cal_id
;
WCHAR
buf
[
256
];
struct
enumdateformats_context
ctxt
;
if
(
!
proc
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
)
;
return
FALSE
;
}
ctxt
.
type
=
CALLBACK_ENUMPROCEX
;
ctxt
.
u
.
callbackex
=
(
DATEFMT_ENUMPROCEXW
)
proc
;
ctxt
.
lcid
=
lcid
;
ctxt
.
flags
=
flags
;
ctxt
.
unicode
=
FALSE
;
if
(
!
GetLocaleInfoW
(
lcid
,
LOCALE_ICALENDARTYPE
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
cal_id
,
sizeof
(
cal_id
)
/
sizeof
(
WCHAR
)))
return
FALSE
;
return
NLS_EnumDateFormats
(
&
ctxt
);
}
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
{
case
0
:
case
DATE_SHORTDATE
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SSHORTDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
break
;
/**************************************************************************
* EnumDateFormatsExW (KERNEL32.@)
*/
BOOL
WINAPI
EnumDateFormatsExW
(
DATEFMT_ENUMPROCEXW
proc
,
LCID
lcid
,
DWORD
flags
)
{
struct
enumdateformats_context
ctxt
;
case
DATE_LONGDATE
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SLONGDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
break
;
ctxt
.
type
=
CALLBACK_ENUMPROCEX
;
ctxt
.
u
.
callbackex
=
proc
;
ctxt
.
lcid
=
lcid
;
ctxt
.
flags
=
flags
;
ctxt
.
unicode
=
TRUE
;
case
DATE_YEARMONTH
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SYEARMONTH
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
,
cal_id
);
break
;
default:
FIXME
(
"Unknown date format (%d)
\n
"
,
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
return
NLS_EnumDateFormats
(
&
ctxt
);
}
/**************************************************************************
...
...
@@ -1839,38 +1872,15 @@ BOOL WINAPI EnumDateFormatsExW(DATEFMT_ENUMPROCEXW proc, LCID lcid, DWORD flags)
*/
BOOL
WINAPI
EnumDateFormatsA
(
DATEFMT_ENUMPROCA
proc
,
LCID
lcid
,
DWORD
flags
)
{
char
buf
[
256
];
if
(
!
proc
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
{
case
0
:
case
DATE_SHORTDATE
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SSHORTDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
case
DATE_LONGDATE
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SLONGDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
struct
enumdateformats_context
ctxt
;
case
DATE_YEARMONTH
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_SYEARMONTH
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
ctxt
.
type
=
CALLBACK_ENUMPROC
;
ctxt
.
u
.
callback
=
(
DATEFMT_ENUMPROCW
)
proc
;
ctxt
.
lcid
=
lcid
;
ctxt
.
flags
=
flags
;
ctxt
.
unicode
=
FALSE
;
default:
FIXME
(
"Unknown date format (%d)
\n
"
,
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
return
NLS_EnumDateFormats
(
&
ctxt
);
}
/**************************************************************************
...
...
@@ -1878,38 +1888,15 @@ BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
*/
BOOL
WINAPI
EnumDateFormatsW
(
DATEFMT_ENUMPROCW
proc
,
LCID
lcid
,
DWORD
flags
)
{
WCHAR
buf
[
256
];
if
(
!
proc
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
struct
enumdateformats_context
ctxt
;
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
{
case
0
:
case
DATE_SHORTDATE
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SSHORTDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
ctxt
.
type
=
CALLBACK_ENUMPROC
;
ctxt
.
u
.
callback
=
proc
;
ctxt
.
lcid
=
lcid
;
ctxt
.
flags
=
flags
;
ctxt
.
unicode
=
TRUE
;
case
DATE_LONGDATE
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SLONGDATE
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
case
DATE_YEARMONTH
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_SYEARMONTH
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
default:
FIXME
(
"Unknown date format (%d)
\n
"
,
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
return
NLS_EnumDateFormats
(
&
ctxt
);
}
/**************************************************************************
...
...
@@ -1971,14 +1958,8 @@ BOOL WINAPI EnumTimeFormatsW(TIMEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
return
TRUE
;
}
enum
enumcalendar_callback_type
{
CALLBACK_ENUMPROC
,
CALLBACK_ENUMPROCEX
,
CALLBACK_ENUMPROCEXEX
};
struct
enumcalendar_context
{
enum
enum
calendar
_callback_type
type
;
/* callback kind */
enum
enum_callback_type
type
;
/* callback kind */
union
{
CALINFO_ENUMPROCW
callback
;
/* user callback pointer */
CALINFO_ENUMPROCEXW
callbackex
;
...
...
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