crt: Add emulation of _get_tzname() function for pre-msvcr80 import libs
Function _get_tzname() is available in msvcr80+ and UCRT.
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 23962a6..fa08d16 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -335,6 +335,7 @@
misc/_get_daylight.c \
misc/_get_dstbias.c \
misc/_get_timezone.c \
+ misc/_get_tzname.c \
misc/_recalloc.c \
misc/_set_purecall_handler.c \
misc/imaxdiv.c \
@@ -884,6 +885,7 @@
misc/_get_dstbias.c \
misc/_get_errno.c \
misc/_get_timezone.c \
+ misc/_get_tzname.c \
misc/_initterm_e.c \
misc/_recalloc.c \
misc/_set_errno.c \
diff --git a/mingw-w64-crt/misc/_get_tzname.c b/mingw-w64-crt/misc/_get_tzname.c
new file mode 100644
index 0000000..b5a9186
--- /dev/null
+++ b/mingw-w64-crt/misc/_get_tzname.c
@@ -0,0 +1,42 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+
+errno_t __cdecl _get_tzname(size_t *length, char *buffer, size_t size, int index)
+{
+ const char *tzname_ptr;
+
+ if ((!buffer && size != 0) || (buffer && size == 0))
+ {
+ errno = EINVAL;
+ return EINVAL;
+ }
+
+ if (buffer)
+ buffer[0] = '\0';
+
+ if (!length || (index != 0 && index != 1))
+ {
+ errno = EINVAL;
+ return EINVAL;
+ }
+
+ tzname_ptr = _tzname[index];
+
+ *length = strlen(tzname_ptr) + 1;
+
+ if (buffer)
+ {
+ if (*length > size)
+ return ERANGE;
+ memcpy(buffer, tzname_ptr, *length);
+ }
+
+ return 0;
+}
+errno_t (__cdecl *__MINGW_IMP_SYMBOL(_get_tzname))(size_t *, char *, size_t, int) = _get_tzname;