minor tz tuneups and portability fix
kre at munnari.OZ.AU
Mon Jan 15 08:18:49 UTC 1996
Date: Sun, 14 Jan 1996 22:37:20 -0800
From: Paul Eggert <eggert at twinsun.com>
Message-ID: <199601150637.WAA15042 at der.twinsun.com>
While accumulating these I noticed a portability bug in localtime.c;
the expression `(t < 0) ? 0 : ((time_t) 1 << bits)' yields undefined
results if time_t is unsigned, since `bits' is the number of bits in
a time_t in that case. The patch below fixes this bug as part of the tuneups.
It is a "portability bug" in the sense that it is simply wrong
if time_t is unsigned (but OK for signed time_t). I am not
sure how this happened - I actually had unsigned time_t for
a while (and it was in some BSD beta release ages ago, before
people west of Greenwich complained about what that meant to
((time_t)0) when converted to local time...
That is, once upon a time, this code was actually tested, and
worked, with unsigned time_t, somehow it seems to have suffered
some bit rot... Unfortunately I don't have any very ancient
versions to look see what happened there. (bits - 1) is
clearly the right thing (1 << bits) is going to be either 0 or
1 on most architectures (but might be anything).
More information about the tz