From 63830e1db4ba04b75d0cc6cdd95cb9a15caecdc9 Mon Sep 17 00:00:00 2001 From: Arthur David Olson Date: Tue, 16 Jan 1996 12:04:09 -0500 Subject: [PATCH] Eggert tuneups SCCS-file: localtime.c SCCS-SID: 7.51 --- localtime.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/localtime.c b/localtime.c index b2affbe..787e907 100644 --- a/localtime.c +++ b/localtime.c @@ -1163,13 +1163,11 @@ register struct tm * const tmp; tmp->tm_hour = (int) (rem / SECSPERHOUR); rem = rem % SECSPERHOUR; tmp->tm_min = (int) (rem / SECSPERMIN); - tmp->tm_sec = (int) (rem % SECSPERMIN); - if (hit) - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60" et seq. - */ - tmp->tm_sec += hit; + /* + ** A positive leap second requires a special + ** representation. This uses "... ??:59:60" et seq. + */ + tmp->tm_sec = (int) (rem % SECSPERMIN) + hit; tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); if (tmp->tm_wday < 0) tmp->tm_wday += DAYSPERWEEK; @@ -1344,15 +1342,14 @@ int * const okayp; /* ** Calculate the number of magnitude bits in a time_t ** (this works regardless of whether time_t is - ** signed or unsigned, though lint complains if unsigned). + ** signed or unsigned). */ - for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) - continue; + bits = TYPE_BIT(time_t) - TYPE_SIGNED(time_t); /* ** If time_t is signed, then 0 is the median value, - ** if time_t is unsigned, then 1 << bits is median. + ** if time_t is unsigned, then 1 << (bits - 1) is median. */ - t = (t < 0) ? 0 : ((time_t) 1 << bits); + t = TYPE_SIGNED(time_t) ? 0 : ((time_t) 1 << (TYPE_BIT(time_t) - 1)); for ( ; ; ) { (*funcp)(&t, offset, &mytm); dir = tmcomp(&mytm, &yourtm);