proposed zic.c change to cope with "32 < sizeof (time_t)"
Arthur David Olson
ado
Sat Oct 21 10:02:11 UTC 1995
Attached is a proposed change to let zic.c cope gracefully when
32 < sizeof (time_t)
I'll make it part of the ftpable stuff if nobody squawks in the next week.
--ado
SCCS/s.zic.c: 7.50 vs. 7.51
*** 7.50/zic.c Sat Oct 21 05:58:46 1995
--- 7.51/zic.c Sat Oct 21 05:58:47 1995
***************
*** 1,6 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)zic.c 7.50";
#endif /* !defined NOID */
#endif /* !defined lint */
--- 1,6 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)zic.c 7.51";
#endif /* !defined NOID */
#endif /* !defined lint */
***************
*** 567,594 ****
ifree(toname);
}
static void
setboundaries P((void))
{
register time_t bit;
! register int bii;
for (bit = 1; bit > 0; bit <<= 1)
! continue;
! if (bit == 0) { /* time_t is an unsigned type */
! tt_signed = FALSE;
! min_time = 0;
! max_time = ~(time_t) 0;
if (sflag)
! max_time >>= 1;
} else {
! tt_signed = TRUE;
! min_time = bit;
! max_time = bit;
! ++max_time;
! max_time = -max_time;
if (sflag)
! min_time = 0;
}
min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year;
max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year;
--- 567,613 ----
ifree(toname);
}
+ #define MAX_BITS_IN_FILE 32
+
static void
setboundaries P((void))
{
register time_t bit;
! register int nbits;
! register int bii;
+ nbits = 0;
for (bit = 1; bit > 0; bit <<= 1)
! ++nbits;
! tt_signed = (bit != 0);
! if (tt_signed)
! ++nbits;
! if (tt_signed) {
! if (nbits <= MAX_BITS_IN_FILE) {
! min_time = bit;
! max_time = bit;
! ++max_time;
! max_time = -max_time;
! } else {
! max_time = 1;
! max_time <<= (MAX_BITS_IN_FILE - 1);
! --max_time;
! min_time = max_time;
! --min_time;
! }
if (sflag)
! min_time = 0;
} else {
! min_time = 0;
! if (nbits <= MAX_BITS_IN_FILE)
! max_time = ~(time_t) 0;
! else {
! max_time = 1;
! max_time <<= MAX_BITS_IN_FILE;
! --max_time;
! }
if (sflag)
! max_time >>= 1;
}
min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year;
max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year;
More information about the tz
mailing list