diff options
author | Bernd Ahlers <bernd@ba-net.org> | 2009-04-06 19:26:37 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-05 22:19:14 -0700 |
commit | f697b33b015fcb0c90210840eb4ef8e6a18d4bdf (patch) | |
tree | dee9b73dc1431f423d1246cd7bc7ad6a68f1aab8 /date.c | |
parent | 7713e053fd13a09b548cb65d99dfca986064955e (diff) | |
download | git-f697b33b015fcb0c90210840eb4ef8e6a18d4bdf.tar.gz |
Work around BSD whose typeof(tv.tv_sec) != time_t
According to POSIX, tv_sec is supposed to be a time_t, but OpenBSD
(and FreeBSD, too) defines it to be a long, which triggers a type
mismatch when a pointer to it is given to localtime_r().
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'date.c')
-rw-r--r-- | date.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date) int number = 0; struct tm tm, now; struct timeval tv; + time_t time_sec; char buffer[50]; if (parse_date(date, buffer, sizeof(buffer)) > 0) return strtoul(buffer, NULL, 10); gettimeofday(&tv, NULL); - localtime_r(&tv.tv_sec, &tm); + time_sec = tv.tv_sec; + localtime_r(&time_sec, &tm); now = tm; for (;;) { unsigned char c = *date; |