Proposed tz code cleanups
Arthur David Olson
olsona at lecserver.nci.nih.gov
Thu Feb 16 16:26:19 UTC 2006
Along with the 64-bit changes previously circulated on the time zone list and
due to show up in the ftp version on Monday, here are proposed STDC, long,
and overflow cleanups from Paul Eggert and Ken Pizzini.
diff -r -c old/date.c new/date.c
*** old/date.c Thu Jan 26 10:19:21 2006
--- new/date.c Thu Feb 16 11:05:15 2006
***************
*** 1,6 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)date.c 7.42";
/*
** Modified from the UCB version with the SCCS ID appearing below.
*/
--- 1,6 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)date.c 7.44";
/*
** Modified from the UCB version with the SCCS ID appearing below.
*/
***************
*** 254,260 ****
struct timeval tv;
tv.tv_sec = (int) adjust;
! tv.tv_usec = (int) ((adjust - tv.tv_sec) * 1000000);
if (adjtime(&tv, (struct timeval *) NULL) != 0)
oops("adjtime");
#endif /* HAVE_ADJTIME */
--- 254,260 ----
struct timeval tv;
tv.tv_sec = (int) adjust;
! tv.tv_usec = (int) ((adjust - tv.tv_sec) * 1000000L);
if (adjtime(&tv, (struct timeval *) NULL) != 0)
oops("adjtime");
#endif /* HAVE_ADJTIME */
***************
*** 352,360 ****
--- 352,364 ----
/*ARGSUSED*/
static void
+ #ifdef __STDC__
+ reset(const time_t newt, const int nflag)
+ #else /* !defined __STDC__ */
reset(newt, nflag)
const time_t newt;
const int nflag;
+ #endif /* !defined __STDC__ */
{
register int fid;
time_t oldt;
***************
*** 619,628 ****
--- 623,636 ----
#define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2;
static time_t
+ #ifdef __STDC__
+ convert(register const char * const value, const int dousg, const time_t t)
+ #else /* !defined __STDC__ */
convert(value, dousg, t)
register const char * const value;
const int dousg;
const time_t t;
+ #endif /* !defined __STDC__ */
{
register const char * cp;
register const char * dotp;
***************
*** 726,736 ****
--- 734,751 ----
*/
static void
+ #ifdef __STDC__
+ checkfinal(const char * const value,
+ const int didusg,
+ const time_t t,
+ const time_t oldnow)
+ #else /* !defined __STDC__ */
checkfinal(value, didusg, t, oldnow)
const char * const value;
const int didusg;
const time_t t;
const time_t oldnow;
+ #endif /* !defined __STDC__ */
{
time_t othert;
struct tm tm;
***************
*** 789,799 ****
--- 804,819 ----
}
static void
+ #ifdef __STDC__
+ iffy(const time_t thist, const time_t thatt,
+ const char * const value, const char * const reason)
+ #else /* !defined __STDC__ */
iffy(thist, thatt, value, reason)
const time_t thist;
const time_t thatt;
const char * const value;
const char * const reason;
+ #endif /* !defined __STDC__ */
{
struct tm tm;
diff -r -c old/localtime.c new/localtime.c
*** old/localtime.c Thu Jan 26 10:19:21 2006
--- new/localtime.c Thu Feb 16 11:07:47 2006
***************
*** 5,11 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)localtime.c 7.97";
#endif /* !defined NOID */
#endif /* !defined lint */
--- 5,11 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)localtime.c 7.98";
#endif /* !defined NOID */
#endif /* !defined lint */
***************
*** 510,518 ****
--- 510,522 ----
*/
static const char *
+ #ifdef __STDC__
+ getqzname(register const char *strp, const char delim)
+ #else /* !defined __STDC__ */
getqzname(strp, delim)
register const char * strp;
const char delim;
+ #endif /* !defined __STDC__ */
{
register char c;
diff -r -c old/zdump.c new/zdump.c
*** old/zdump.c Thu Jan 26 10:19:21 2006
--- new/zdump.c Thu Feb 16 11:16:58 2006
***************
*** 1,4 ****
! static char elsieid[] = "@(#)zdump.c 7.74";
/*
** This code has been made independent of the rest of the time
--- 1,4 ----
! static char elsieid[] = "@(#)zdump.c 7.76";
/*
** This code has been made independent of the rest of the time
***************
*** 15,21 ****
#include "ctype.h" /* for isalpha et al. */
#ifndef isascii
#define isascii(x) 1
! #endif
#ifndef ZDUMP_LO_YEAR
#define ZDUMP_LO_YEAR (-500)
--- 15,21 ----
#include "ctype.h" /* for isalpha et al. */
#ifndef isascii
#define isascii(x) 1
! #endif /* !defined isascii */
#ifndef ZDUMP_LO_YEAR
#define ZDUMP_LO_YEAR (-500)
***************
*** 418,431 ****
}
} else if (0 > (time_t) -1) {
/*
! ** time_t is signed.
*/
! register time_t hibit;
! for (hibit = 1; (hibit * 2) != 0; hibit *= 2)
! continue;
! absolute_min_time = hibit;
! absolute_max_time = -(hibit + 1);
} else {
/*
** time_t is unsigned.
--- 418,438 ----
}
} else if (0 > (time_t) -1) {
/*
! ** time_t is signed. Assume overflow wraps around.
*/
! time_t t = 0;
! time_t t1 = 1;
! while (t < t1) {
! t = t1;
! t1 = 2 * t1 + 1;
! }
!
! absolute_max_time = t;
! t = -t;
! absolute_min_time = t - 1;
! if (t < absolute_min_time)
! absolute_min_time = t;
} else {
/*
** time_t is unsigned.
***************
*** 468,477 ****
--- 475,488 ----
}
static time_t
+ #ifdef __STDC__
+ hunt(char *name, time_t lot, time_t hit)
+ #else /* !defined __STDC__ */
hunt(name, lot, hit)
char * name;
time_t lot;
time_t hit;
+ #endif /* !defined __STDC__ */
{
time_t t;
long diff;
***************
*** 541,550 ****
--- 552,565 ----
}
static void
+ #ifdef __STDC__
+ show(char *zone, time_t t, int v)
+ #else /* !defined __STDC__ */
show(zone, t, v)
char * zone;
time_t t;
int v;
+ #endif /* !defined __STDC__ */
{
register struct tm * tmp;
More information about the tz
mailing list