Module: wine Branch: refs/heads/master Commit: 9a583763eefb7cec46e0b4b031cf71d6b5d2a5ae URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=9a583763eefb7cec46e0b4b0...
Author: Marcus Meissner marcus@jet.franken.de Date: Wed Dec 21 20:23:47 2005 +0100
msvcrt: Implemented wctime(), wasctime(). Free thread data in DLL_THREAD_DETACH.
---
dlls/msvcrt/main.c | 2 ++ dlls/msvcrt/msvcrt.h | 1 + dlls/msvcrt/msvcrt.spec | 4 ++-- dlls/msvcrt/time.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/main.c b/dlls/msvcrt/main.c index b8660bb..a79d12f 100644 --- a/dlls/msvcrt/main.c +++ b/dlls/msvcrt/main.c @@ -70,6 +70,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, case DLL_THREAD_DETACH: /* Free TLS */ tls = TlsGetValue(msvcrt_tls_index); + HeapFree(GetProcessHeap(),0,tls->efcvt_buffer); + HeapFree(GetProcessHeap(),0,tls->wasctime_buffer); HeapFree(GetProcessHeap(), 0, tls); TRACE("finished thread free\n"); break; diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index d46f738..b454579 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -83,6 +83,7 @@ struct __thread_data { unsigned long thread_doserrno; unsigned char *mbstok_next; /* next ptr for mbstok() */ char *efcvt_buffer; /* buffer for ecvt/fcvt */ + MSVCRT_wchar_t *wasctime_buffer; /* buffer for asctime */ int fpecode; MSVCRT_terminate_function terminate_handler; MSVCRT_unexpected_function unexpected_handler; diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index f964f29..a4d3ade 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -487,7 +487,7 @@ @ cdecl _vsnprintf(ptr long ptr ptr) MSVCRT_vsnprintf @ cdecl _vsnwprintf(ptr long wstr long) MSVCRT_vsnwprintf @ cdecl _waccess(wstr long) -@ stub _wasctime #(ptr) MSVCRT__wasctime +@ cdecl _wasctime(ptr) MSVCRT__wasctime @ cdecl _wchdir(wstr) @ cdecl _wchmod(wstr long) @ extern _wcmdln MSVCRT__wcmdln @@ -503,7 +503,7 @@ @ cdecl _wcsrev(wstr) @ cdecl _wcsset(wstr long) @ cdecl _wcsupr(wstr) ntdll._wcsupr -@ stub _wctime #(ptr) +@ cdecl _wctime(ptr) MSVCRT__wctime @ extern _wenviron @ stub _wexecl #(wstr wstr) varargs @ stub _wexecle #(wstr wstr) varargs diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index f7daab5..f462aa7 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -410,3 +410,35 @@ void MSVCRT__tzset(void) lstrcpynA(tzname_dst, tzname[1], sizeof(tzname_dst)); tzname_dst[sizeof(tzname_dst) - 1] = '\0'; } + +/********************************************************************* + * _wctime (MSVCRT.@) + */ +MSVCRT_wchar_t *MSVCRT__wasctime(const struct MSVCRT_tm *mstm) { + thread_data_t *data = msvcrt_get_thread_data(); + struct tm xtm; + + memset(&xtm,0,sizeof(xtm)); + xtm.tm_sec = mstm->tm_sec; + xtm.tm_min = mstm->tm_min; + xtm.tm_hour = mstm->tm_hour; + xtm.tm_mday = mstm->tm_mday; + xtm.tm_mon = mstm->tm_mon; + xtm.tm_year = mstm->tm_year; + xtm.tm_wday = mstm->tm_wday; + xtm.tm_yday = mstm->tm_yday; + xtm.tm_isdst = mstm->tm_isdst; + + if (!data->wasctime_buffer) + data->wasctime_buffer = MSVCRT_malloc( 30*sizeof(MSVCRT_wchar_t) ); /* ought to be enough */ + MultiByteToWideChar( CP_UNIXCP, 0, asctime(&xtm), -1, data->wasctime_buffer, 30 ); + return data->wasctime_buffer; +} + +/********************************************************************* + * _wctime (MSVCRT.@) + */ +MSVCRT_wchar_t *MSVCRT__wctime(MSVCRT_time_t *time) +{ + return MSVCRT__wasctime( MSVCRT_localtime(time) ); +}