Outlook 2002 vs. Cyrus 2.1.12
Thomas Fritz
Thomas.Fritz at bam.de
Sat Feb 22 10:28:51 EST 2003
On Mon, 2003-02-10 at 20:52, Lawrence Greenfield wrote:
> From: Fritz Test <Fritz.Test at bam.de>
> Date: 09 Feb 2003 11:25:37 +0100
> [...]
> With help of the analysis of Jeremy (Thanks) I patched the function
> mkgmtime, such that it works for me now. The problem is, that gmtime(&t)
> returns a null pointer for my 64-bit system if t is out of some range. I
> don't know exactly what range, but I assume that the generated value for
> the year must fit in 32 bits?.
>
> Your patch wouldn't work on a system with an unsigned 64-bit time_t.
> (The median value would start out very large, and the binary search
> would never subtract enough to get down into "normal" time.)
>
> It seems to me that moving
> if (bits > 40) { bits = 40; }
>
> to above the
>
> t = (t < 0) ? 0 : ((time_t) 1 << bits);
>
> would fix the problem.
>
> Is my analysis correct?
Please correct me, but I think that the median is calculated here to be
the time_t value which translates to 1970-01-01 00:00:00 GMT. If we
modify 'bits' before caculating the median, we don't start the binary
search with this median value.
Unfortunately, I do not have a platform with unsigned time_t, so I
cannot test. Which systems have unsigned time_t?
Tom
>
> Larry
>
> Here's a snipped of my code in mkgmtime.c
>
> -----------------------------------------------
>
> /*
> ** If time_t is signed, then 0 is the median value,
> ** if time_t is unsigned, then 1 << bits is median.
> */
> t = (t < 0) ? 0 : ((time_t) 1 << bits)
> ;
>
> /* Patch begin */
> /*
> ** On my 32-bit Debian GNU/Linux 3.0 AMD K6 PC, the algorithm
> ** converges in a range
> ** from
> ** 1901-12-13 20:46:00 GMT -> -2147483640
> ** to
> ** 2038-01-19 03:14:07 GMT -> 2147483647
> */
>
> /*
> ** It segfaults on RedHat 7.2/Alpha if bits > 56, since gmtime (&t)
> ** returns null pointer.
> ** Hence, set bits to a resonable value <= 56.
> **
> ** Setting, e.g. bits=40, the algorithm converges in a range
> ** from
> ** -32873-11-12 23:24:00 GMT -> -1099511627760
> ** to
> ** 36812-02-20 00:36:59 GMT -> 1099511627819
> */
> if (bits > 40) {
> bits = 40;
> }
> /* patch end */
>
> for ( ; ; ) {
>
> prt (t);
> fprintf (stderr, " ");
>
>
>
More information about the Info-cyrus
mailing list