diff options
author | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
commit | e109f99dcb6c95c84bbec22229de29a25491f7c2 (patch) | |
tree | d142d742b698973a366ae768a3f4033924e314c8 /contrib/file/src/print.c | |
parent | 238df27d058d0d8912acf0a186d3f43289a0a2b6 (diff) | |
parent | cb167b45a82327b0d6d88e85e3d6e2e326291ee4 (diff) | |
download | FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.zip FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.tar.gz |
Merge ^/head r284188 through r284643.
Diffstat (limited to 'contrib/file/src/print.c')
-rw-r--r-- | contrib/file/src/print.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/contrib/file/src/print.c b/contrib/file/src/print.c index fa81798..07ae8f6 100644 --- a/contrib/file/src/print.c +++ b/contrib/file/src/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.76 2013/02/26 18:25:00 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.79 2015/01/09 19:28:32 christos Exp $") #endif /* lint */ #include <string.h> @@ -164,6 +164,7 @@ file_mdump(struct magic *m) case FILE_MELDATE: (void)fprintf(stderr, "%s,", file_fmttime(m->value.l, 0, tbuf)); + break; case FILE_QDATE: case FILE_LEQDATE: case FILE_BEQDATE: @@ -231,40 +232,27 @@ protected const char * file_fmttime(uint64_t v, int flags, char *buf) { char *pp; - time_t t = (time_t)v; - struct tm *tm; + time_t t; + struct tm *tm, tmz; if (flags & FILE_T_WINDOWS) { struct timespec ts; - cdf_timestamp_to_timespec(&ts, t); + cdf_timestamp_to_timespec(&ts, v); t = ts.tv_sec; + } else { + // XXX: perhaps detect and print something if overflow + // on 32 bit time_t? + t = (time_t)v; } if (flags & FILE_T_LOCAL) { - pp = ctime_r(&t, buf); + tm = localtime_r(&t, &tmz); } else { -#ifndef HAVE_DAYLIGHT - private int daylight = 0; -#ifdef HAVE_TM_ISDST - private time_t now = (time_t)0; - - if (now == (time_t)0) { - struct tm *tm1; - (void)time(&now); - tm1 = localtime(&now); - if (tm1 == NULL) - goto out; - daylight = tm1->tm_isdst; - } -#endif /* HAVE_TM_ISDST */ -#endif /* HAVE_DAYLIGHT */ - if (daylight) - t += 3600; - tm = gmtime(&t); - if (tm == NULL) - goto out; - pp = asctime_r(tm, buf); + tm = gmtime_r(&t, &tmz); } + if (tm == NULL) + goto out; + pp = asctime_r(tm, buf); if (pp == NULL) goto out; |