Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
81183c1e
Commit
81183c1e
authored
Jun 08, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix the handling of CAL_ITWODIGITYEARMAX in GetCalendarInfo.
parent
53218eb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
1 deletion
+87
-1
time.c
dlls/kernel32/tests/time.c
+61
-0
time.c
dlls/kernel32/time.c
+26
-1
No files found.
dlls/kernel32/tests/time.c
View file @
81183c1e
...
...
@@ -25,6 +25,8 @@
static
BOOL
(
WINAPI
*
pTzSpecificLocalTimeToSystemTime
)(
LPTIME_ZONE_INFORMATION
,
LPSYSTEMTIME
,
LPSYSTEMTIME
);
static
BOOL
(
WINAPI
*
pSystemTimeToTzSpecificLocalTime
)(
LPTIME_ZONE_INFORMATION
,
LPSYSTEMTIME
,
LPSYSTEMTIME
);
static
int
(
WINAPI
*
pGetCalendarInfoA
)(
LCID
,
CALID
,
CALTYPE
,
LPSTR
,
int
,
LPDWORD
);
static
int
(
WINAPI
*
pGetCalendarInfoW
)(
LCID
,
CALID
,
CALTYPE
,
LPWSTR
,
int
,
LPDWORD
);
#define SECSPERMIN 60
#define SECSPERDAY 86400
...
...
@@ -637,11 +639,69 @@ static void test_FileTimeToDosDateTime(void)
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
static
void
test_GetCalendarInfo
(
void
)
{
char
bufferA
[
20
];
WCHAR
bufferW
[
20
];
DWORD
val1
,
val2
;
int
ret
;
if
(
!
pGetCalendarInfoA
||
!
pGetCalendarInfoW
)
{
trace
(
"GetCalendarInfo missing
\n
"
);
return
;
}
ret
=
pGetCalendarInfoA
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
|
CAL_RETURN_NUMBER
,
NULL
,
0
,
&
val1
);
ok
(
ret
,
"GetCalendarInfoA failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
sizeof
(
val1
),
"wrong size %u
\n
"
,
ret
);
ok
(
val1
>=
2000
&&
val1
<
2100
,
"wrong value %u
\n
"
,
val1
);
ret
=
pGetCalendarInfoW
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
|
CAL_RETURN_NUMBER
,
NULL
,
0
,
&
val2
);
ok
(
ret
,
"GetCalendarInfoW failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
sizeof
(
val2
)
/
sizeof
(
WCHAR
),
"wrong size %u
\n
"
,
ret
);
ok
(
val1
==
val2
,
"A/W mismatch %u/%u
\n
"
,
val1
,
val2
);
ret
=
pGetCalendarInfoA
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
,
bufferA
,
sizeof
(
bufferA
),
NULL
);
ok
(
ret
,
"GetCalendarInfoA failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
5
,
"wrong size %u
\n
"
,
ret
);
ok
(
atoi
(
bufferA
)
==
val1
,
"wrong value %s/%u
\n
"
,
bufferA
,
val1
);
ret
=
pGetCalendarInfoW
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
,
bufferW
,
sizeof
(
bufferW
),
NULL
);
ok
(
ret
,
"GetCalendarInfoW failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
5
,
"wrong size %u
\n
"
,
ret
);
memset
(
bufferA
,
0x55
,
sizeof
(
bufferA
)
);
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
-
1
,
bufferA
,
sizeof
(
bufferA
),
NULL
,
NULL
);
ok
(
atoi
(
bufferA
)
==
val1
,
"wrong value %s/%u
\n
"
,
bufferA
,
val1
);
ret
=
pGetCalendarInfoA
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
|
CAL_RETURN_NUMBER
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"GetCalendarInfoA succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
pGetCalendarInfoA
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
,
NULL
,
0
,
NULL
);
ok
(
ret
,
"GetCalendarInfoA failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
5
,
"wrong size %u
\n
"
,
ret
);
ret
=
pGetCalendarInfoW
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
|
CAL_RETURN_NUMBER
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"GetCalendarInfoW succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
pGetCalendarInfoW
(
0x0409
,
CAL_GREGORIAN
,
CAL_ITWODIGITYEARMAX
,
NULL
,
0
,
NULL
);
ok
(
ret
,
"GetCalendarInfoW failed err %u
\n
"
,
GetLastError
()
);
ok
(
ret
==
5
,
"wrong size %u
\n
"
,
ret
);
}
START_TEST
(
time
)
{
HMODULE
hKernel
=
GetModuleHandle
(
"kernel32"
);
pTzSpecificLocalTimeToSystemTime
=
(
void
*
)
GetProcAddress
(
hKernel
,
"TzSpecificLocalTimeToSystemTime"
);
pSystemTimeToTzSpecificLocalTime
=
(
void
*
)
GetProcAddress
(
hKernel
,
"SystemTimeToTzSpecificLocalTime"
);
pGetCalendarInfoA
=
(
void
*
)
GetProcAddress
(
hKernel
,
"GetCalendarInfoA"
);
pGetCalendarInfoW
=
(
void
*
)
GetProcAddress
(
hKernel
,
"GetCalendarInfoW"
);
test_conversions
();
test_invalid_arg
();
...
...
@@ -650,4 +710,5 @@ START_TEST(time)
test_FileTimeToLocalFileTime
();
test_TzSpecificLocalTimeToSystemTime
();
test_FileTimeToDosDateTime
();
test_GetCalendarInfo
();
}
dlls/kernel32/time.c
View file @
81183c1e
...
...
@@ -618,6 +618,8 @@ int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
ret
=
GetCalendarInfoW
(
lcid
,
Calendar
,
CalType
,
lpCalDataW
,
cchData
,
lpValue
);
if
(
ret
&&
lpCalDataW
&&
lpCalData
)
WideCharToMultiByte
(
CP_ACP
,
0
,
lpCalDataW
,
cchData
,
lpCalData
,
cchData
,
NULL
,
NULL
);
else
if
(
CalType
&
CAL_RETURN_NUMBER
)
ret
*=
sizeof
(
WCHAR
);
HeapFree
(
GetProcessHeap
(),
0
,
lpCalDataW
);
return
ret
;
...
...
@@ -636,6 +638,11 @@ int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType,
FIXME
(
"flag CAL_USE_CP_ACP used, not fully implemented
\n
"
);
if
(
CalType
&
CAL_RETURN_NUMBER
)
{
if
(
!
lpValue
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
lpCalData
!=
NULL
)
WARN
(
"lpCalData not NULL (%p) when it should!
\n
"
,
lpCalData
);
if
(
cchData
!=
0
)
...
...
@@ -747,7 +754,25 @@ int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType,
case
CAL_SYEARMONTH
:
return
GetLocaleInfoW
(
Locale
,
LOCALE_SYEARMONTH
,
lpCalData
,
cchData
);
case
CAL_ITWODIGITYEARMAX
:
if
(
lpValue
)
*
lpValue
=
CALINFO_MAX_YEAR
;
if
(
CalType
&
CAL_RETURN_NUMBER
)
{
*
lpValue
=
CALINFO_MAX_YEAR
;
return
sizeof
(
DWORD
)
/
sizeof
(
WCHAR
);
}
else
{
static
const
WCHAR
fmtW
[]
=
{
'%'
,
'u'
,
0
};
WCHAR
buffer
[
10
];
int
ret
=
snprintfW
(
buffer
,
10
,
fmtW
,
CALINFO_MAX_YEAR
)
+
1
;
if
(
!
lpCalData
)
return
ret
;
if
(
ret
<=
cchData
)
{
strcpyW
(
lpCalData
,
buffer
);
return
ret
;
}
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
break
;
default:
FIXME
(
"Unknown caltype %d
\n
"
,
CalType
&
0xffff
);
...
...
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