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
6f6d58b8
Commit
6f6d58b8
authored
Jul 28, 2005
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 28, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Reimplement EnumTimeFormats, make it work for all available
locales. - Add a test for EnumTimeFormats
parent
83f8704b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
93 deletions
+79
-93
lcformat.c
dlls/kernel/lcformat.c
+42
-63
locale.c
dlls/kernel/tests/locale.c
+37
-30
No files found.
dlls/kernel/lcformat.c
View file @
6f6d58b8
...
...
@@ -1685,82 +1685,61 @@ BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
/**************************************************************************
* EnumTimeFormatsA (KERNEL32.@)
*
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
* LOCALE_NOUSEROVERRIDE here as well?
*/
BOOL
WINAPI
EnumTimeFormatsA
(
TIMEFMT_ENUMPROCA
lpTimeFmtEnumProc
,
LCID
Locale
,
DWORD
dwFlags
)
BOOL
WINAPI
EnumTimeFormatsA
(
TIMEFMT_ENUMPROCA
proc
,
LCID
lcid
,
DWORD
flags
)
{
LCID
Loc
=
GetUserDefaultLCID
();
if
(
!
lpTimeFmtEnumProc
)
char
buf
[
256
];
if
(
!
proc
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
dwFlags
)
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
{
FIXME
(
"Unknown time format (%ld)
\n
"
,
dwFlags
);
}
case
0
:
if
(
GetLocaleInfoA
(
lcid
,
LOCALE_STIMEFORMAT
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
switch
(
Loc
)
{
case
0x00000407
:
/* (Loc,"de_DE") */
{
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH.mm"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H.mm"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H.mm'Uhr'"
))
return
TRUE
;
return
TRUE
;
}
case
0x0000040c
:
/* (Loc,"fr_FR") */
case
0x00000c0c
:
/* (Loc,"fr_CA") */
{
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H:mm"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH.mm"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH'h'mm"
))
return
TRUE
;
return
TRUE
;
}
case
0x00000809
:
/* (Loc,"en_UK") */
case
0x00000c09
:
/* (Loc,"en_AU") */
case
0x00001409
:
/* (Loc,"en_NZ") */
case
0x00001809
:
/* (Loc,"en_IE") */
{
if
(
!
(
*
lpTimeFmtEnumProc
)(
"h:mm:ss tt"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H:mm:ss"
))
return
TRUE
;
return
TRUE
;
}
case
0x00001c09
:
/* (Loc,"en_ZA") */
case
0x00002809
:
/* (Loc,"en_BZ") */
case
0x00002c09
:
/* (Loc,"en_TT") */
{
if
(
!
(
*
lpTimeFmtEnumProc
)(
"h:mm:ss tt"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"hh:mm:ss tt"
))
return
TRUE
;
return
TRUE
;
}
default:
/* default to US style "en_US" */
{
if
(
!
(
*
lpTimeFmtEnumProc
)(
"h:mm:ss tt"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"hh:mm:ss tt"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"H:mm:ss"
))
return
TRUE
;
if
(
!
(
*
lpTimeFmtEnumProc
)(
"HH:mm:ss"
))
return
TRUE
;
default:
FIXME
(
"Unknown time format (%ld)
\n
"
,
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
}
}
}
/**************************************************************************
* EnumTimeFormatsW (KERNEL32.@)
*/
BOOL
WINAPI
EnumTimeFormatsW
(
TIMEFMT_ENUMPROCW
lpTimeFmtEnumProc
,
LCID
Locale
,
DWORD
dwFlags
)
BOOL
WINAPI
EnumTimeFormatsW
(
TIMEFMT_ENUMPROCW
proc
,
LCID
lcid
,
DWORD
flags
)
{
FIXME
(
"(%p,%ld,%ld): stub
\n
"
,
lpTimeFmtEnumProc
,
Locale
,
dwFlags
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
FALSE
;
WCHAR
buf
[
256
];
if
(
!
proc
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
switch
(
flags
&
~
LOCALE_USE_CP_ACP
)
{
case
0
:
if
(
GetLocaleInfoW
(
lcid
,
LOCALE_STIMEFORMAT
|
(
flags
&
LOCALE_USE_CP_ACP
),
buf
,
256
))
proc
(
buf
);
break
;
default:
FIXME
(
"Unknown time format (%ld)
\n
"
,
flags
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
TRUE
;
}
/******************************************************************************
...
...
dlls/kernel/tests/locale.c
View file @
6f6d58b8
...
...
@@ -51,7 +51,7 @@ static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n )
static
inline
WCHAR
*
strchrW
(
const
WCHAR
*
str
,
WCHAR
ch
)
{
for
(
;
*
str
;
str
++
)
if
(
*
str
==
ch
)
return
(
WCHAR
*
)
str
;
do
{
if
(
*
str
==
ch
)
return
(
WCHAR
*
)
str
;
}
while
(
*
str
++
)
;
return
NULL
;
}
...
...
@@ -104,7 +104,6 @@ static void InitFunctionPointers(void)
(label), (received), (expected))
#define BUFFER_SIZE 128
static
char
GlobalBuffer
[
BUFFER_SIZE
];
/* Buffer used by callback function */
#define COUNTOF(x) (sizeof(x)/sizeof(x)[0])
#define EXPECT_LEN(len) ok(ret == (len), "Expected Len %d, got %d\n", (len), ret)
...
...
@@ -748,27 +747,6 @@ static void test_GetNumberFormatA(void)
}
/* Callback function used by TestEnumTimeFormats */
static
BOOL
CALLBACK
EnumTimeFormatsProc
(
char
*
lpTimeFormatString
)
{
trace
(
"%s
\n
"
,
lpTimeFormatString
);
strcpy
(
GlobalBuffer
,
lpTimeFormatString
);
#if 0
return TRUE;
#endif
return
FALSE
;
}
static
void
test_EnumTimeFormats
(
void
)
{
int
ret
;
LCID
lcid
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
GlobalBuffer
[
0
]
=
'\0'
;
ret
=
EnumTimeFormatsA
(
EnumTimeFormatsProc
,
lcid
,
0
);
ok
(
ret
==
1
&&
!
strcmp
(
GlobalBuffer
,
"h:mm:ss tt"
),
"Expected %d '%s'
\n
"
,
ret
,
GlobalBuffer
);
}
static
void
test_CompareStringA
(
void
)
{
int
ret
;
...
...
@@ -2096,7 +2074,7 @@ static void test_EnumUILanguageA(void)
static
char
date_fmt_buf
[
1024
];
static
BOOL
CALLBACK
enum_date
fmt
_procA
(
LPSTR
fmt
)
static
BOOL
CALLBACK
enum_date
time
_procA
(
LPSTR
fmt
)
{
lstrcatA
(
date_fmt_buf
,
fmt
);
lstrcatA
(
date_fmt_buf
,
"
\n
"
);
...
...
@@ -2111,7 +2089,7 @@ static void test_EnumDateFormatsA(void)
trace
(
"EnumDateFormatsA 0
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumDateFormatsA
(
enum_date
fmt
_procA
,
lcid
,
0
);
ret
=
EnumDateFormatsA
(
enum_date
time
_procA
,
lcid
,
0
);
ok
(
ret
,
"EnumDateFormatsA(0) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
...
...
@@ -2122,7 +2100,7 @@ static void test_EnumDateFormatsA(void)
trace
(
"EnumDateFormatsA LOCALE_USE_CP_ACP
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumDateFormatsA
(
enum_date
fmt
_procA
,
lcid
,
LOCALE_USE_CP_ACP
);
ret
=
EnumDateFormatsA
(
enum_date
time
_procA
,
lcid
,
LOCALE_USE_CP_ACP
);
ok
(
ret
,
"EnumDateFormatsA(LOCALE_USE_CP_ACP) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
...
...
@@ -2133,7 +2111,7 @@ static void test_EnumDateFormatsA(void)
trace
(
"EnumDateFormatsA DATE_SHORTDATE
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumDateFormatsA
(
enum_date
fmt
_procA
,
lcid
,
DATE_SHORTDATE
);
ret
=
EnumDateFormatsA
(
enum_date
time
_procA
,
lcid
,
DATE_SHORTDATE
);
ok
(
ret
,
"EnumDateFormatsA(DATE_SHORTDATE) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
...
...
@@ -2144,7 +2122,7 @@ static void test_EnumDateFormatsA(void)
trace
(
"EnumDateFormatsA DATE_LONGDATE
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumDateFormatsA
(
enum_date
fmt
_procA
,
lcid
,
DATE_LONGDATE
);
ret
=
EnumDateFormatsA
(
enum_date
time
_procA
,
lcid
,
DATE_LONGDATE
);
ok
(
ret
,
"EnumDateFormatsA(DATE_LONGDATE) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
...
...
@@ -2155,7 +2133,7 @@ static void test_EnumDateFormatsA(void)
trace
(
"EnumDateFormatsA DATE_YEARMONTH
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumDateFormatsA
(
enum_date
fmt
_procA
,
lcid
,
DATE_YEARMONTH
);
ret
=
EnumDateFormatsA
(
enum_date
time
_procA
,
lcid
,
DATE_YEARMONTH
);
ok
(
ret
,
"EnumDateFormatsA(DATE_YEARMONTH) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
...
...
@@ -2165,11 +2143,40 @@ static void test_EnumDateFormatsA(void)
ok
(
!
lstrcmpA
(
date_fmt_buf
,
buf
),
"expected
\"
%s
\"
got
\"
%s
\"\n
"
,
date_fmt_buf
,
buf
);
}
static
void
test_EnumTimeFormatsA
(
void
)
{
char
*
p
,
buf
[
256
];
BOOL
ret
;
LCID
lcid
=
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
);
trace
(
"EnumTimeFormatsA 0
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumTimeFormatsA
(
enum_datetime_procA
,
lcid
,
0
);
ok
(
ret
,
"EnumTimeFormatsA(0) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
if
((
p
=
strchr
(
date_fmt_buf
,
'\n'
)))
*
p
=
0
;
ret
=
GetLocaleInfoA
(
lcid
,
LOCALE_STIMEFORMAT
,
buf
,
sizeof
(
buf
));
ok
(
ret
,
"GetLocaleInfoA(LOCALE_STIMEFORMAT) error %ld
\n
"
,
GetLastError
());
ok
(
!
lstrcmpA
(
date_fmt_buf
,
buf
),
"expected
\"
%s
\"
got
\"
%s
\"\n
"
,
date_fmt_buf
,
buf
);
trace
(
"EnumTimeFormatsA LOCALE_USE_CP_ACP
\n
"
);
date_fmt_buf
[
0
]
=
0
;
ret
=
EnumTimeFormatsA
(
enum_datetime_procA
,
lcid
,
LOCALE_USE_CP_ACP
);
ok
(
ret
,
"EnumTimeFormatsA(LOCALE_USE_CP_ACP) error %ld
\n
"
,
GetLastError
());
trace
(
"%s
\n
"
,
date_fmt_buf
);
/* test the 1st enumerated format */
if
((
p
=
strchr
(
date_fmt_buf
,
'\n'
)))
*
p
=
0
;
ret
=
GetLocaleInfoA
(
lcid
,
LOCALE_STIMEFORMAT
,
buf
,
sizeof
(
buf
));
ok
(
ret
,
"GetLocaleInfoA(LOCALE_STIMEFORMAT) error %ld
\n
"
,
GetLastError
());
ok
(
!
lstrcmpA
(
date_fmt_buf
,
buf
),
"expected
\"
%s
\"
got
\"
%s
\"\n
"
,
date_fmt_buf
,
buf
);
}
START_TEST
(
locale
)
{
InitFunctionPointers
();
if
(
0
)
test_EnumTimeFormats
();
test_EnumTimeFormatsA
();
test_EnumDateFormatsA
();
test_GetLocaleInfoA
();
...
...
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