next time zone package update
My plan is to wait for Sri Lanka changes (which affect present and future rather than historical instants) then update the elsie ftp directory to contain old-tzcode-32-bit-binary-files.tar.gz (tz32code2006b.tar.gz renamed) and tzcode2006c.tar.gz (not tz64code2006c.tar.gz) and tzdata2006c.tar.gz (not tz64data2006c.tar.gz) Proposed code changes are at the end of this message; the changes would: 1. eliminate conditionalization on __STDC__ by assuming a standard-conforming compiler is in use; 2. avoid gcc warnings about format strings in asctime; 3. introduce binary search logic in localtime.c. At least for now, the plan is to forego size_t tweaks, changes in default zdump cutoff years, and elimination of the P (paramater) macro. --ado ------- asctime.c ------- *** /tmp/geta17330 Tue Mar 14 10:20:10 2006 --- /tmp/getb17330 Tue Mar 14 10:20:10 2006 *************** *** 11,17 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)asctime.c 8.1"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 11,17 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)asctime.c 8.2"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 23,29 **** /* ** Some systems only handle "%.2d"; others only handle "%02d"; ** "%02.2d" makes (most) everybody happy. ! ** At least some versions of gcc warn about the %02.2d; ignore the warning. */ /* ** All years associated with 32-bit time_t values are exactly four digits long; --- 23,30 ---- /* ** Some systems only handle "%.2d"; others only handle "%02d"; ** "%02.2d" makes (most) everybody happy. ! ** At least some versions of gcc warn about the %02.2d; ! ** we conditionalize below to avoid the warning. */ /* ** All years associated with 32-bit time_t values are exactly four digits long; *************** *** 37,43 **** --- 38,48 ---- ** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year, ** but many implementations pad anyway; most likely the standards are buggy. */ + #ifdef __GNUC__ + #define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" + #else /* !defined __GNUC__ */ #define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n" + #endif /* !defined __GNUC__ */ /* ** For years that are more than four digits we put extra spaces before the year ** so that code trying to overwrite the newline won't end up overwriting *************** *** 44,50 **** --- 49,59 ---- ** a digit within a year and truncating the year (operating on the assumption ** that no output is better than wrong output). */ + #ifdef __GNUC__ + #define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n" + #else /* !defined __GNUC__ */ #define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n" + #endif /* !defined __GNUC__ */ #define STD_ASCTIME_BUF_SIZE 26 /* ------- date.c ------- *** /tmp/geta17349 Tue Mar 14 10:20:10 2006 --- /tmp/getb17349 Tue Mar 14 10:20:10 2006 *************** *** 1,6 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)date.c 8.1"; /* ** Modified from the UCB version with the SCCS ID appearing below. */ --- 1,6 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)date.c 8.2"; /* ** Modified from the UCB version with the SCCS ID appearing below. */ *************** *** 352,364 **** /*ARGSUSED*/ static void - #if __STDC__ reset(const time_t newt, const int nflag) - #else /* !__STDC__ */ - reset(newt, nflag) - const time_t newt; - const int nflag; - #endif /* !__STDC__ */ { register int fid; time_t oldt; --- 352,358 ---- *************** *** 623,636 **** #define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2; static time_t - #if __STDC__ convert(register const char * const value, const int dousg, const time_t t) - #else /* !__STDC__ */ - convert(value, dousg, t) - register const char * const value; - const int dousg; - const time_t t; - #endif /* !__STDC__ */ { register const char * cp; register const char * dotp; --- 617,623 ---- *************** *** 734,751 **** */ static void - #if __STDC__ checkfinal(const char * const value, const int didusg, const time_t t, const time_t oldnow) - #else /* !__STDC__ */ - checkfinal(value, didusg, t, oldnow) - const char * const value; - const int didusg; - const time_t t; - const time_t oldnow; - #endif /* !__STDC__ */ { time_t othert; struct tm tm; --- 721,730 ---- *************** *** 804,819 **** } static void - #if __STDC__ iffy(const time_t thist, const time_t thatt, const char * const value, const char * const reason) - #else /* !__STDC__ */ - iffy(thist, thatt, value, reason) - const time_t thist; - const time_t thatt; - const char * const value; - const char * const reason; - #endif /* !__STDC__ */ { struct tm tm; --- 783,790 ---- ------- localtime.c ------- *** /tmp/geta17444 Tue Mar 14 10:20:12 2006 --- /tmp/getb17444 Tue Mar 14 10:20:12 2006 *************** *** 5,11 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.1"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 5,11 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.3"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 602,614 **** */ static const char * - #if __STDC__ getqzname(register const char *strp, const int delim) - #else /* !__STDC__ */ - getqzname(strp, delim) - register const char * strp; - const int delim; - #endif /* !__STDC__ */ { register int c; --- 602,608 ---- *************** *** 1263,1272 **** break; } } else { ! for (i = 1; i < sp->timecnt; ++i) ! if (t < sp->ats[i]) ! break; ! i = (int) sp->types[i - 1]; } ttisp = &sp->ttis[i]; /* --- 1257,1273 ---- break; } } else { ! register int lo = 1; ! register int hi = sp->timecnt; ! ! while (lo < hi) { ! register int mid = (lo + hi) >> 1; ! ! if (t < sp->ats[mid]) ! hi = mid; ! else lo = mid + 1; ! } ! i = (int) sp->types[lo - 1]; } ttisp = &sp->ttis[i]; /* ------- private.h ------- *** /tmp/geta17482 Tue Mar 14 10:20:12 2006 --- /tmp/getb17482 Tue Mar 14 10:20:12 2006 *************** *** 21,27 **** #ifndef lint #ifndef NOID ! static char privatehid[] = "@(#)private.h 8.1"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 21,27 ---- #ifndef lint #ifndef NOID ! static char privatehid[] = "@(#)private.h 8.2"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 152,166 **** */ /* ! ** SunOS 4.1.1 cc lacks prototypes. */ #ifndef P - #if __STDC__ #define P(x) x - #else /* !__STDC__ */ - #define P(x) () - #endif /* ! __STDC__ */ #endif /* !defined P */ /* --- 152,162 ---- */ /* ! ** If your compiler lacks prototypes, "#define P(x) ()". */ #ifndef P #define P(x) x #endif /* !defined P */ /* ------- zdump.c ------- *** /tmp/geta17586 Tue Mar 14 10:20:14 2006 --- /tmp/getb17586 Tue Mar 14 10:20:14 2006 *************** *** 1,4 **** ! static char elsieid[] = "@(#)zdump.c 8.1"; /* ** This code has been made independent of the rest of the time --- 1,4 ---- ! static char elsieid[] = "@(#)zdump.c 8.2"; /* ** This code has been made independent of the rest of the time *************** *** 130,140 **** #endif /* !defined TZ_DOMAIN */ #ifndef P - #if __STDC__ #define P(x) x - #else /* !__STDC__ */ - #define P(x) () - #endif /* !__STDC__ */ #endif /* !defined P */ extern char ** environ; --- 130,136 ---- *************** *** 475,488 **** } static time_t - #if __STDC__ hunt(char *name, time_t lot, time_t hit) - #else /* !__STDC__ */ - hunt(name, lot, hit) - char * name; - time_t lot; - time_t hit; - #endif /* !__STDC__ */ { time_t t; long diff; --- 471,477 ---- *************** *** 552,565 **** } static void - #if __STDC__ show(char *zone, time_t t, int v) - #else /* !__STDC__ */ - show(zone, t, v) - char * zone; - time_t t; - int v; - #endif /* !__STDC__ */ { register struct tm * tmp; --- 541,547 ----
On Tue, Mar 14, 2006 at 10:49:13AM -0500, Arthur David Olson wrote:
Proposed code changes are at the end of this message; the changes would: 1. eliminate conditionalization on __STDC__ by assuming a standard-conforming compiler is in use; 2. avoid gcc warnings about format strings in asctime; 3. introduce binary search logic in localtime.c.
Could you also please include the patch that Paul Eggert had in message <87k6blg49q.fsf@penguin.cs.ucla.edu> (Thu, 23 Feb 2006 13:21:37 -0800) for automatically setting HAVE_STDINT_H on glibc systems (like Linux)? (I've appended it below so you don't have to hunt the archives.) --Ken Pizzini --- private.h 2006/02/23 06:18:32 2006.2.0.5 +++ private.h 2006/02/23 21:16:15 2006.2.0.7 @@ -48,10 +48,6 @@ static char privatehid[] = "@(#)private. #define HAVE_SETTIMEOFDAY 3 #endif /* !defined HAVE_SETTIMEOFDAY */ -#ifndef HAVE_STDINT_H -#define HAVE_STDINT_H (199901 <= __STDC_VERSION__) -#endif /* !defined HAVE_STDINT_H */ - #ifndef HAVE_STRERROR #define HAVE_STRERROR 1 #endif /* !defined HAVE_STRERROR */ @@ -128,20 +124,30 @@ static char privatehid[] = "@(#)private. /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) +/* Define HAVE_STDINT_H's default value here, rather than at the + start, since __GLIBC__'s value depends on previously-included + files. (glibc 2.1 and later have stdint.h, even with pre-C99 + compilers.) */ +#ifndef HAVE_STDINT_H +#define HAVE_STDINT_H \ + (199901 <= __STDC_VERSION__ || 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) +#endif /* !defined HAVE_STDINT_H */ + #if HAVE_STDINT_H #include <stdint.h> #endif /* !HAVE_STDINT_H */ #ifndef INT_FAST64_MAX -#ifdef LLONG_MAX +/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ +#if defined LLONG_MAX || defined __LONG_LONG_MAX__ typedef long long int_fast64_t; -#else /* !defined LLONG_MAX */ +#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ #if (LONG_MAX >> 31) < 0xffffffff Please use a compiler that supports a 64-bit integer type (or wider); you may need to compile with "-DHAVE_STDINT_H". #endif /* (LONG_MAX >> 31) < 0xffffffff */ typedef long int_fast64_t; -#endif /* !defined LLONG_MAX */ +#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ #endif /* !defined INT_FAST64_MAX */ #ifndef INT32_MAX
Arthur David Olson <olsona@elsie.nci.nih.gov> writes:
My plan is to wait for Sri Lanka changes (which affect present and future rather than historical instants)
I'll try to get those done by Thursday.
At least for now, the plan is to forego size_t tweaks, changes in default zdump cutoff years, and elimination of the P (paramater) macro.
OK, thanks; should I submit these proposed changes again after 2006c comes out, or just leave the issues alone for a while? (No doubt you have other things to do too....) Like Ken, I'd also like to see the __LONG_LONG_MAX__ and HAVE_STDINT_H patches for private.h, as this makes things more convenient for GCC and glibc users.
participants (3)
-
Arthur David Olson -
Ken Pizzini -
Paul Eggert