Mercurial > gnulib
diff lib/mktime.c @ 7276:4be2c469b318
* config/srclist.txt: Temporarily comment out mktime.c until glibc bug
2821 is fixed.
* lib/mktime.c (guess_time_tm): Fix bug where mktime
returned the maximum time_t value rather than (time_t) -1.
Problem originally reported by William Bardwell
<http://sourceware.org/bugzilla/show_bug.cgi?id=2821>.
* m4/mktime.m4 (AC_FUNC_MKTIME): Sync from Autoconf.
Check for unistd.h too, since Autoconf doesn't assume POSIX.
Also:
2006-09-08 Paul Eggert <eggert@cs.ucla.edu>
Add year_2050_test to catch glibc bug 2821
<http://sourceware.org/bugzilla/show_bug.cgi?id=2821>.
2006-08-15 Paul Eggert <eggert@cs.ucla.edu>
Prefer #ifdef to #if.
2006-04-02 Paul Eggert <eggert@cs.ucla.edu>
Return from 'main' instead of calling 'exit'.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 08 Sep 2006 22:48:25 +0000 |
parents | c7eeea00ac4b |
children | 429742e1c41d |
line wrap: on
line diff
--- a/lib/mktime.c Fri Sep 08 17:11:17 2006 +0000 +++ b/lib/mktime.c Fri Sep 08 22:48:25 2006 +0000 @@ -1,5 +1,5 @@ /* Convert a `struct tm' to a time_t value. - Copyright (C) 1993-1999, 2002-2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1993-1999, 2002-2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert (eggert@twinsun.com). @@ -215,10 +215,11 @@ /* Overflow occurred one way or another. Return the nearest result that is actually in range, except don't report a zero difference if the actual difference is nonzero, as that would cause a false - match. */ + match; and don't oscillate between two values, as that would + confuse the spring-forward gap detector. */ return (*t < TIME_T_MIDPOINT - ? TIME_T_MIN + (*t == TIME_T_MIN) - : TIME_T_MAX - (*t == TIME_T_MAX)); + ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN) + : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX)); } /* Use CONVERT to convert *T to a broken down time in *TP.