Skip to content

Commit

Permalink
Merge pull request #2574 from rimrul/ucrt-strftime
Browse files Browse the repository at this point in the history
mingw: use modern strftime implementation if possible
  • Loading branch information
dscho authored Apr 7, 2020
2 parents 9c98e1c + 6b80b39 commit 8644094
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,15 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
size_t mingw_strftime(char *s, size_t max,
const char *format, const struct tm *tm)
{
size_t ret = strftime(s, max, format, tm);
/* a pointer to the original strftime in case we can't find the UCRT version */
static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
size_t ret;
DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t,
const char *, const struct tm *);
if (INIT_PROC_ADDR(strftime))
ret = strftime(s, max, format, tm);
else
ret = fallback(s, max, format, tm);

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

0 comments on commit 8644094

Please sign in to comment.