Commit 471bad1e authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added _strdate_s and _wstrdate_s implementation.

parent 7d0c04d3
......@@ -1131,7 +1131,7 @@
@ stub _statusfp2
@ stub _strcoll_l
@ cdecl _strdate(ptr) msvcrt._strdate
@ stub _strdate_s
@ cdecl _strdate_s(ptr long) msvcrt._strdate_s
@ cdecl _strdup(str) msvcrt._strdup
@ cdecl _strerror(long) msvcrt._strerror
@ stub _strerror_s
......@@ -1398,7 +1398,7 @@
@ cdecl _wstat64(wstr ptr) msvcrt._wstat64
@ stub _wstat64i32
@ cdecl _wstrdate(ptr) msvcrt._wstrdate
@ stub _wstrdate_s
@ cdecl _wstrdate_s(ptr long) msvcrt._wstrdate_s
@ cdecl _wstrtime(ptr) msvcrt._wstrtime
@ cdecl _wstrtime_s(ptr long) msvcrt._wstrtime_s
@ cdecl _wsystem(wstr) msvcrt._wsystem
......
......@@ -985,7 +985,7 @@
@ stub _statusfp2
@ stub _strcoll_l
@ cdecl _strdate(ptr) msvcrt._strdate
@ stub _strdate_s
@ cdecl _strdate_s(ptr long) msvcrt._strdate_s
@ cdecl _strdup(str) msvcrt._strdup
@ cdecl _strerror(long) msvcrt._strerror
@ stub _strerror_s
......@@ -1254,7 +1254,7 @@
@ cdecl _wstat64(wstr ptr) msvcrt._wstat64
@ stub _wstat64i32
@ cdecl _wstrdate(ptr) msvcrt._wstrdate
@ stub _wstrdate_s
@ cdecl _wstrdate_s(ptr long) msvcrt._wstrdate_s
@ cdecl _wstrtime(ptr) msvcrt._wstrtime
@ cdecl _wstrtime_s(ptr long) msvcrt._wstrtime_s
@ cdecl _wsystem(wstr) msvcrt._wsystem
......
......@@ -971,7 +971,7 @@
@ stub _statusfp2
@ stub _strcoll_l
@ cdecl _strdate(ptr) msvcrt._strdate
@ stub _strdate_s
@ cdecl _strdate_s(ptr long) msvcrt._strdate_s
@ cdecl _strdup(str) msvcrt._strdup
@ cdecl _strerror(long) msvcrt._strerror
@ stub _strerror_s
......@@ -1238,7 +1238,7 @@
@ cdecl _wstat64(wstr ptr) msvcrt._wstat64
@ stub _wstat64i32
@ cdecl _wstrdate(ptr) msvcrt._wstrdate
@ stub _wstrdate_s
@ cdecl _wstrdate_s(ptr long) msvcrt._wstrdate_s
@ cdecl _wstrtime(ptr) msvcrt._wstrtime
@ cdecl _wstrtime_s(ptr long) msvcrt._wstrtime_s
@ cdecl _wsystem(wstr) msvcrt._wsystem
......
......@@ -906,7 +906,7 @@
@ cdecl _strcmpi(str str) ntdll._strcmpi
# stub _strcoll_l
@ cdecl _strdate(ptr)
# stub _strdate_s
@ cdecl _strdate_s(ptr long)
@ cdecl _strdup(str)
# stub _strdup_dbg
@ cdecl _strerror(long)
......@@ -1168,7 +1168,7 @@
@ cdecl _wstati64(wstr ptr) MSVCRT__wstati64
@ cdecl _wstat64(wstr ptr) MSVCRT__wstat64
@ cdecl _wstrdate(ptr)
# stub _wstrdate_s
@ cdecl _wstrdate_s(ptr long)
@ cdecl _wstrtime(ptr)
@ cdecl _wstrtime_s(ptr long)
@ cdecl _wsystem(wstr)
......
......@@ -36,6 +36,7 @@
static __time32_t (__cdecl *p_mkgmtime32)(struct tm*);
static struct tm* (__cdecl *p_gmtime32)(__time32_t*);
static errno_t (__cdecl *p_strtime_s)(char*,size_t);
static errno_t (__cdecl *p_strdate_s)(char*,size_t);
static void init(void)
{
......@@ -44,6 +45,7 @@ static void init(void)
p_gmtime32 = (void*)GetProcAddress(hmod, "_gmtime32");
p_mkgmtime32 = (void*)GetProcAddress(hmod, "_mkgmtime32");
p_strtime_s = (void*)GetProcAddress(hmod, "_strtime_s");
p_strdate_s = (void*)GetProcAddress(hmod, "_strdate_s");
}
static int get_test_year(time_t *start)
......@@ -295,6 +297,7 @@ static void test_strdate(void)
{
char date[16], * result;
int month, day, year, count, len;
errno_t err;
result = _strdate(date);
ok(result == date, "Wrong return value\n");
......@@ -302,6 +305,27 @@ static void test_strdate(void)
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
count = sscanf(date, "%02d/%02d/%02d", &month, &day, &year);
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
if(!p_strdate_s) {
win_skip("Skipping _strdate_s tests\n");
return;
}
errno = 0;
err = p_strdate_s(NULL, 1);
ok(err == EINVAL, "err = %d\n", err);
ok(errno == EINVAL, "errno = %d\n", errno);
date[0] = 'x';
date[1] = 'x';
err = p_strdate_s(date, 8);
ok(err == ERANGE, "err = %d\n", err);
ok(errno == ERANGE, "errno = %d\n", errno);
ok(date[0] == '\0', "date[0] != '\\0'\n");
ok(date[1] == 'x', "date[1] != 'x'\n");
err = p_strdate_s(date, 9);
ok(err == 0, "err = %x\n", err);
}
static void test_strtime(void)
......
......@@ -302,6 +302,28 @@ char* CDECL _strdate(char* date)
}
/**********************************************************************
* _strdate_s (MSVCRT.@)
*/
int CDECL _strdate_s(char* date, MSVCRT_size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
}
if(size < 9) {
*MSVCRT__errno() = MSVCRT_ERANGE;
return MSVCRT_ERANGE;
}
_strdate(date);
return 0;
}
/**********************************************************************
* _wstrdate (MSVCRT.@)
*/
MSVCRT_wchar_t* CDECL _wstrdate(MSVCRT_wchar_t* date)
......@@ -313,6 +335,28 @@ MSVCRT_wchar_t* CDECL _wstrdate(MSVCRT_wchar_t* date)
return date;
}
/**********************************************************************
* _wstrdate_s (MSVCRT.@)
*/
int CDECL _wstrdate_s(MSVCRT_wchar_t* date, MSVCRT_size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
}
if(size < 9) {
*MSVCRT__errno() = MSVCRT_ERANGE;
return MSVCRT_ERANGE;
}
_wstrdate(date);
return 0;
}
/*********************************************************************
* _strtime (MSVCRT.@)
*/
......
......@@ -89,6 +89,7 @@ extern char *_tzname;
unsigned __cdecl _getsystime(struct tm*);
unsigned __cdecl _setsystime(struct tm*,unsigned);
char* __cdecl _strdate(char*);
errno_t __cdecl _strdate_s(char*,size_t);
char* __cdecl _strtime(char*);
errno_t __cdecl _strtime_s(char*,size_t);
void __cdecl _tzset(void);
......@@ -130,6 +131,7 @@ size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*);
wchar_t* __cdecl _wctime32(const __time32_t*);
wchar_t* __cdecl _wctime64(const __time64_t*);
wchar_t* __cdecl _wstrdate(wchar_t*);
errno_t __cdecl _wstrdate_s(wchar_t*,size_t);
wchar_t* __cdecl _wstrtime(wchar_t*);
errno_t __cdecl _wstrtime_s(wchar_t*,size_t);
......
......@@ -396,6 +396,7 @@ size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*);
wchar_t* __cdecl _wctime32(const __time32_t*);
wchar_t* __cdecl _wctime64(const __time64_t*);
wchar_t* __cdecl _wstrdate(wchar_t*);
errno_t __cdecl _wstrdate_s(wchar_t*,size_t);
wchar_t* __cdecl _wstrtime(wchar_t*);
errno_t __cdecl _wstrtime_s(wchar_t*,size_t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment