msvcrt: Forward strftime() to wcsftime().

Dmitry Timoshkov dmitry at baikal.ru
Mon Jan 9 02:16:31 CST 2012


This patch should fix the problem reported in the bug 29038.
---
 dlls/msvcrt/time.c |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index f9de5c5..4c8db34 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,35 @@ 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(WCHAR) ))) return 0;
+
+    len = MultiByteToWideChar( CP_ACP, 0, format, -1, NULL, 0 );
+    if ((fmt = MSVCRT_malloc( len * sizeof(WCHAR) )))
+    {
+        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 );
+    }
+    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