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>
This commit is contained in:
parent
7713e053fd
commit
f697b33b01
4
date.c
4
date.c
@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
|
|||||||
int number = 0;
|
int number = 0;
|
||||||
struct tm tm, now;
|
struct tm tm, now;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
time_t time_sec;
|
||||||
char buffer[50];
|
char buffer[50];
|
||||||
|
|
||||||
if (parse_date(date, buffer, sizeof(buffer)) > 0)
|
if (parse_date(date, buffer, sizeof(buffer)) > 0)
|
||||||
return strtoul(buffer, NULL, 10);
|
return strtoul(buffer, NULL, 10);
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
localtime_r(&tv.tv_sec, &tm);
|
time_sec = tv.tv_sec;
|
||||||
|
localtime_r(&time_sec, &tm);
|
||||||
now = tm;
|
now = tm;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
unsigned char c = *date;
|
unsigned char c = *date;
|
||||||
|
Loading…
Reference in New Issue
Block a user