Skip to content

Commit 36f1f1f

Browse files
committed
Merge pull request #2574 from rimrul/ucrt-strftime
mingw: use modern strftime implementation if possible
2 parents dc3c4cf + 013be0b commit 36f1f1f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compat/mingw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,15 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
975975
size_t mingw_strftime(char *s, size_t max,
976976
const char *format, const struct tm *tm)
977977
{
978-
size_t ret = strftime(s, max, format, tm);
978+
/* a pointer to the original strftime in case we can't find the UCRT version */
979+
static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
980+
size_t ret;
981+
DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t,
982+
const char *, const struct tm *);
983+
if (INIT_PROC_ADDR(strftime))
984+
ret = strftime(s, max, format, tm);
985+
else
986+
ret = fallback(s, max, format, tm);
979987

980988
if (!ret && errno == EINVAL)
981989
die("invalid strftime format: '%s'", format);

0 commit comments

Comments
 (0)