@matheusbsbs / matheus-bagliano / commits / f697b33b01
Fork 0

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>

Bernd Ahlers committed Apr 6, 2009 at 19:26 UTC f697b33b015fcb0c90210840eb4ef8e6a18d4bdf
1 file changed +3 -1
date.c
+3 -1
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
871 int number = 0;
872 struct tm tm, now;
873 struct timeval tv;
874 + time_t time_sec;
875 char buffer[50];
876
877 if (parse_date(date, buffer, sizeof(buffer)) > 0)
878 return strtoul(buffer, NULL, 10);
879
880 gettimeofday(&tv, NULL);
880 - localtime_r(&tv.tv_sec, &tm);
881 + time_sec = tv.tv_sec;
882 + localtime_r(&time_sec, &tm);
883 now = tm;
884 for (;;) {
885 unsigned char c = *date;