Piotr Caban : msvcrt: Added _strdate_s and _wstrdate_s implementation.

Alexandre Julliard julliard at winehq.org
Fri Aug 27 11:11:18 CDT 2010


Module: wine
Branch: master
Commit: 471bad1ee805f2eb6c932ea0b1b57a3f78267061
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=471bad1ee805f2eb6c932ea0b1b57a3f78267061

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Aug 27 01:46:00 2010 +0200

msvcrt: Added _strdate_s and _wstrdate_s implementation.

---

 dlls/msvcr100/msvcr100.spec |    4 +-
 dlls/msvcr80/msvcr80.spec   |    4 +-
 dlls/msvcr90/msvcr90.spec   |    4 +-
 dlls/msvcrt/msvcrt.spec     |    4 +-
 dlls/msvcrt/tests/time.c    |   24 +++++++++++++++++++++++
 dlls/msvcrt/time.c          |   44 +++++++++++++++++++++++++++++++++++++++++++
 include/msvcrt/time.h       |    2 +
 include/msvcrt/wchar.h      |    1 +
 8 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index c9c248b..a6b8ec0 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -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
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index de58182..ae2a1f8 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -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
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index b3f3801..7000c2d 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -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
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 753ca7a..2ace243 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -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)
diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c
index 4dfeb64..78d8e09 100644
--- a/dlls/msvcrt/tests/time.c
+++ b/dlls/msvcrt/tests/time.c
@@ -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)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index b0ad20d..5044203 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -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.@)
  */
diff --git a/include/msvcrt/time.h b/include/msvcrt/time.h
index 2175526..ebbfbc2 100644
--- a/include/msvcrt/time.h
+++ b/include/msvcrt/time.h
@@ -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);
 
diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h
index c9b12fb..c5ab25f 100644
--- a/include/msvcrt/wchar.h
+++ b/include/msvcrt/wchar.h
@@ -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);
 




More information about the wine-cvs mailing list