Skip to content
Permalink
Browse files
Merge pull request #2574 from rimrul/ucrt-strftime
mingw: use modern strftime implementation if possible
  • Loading branch information
dscho committed Apr 7, 2020
2 parents 9c98e1c + 6b80b39 commit 86440948da5f8e6aabccee6d67181c9097db751b
Showing 1 changed file with 9 additions and 1 deletion.
@@ -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);

0 comments on commit 8644094

Please sign in to comment.