This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/473] mktime.c patches for Southern hemisphere and 64-bit time_t
- From: "eggert at gnu dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 27 Oct 2004 21:54:01 -0000
- Subject: [Bug libc/473] mktime.c patches for Southern hemisphere and 64-bit time_t
- References: <20041022214551.473.eggert@gnu.org>
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
------- Additional Comments From eggert at gnu dot org 2004-10-27 21:54 -------
The existing tst-mktime is incorrect. It assumes that mktime must
fail when presented with a time stamp before 1970-01-01 00:00:00 UTC.
However, POSIX does not require mktime to fail, and BSD mktime returns
a negative time_t value in such cases. Thus the existing tst-mktime
also fails under Debian stable, under Solaris 9, and under OpenBSD
3.4, because they are all compatible with BSD.
POSIX does not require the BSD behavior for negative time stamps, but
it's better to be compatible, especially if it's easy (which is the
case here), so tst-mktime should be changed to check for the BSD
behavior.
Here is a patch to tst-mktime. This patch assumes that time_t is
signed, but tst-mktime already makes the same assumption, so I guess
it's safe.
2004-10-24 Paul Eggert <eggert@cs.ucla.edu>
* time/tst-mktime.c (main): Don't assume that mktime fails
when given time stamps before 1970. It returns negative
time_t values instead, for compatibility with BSD.
--- old/time/tst-mktime.c 2002-04-18 20:28:16 -0700
+++ new/time/tst-mktime.c 2004-10-24 16:43:52 -0700
@@ -55,9 +55,11 @@ main (void)
setenv ("TZ", "CET-1", 1);
t = mktime (&time_str);
- if (t != (time_t) -1)
+#define EVENING69_CET (EVENING69 - (5 - -1) * 60 * 60)
+ if (t != EVENING69_CET)
{
- printf ("mktime returned %ld, expected -1\n", (long) t);
+ printf ("mktime returned %ld, expected %ld\n",
+ (long) t, (long) EVENING69_CET);
result = 1;
}
else
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
http://sources.redhat.com/bugzilla/show_bug.cgi?id=473
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.