summaryrefslogtreecommitdiff
path: root/cpio/cpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpio/cpio.c')
-rw-r--r--cpio/cpio.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c
index 4fd394de..f8dd62c5 100644
--- a/cpio/cpio.c
+++ b/cpio/cpio.c
@@ -1139,6 +1139,10 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
const char *fmt;
time_t mtime;
static time_t now;
+ struct tm *ltime;
+#ifdef HAVE_LOCALTIME_R
+ struct tm tmbuf;
+#endif
if (!now)
time(&now);
@@ -1186,7 +1190,12 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
else
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
#endif
- strftime(date, sizeof(date), fmt, localtime(&mtime));
+#ifdef HAVE_LOCALTIME_R
+ ltime = localtime_r(&mtime, &tmbuf);
+#else
+ ltime = localtime(&mtime)
+#endif
+ strftime(date, sizeof(date), fmt, ltime);
fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
archive_entry_strmode(entry),