summaryrefslogtreecommitdiff
path: root/cpio/test/test_option_t.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpio/test/test_option_t.c')
-rw-r--r--cpio/test/test_option_t.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/cpio/test/test_option_t.c b/cpio/test/test_option_t.c
index eaa73fa3..0f2dda27 100644
--- a/cpio/test/test_option_t.c
+++ b/cpio/test/test_option_t.c
@@ -36,6 +36,14 @@ DEFINE_TEST(test_option_t)
time_t mtime;
char date[32];
char date2[32];
+ struct tm *tmptr;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/* List reference archive, make sure the TOC is correct. */
extract_reference_file("test_option_t.cpio");
@@ -87,11 +95,23 @@ DEFINE_TEST(test_option_t)
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
+#if defined(HAVE_LOCALTIME_R)
+ tmptr = localtime_r(&mtime, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = mtime;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tmptr = NULL;
+ else
+ tmptr = &tmbuf;
+#else
+ tmptr = localtime(&mtime);
+#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
- strftime(date2, sizeof(date2)-1, "%b %d %Y", localtime(&mtime));
+ strftime(date2, sizeof(date2)-1, "%b %d %Y", tmptr);
_snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#else
- strftime(date2, sizeof(date2)-1, "%b %e %Y", localtime(&mtime));
+ strftime(date2, sizeof(date2)-1, "%b %e %Y", tmptr);
snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#endif
assertEqualMem(p + 42, date, strlen(date));