[2/2] msvcrt: Forward strftime() to wcsftime(). Take 2.

Dmitry Timoshkov dmitry at baikal.ru
Tue Jan 10 02:02:14 CST 2012


---
 dlls/msvcrt/time.c |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index f9de5c5..855a49a 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -836,18 +836,6 @@ void CDECL MSVCRT__tzset(void)
 }
 
 /*********************************************************************
- *		strftime (MSVCRT.@)
- */
-MSVCRT_size_t CDECL MSVCRT_strftime( char *str, MSVCRT_size_t max, const char *format,
-                                     const struct MSVCRT_tm *mstm )
-{
-    struct tm tm;
-
-    msvcrt_tm_to_unix( &tm, mstm );
-    return strftime( str, max, format, &tm );
-}
-
-/*********************************************************************
  *		wcsftime (MSVCRT.@)
  */
 MSVCRT_size_t CDECL MSVCRT_wcsftime( MSVCRT_wchar_t *str, MSVCRT_size_t max,
@@ -878,6 +866,38 @@ MSVCRT_size_t CDECL MSVCRT_wcsftime( MSVCRT_wchar_t *str, MSVCRT_size_t max,
 }
 
 /*********************************************************************
+ *		strftime (MSVCRT.@)
+ */
+MSVCRT_size_t CDECL MSVCRT_strftime( char *str, MSVCRT_size_t max, const char *format,
+                                     const struct MSVCRT_tm *mstm )
+{
+    MSVCRT_wchar_t *s, *fmt;
+    MSVCRT_size_t len;
+
+    TRACE("%p %ld %s %p\n", str, max, debugstr_a(format), mstm );
+
+    if (!(s = MSVCRT_malloc( max * sizeof(MSVCRT_wchar_t) ))) return 0;
+
+    len = MultiByteToWideChar( CP_ACP, 0, format, -1, NULL, 0 );
+    if ((fmt = MSVCRT_malloc( len * sizeof(MSVCRT_wchar_t) )))
+    {
+        MultiByteToWideChar( CP_ACP, 0, format, -1, fmt, len );
+
+        if ((len = MSVCRT_wcsftime( s, max, fmt, mstm )))
+        {
+            len = WideCharToMultiByte( CP_ACP, 0, s, len, str, max, NULL, NULL );
+            if (len < max) str[len] = 0;
+        }
+    }
+    else
+        len = 0;
+
+    MSVCRT_free( fmt );
+    MSVCRT_free( s );
+    return len;
+}
+
+/*********************************************************************
  *		asctime (MSVCRT.@)
  */
 char * CDECL MSVCRT_asctime(const struct MSVCRT_tm *mstm)
-- 
1.7.7.4




More information about the wine-patches mailing list