[PATCH] tst-mktime.c
Jakub Jelinek
jakub@redhat.com
Wed Apr 17 05:45:00 GMT 2002
On Wed, Apr 17, 2002 at 02:21:46PM +0200, Thorsten Kukuk wrote:
> On Sat, Apr 13, Jakub Jelinek wrote:
>
> > Hi!
> >
> > The PR libc/2738 fix was not entirely correct, since even tm with tm_year 69
> > is representable in certain timezones. This caused e.g. perl-Date-Calc tests
> > to fail. Below is a fix. Years before 69 surely cannot be represented, for
> > 69 it computes the year and checks for overflow afterwards.
> >
> > 2002-04-13 Jakub Jelinek <jakub@redhat.com>
> >
> > * time/mktime.c (__mktime_internal): If year is 69, don't bail out
> > early, but check whether it overflowed afterwards.
> > * time/tst-mktime.c (main): Add new tests.
>
> make check does not longer pass for me with this. Output of
> tst-mktime.out is:
>
> Wednesday
> Dec 31 1969 EST test passed
> mktime returned 3749, expected -1
Weird, I get
Wednesday
Dec 31 1969 EST test passed
Dec 31 1969 CET test passed
on all arches I've bootstrapped it (i386,i686,ia64,alpha,alphaev6).
Looks like tst-mktime cannot find the CET zone file on your box.
Does the following work for you?
Passes for me with current glibc, fails with:
Wednesday
mktime returned -1, expected 3749
Dec 31 1969 CET test passed
with glibc before my mktime patch (expected).
2002-04-17 Jakub Jelinek <jakub@redhat.com>
* time/tst-mktime.c: Include <stdlib.h>.
Use %d, not %ld format for EVENING69.
Include offsets in TZ environment variable.
--- libc/time/tst-mktime.c.jj Wed Apr 17 14:34:34 2002
+++ libc/time/tst-mktime.c Wed Apr 17 14:48:32 2002
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -30,7 +31,7 @@ main (void)
result = strcmp (daybuf, "Wednesday") != 0;
}
- setenv ("TZ", "EST", 1);
+ setenv ("TZ", "EST+5", 1);
#define EVENING69 1 * 60 * 60 + 2 * 60 + 29
t = EVENING69;
tm = localtime (&t);
@@ -45,14 +46,14 @@ main (void)
t = mktime (&time_str);
if (t != EVENING69)
{
- printf ("mktime returned %ld, expected %ld\n",
+ printf ("mktime returned %ld, expected %d\n",
(long) t, EVENING69);
result = 1;
}
else
(void) puts ("Dec 31 1969 EST test passed");
- setenv ("TZ", "CET", 1);
+ setenv ("TZ", "CET-1", 1);
t = mktime (&time_str);
if (t != (time_t) -1)
{
Jakub
More information about the Libc-hacker
mailing list