msvcrt: Add _strftime_l.

Based on Daniel Lehman's patch.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-08-10 17:18:09 +02:00 committed by Alexandre Julliard
parent d6948bf356
commit 1505684a85
9 changed files with 31 additions and 16 deletions

View File

@ -42,7 +42,7 @@
@ cdecl _setsystime(ptr long) ucrtbase._setsystime
@ cdecl _strdate(ptr) ucrtbase._strdate
@ cdecl _strdate_s(ptr long) ucrtbase._strdate_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) ucrtbase._strftime_l
@ cdecl _strtime(ptr) ucrtbase._strtime
@ cdecl _strtime_s(ptr long) ucrtbase._strtime_s
@ cdecl _time32(ptr) ucrtbase._time32

View File

@ -1340,7 +1340,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll

View File

@ -1697,7 +1697,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll

View File

@ -1708,7 +1708,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll

View File

@ -1419,7 +1419,7 @@
@ cdecl _strdup(str) msvcr120._strdup
@ cdecl _strerror(long) msvcr120._strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) msvcr120._strftime_l
@ cdecl _stricmp(str str) msvcr120._stricmp
@ cdecl _stricmp_l(str str ptr) msvcr120._stricmp_l
@ cdecl _stricoll(str str) msvcr120._stricoll

View File

@ -1020,7 +1020,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll

View File

@ -995,7 +995,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll

View File

@ -1055,11 +1055,8 @@ static inline BOOL strftime_int(char *str, MSVCRT_size_t *pos, MSVCRT_size_t max
return TRUE;
}
/*********************************************************************
* _Strftime (MSVCRT.@)
*/
MSVCRT_size_t CDECL _Strftime(char *str, MSVCRT_size_t max, const char *format,
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data)
static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *format,
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data, MSVCRT__locale_t loc)
{
MSVCRT_size_t ret, tmp;
BOOL alternate;
@ -1074,11 +1071,11 @@ MSVCRT_size_t CDECL _Strftime(char *str, MSVCRT_size_t max, const char *format,
}
if(!time_data)
time_data = get_locinfo()->lc_time_curr;
time_data = loc ? loc->locinfo->lc_time_curr : get_locinfo()->lc_time_curr;
for(ret=0; *format && ret<max; format++) {
if(*format != '%') {
if(MSVCRT_isleadbyte((unsigned char)*format)) {
if(MSVCRT__isleadbyte_l((unsigned char)*format, loc)) {
str[ret++] = *(format++);
if(ret == max) continue;
if(!str[ret]) goto einval_error;
@ -1239,13 +1236,31 @@ einval_error:
return 0;
}
/********************************************************************
* _strftime_l (MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT__strftime_l( char *str, MSVCRT_size_t max, const char *format,
const struct MSVCRT_tm *mstm, MSVCRT__locale_t loc )
{
return strftime_helper(str, max, format, mstm, NULL, loc);
}
/*********************************************************************
* _Strftime (MSVCRT.@)
*/
MSVCRT_size_t CDECL _Strftime(char *str, MSVCRT_size_t max, const char *format,
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data)
{
return strftime_helper(str, max, format, mstm, time_data, NULL);
}
/*********************************************************************
* strftime (MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT_strftime( char *str, MSVCRT_size_t max, const char *format,
const struct MSVCRT_tm *mstm )
{
return _Strftime(str, max, format, mstm, NULL);
return strftime_helper(str, max, format, mstm, NULL, NULL);
}
/*********************************************************************

View File

@ -1926,7 +1926,7 @@
@ cdecl _strdup(str) MSVCRT__strdup
@ cdecl _strerror(long) MSVCRT__strerror
@ stub _strerror_s
@ stub _strftime_l
@ cdecl _strftime_l(str long str ptr ptr) MSVCRT__strftime_l
@ cdecl _stricmp(str str) MSVCRT__stricmp
@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l
@ cdecl _stricoll(str str) MSVCRT__stricoll