summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-11 17:46:33 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-11 17:46:33 +0000
commit7d5e7fb43d575c54a7fe0b995e331f39c260a642 (patch)
treeece2955b3cb32dd5f333d0e5c5b95ea2952371b4
parent7f256c176b27a96548e19698117d1f933b47a4cd (diff)
from netbsd; sync with tzcode96a
-rw-r--r--lib/libc/time/Music81
-rw-r--r--lib/libc/time/Theory20
-rw-r--r--lib/libc/time/WWW71
-rw-r--r--lib/libc/time/ctime.35
-rw-r--r--lib/libc/time/localtime.c68
-rw-r--r--lib/libc/time/private.h23
-rw-r--r--lib/libc/time/scheck.c6
-rw-r--r--lib/libc/time/tzset.35
-rw-r--r--lib/libc/time/zic.89
-rw-r--r--lib/libc/time/zic.c111
10 files changed, 291 insertions, 108 deletions
diff --git a/lib/libc/time/Music b/lib/libc/time/Music
new file mode 100644
index 00000000000..9fb0cecacca
--- /dev/null
+++ b/lib/libc/time/Music
@@ -0,0 +1,81 @@
+@(#)Music 7.4
+
+Data on recordings of "Save That Time," Russ Long, Serrob Publishing, BMI:
+--------------------------------------------------------------------------
+Artist: Karrin Allyson
+CD: I Didn't Know About You
+Copyright Date: 1993
+Label: Concord Jazz, Inc.
+ID: CCD-4543
+Track Time: 3:44
+Personnel: Karrin Allyson, vocal
+ Russ Long, piano
+ Gerald Spaits, bass
+ Todd Strait, drums
+Notes: CD notes "additional lyric by Karrin Allyson;
+ arranged by Russ Long and Karrin Allyson"
+Rating: 1 star
+--------------------------------------------------------------------------
+Artist: Kevin Mahogany
+CD: Double Rainbow
+Copyright Date: 1993
+Label: Enja Records
+ID: ENJ-7097 2
+Track Time: 6:27
+Personnel: Kevin Mahogany, vocal
+ Kenny Barron, piano
+ Ray Drummond, bss
+ Ralph Moore, tenor saxophone
+ Lewis Nash, drums
+Rating: 1.5 stars
+--------------------------------------------------------------------------
+Artist: Joe Williams
+CD: Here's to Life
+Copyright Date: 1994
+Label: Telarc International Corporation
+ID: CD-83357
+Track Time: 3:58
+Personnel: Joe Williams, vocal
+ The Robert Farnon [39 piece] Orchestra
+Rating: black dot
+--------------------------------------------------------------------------
+Artist: Charles Fambrough
+CD: Keeper of the Spirit
+Copyright Date: 1995
+Label: AudioQuest Music
+ID: AQ-CD1033
+Track Time: 7:07
+Personnel: Charles Fambrough, bass
+ Joel Levine, tenor recorder
+ Edward Simon, piano
+ Lenny White, drums
+ Marion Simon, percussion
+Rating: 2 stars
+==========================================================================
+Also of note:
+Artist: Milt Hinton
+CD: Old Man Time
+Date: 1993
+Label: Chiaroscuro
+ID: CR(D) 310
+Total Time: 149:38 (two CDs)
+Personnel: Milt Hinton, bass
+ Doc Cheatham, Dizzy Gillespie, Clark Terry, trumpet
+ Al Grey, trombone
+ Eddier Barefield, Joe Camel (Flip Phillips), Buddy Tate,
+ clarinet and saxophone
+ John Bunch, Red Richards, Norman Simmons, Derek Smith,
+ Ralph Sutton, piano
+ Danny Barker, Al Casey, guitar
+ Gus Johnson, Gerryck King, Bob Rosengarden, Jackie Williams,
+ drums
+ Lionel Hampton, vibraphone
+ Cab Calloway, Joe Williams, vocal
+ Buck Clayton, arrangements
+Notes: tunes include Old Man Time, Time After Time,
+ Sometimes I'm Happy,
+ A Hot Time in the Old Town Tonight,
+ Four or Five Times, Now's the Time,
+ Time on My Hands, This Time It's Us,
+ and Good Time Charlie
+Rating: 3 stars
diff --git a/lib/libc/time/Theory b/lib/libc/time/Theory
index 93a07c0f7da..2e346633e58 100644
--- a/lib/libc/time/Theory
+++ b/lib/libc/time/Theory
@@ -1,4 +1,4 @@
-@(#)Theory 7.2
+@(#)Theory 7.4
These time and date functions are much like the System V Release 2.0 (SVR2)
time and date functions; there are a few additions and changes to extend
@@ -47,7 +47,7 @@ These are the changes that have been made to the SVR2 functions:
abbreviations are used.
It was recognized that allowing the "TZ" environment variable to
- take on values such as "US/Eastern" might cause "old" programs
+ take on values such as "America/New_York" might cause "old" programs
(that expect "TZ" to have a certain form) to operate incorrectly;
consideration was given to using some other environment variable
(for example, "TIMEZONE") to hold the string used to generate the
@@ -79,8 +79,8 @@ These are the changes that have been made to the SVR2 functions:
best approximation to local wall clock time to be delivered by
subsequent calls to "localtime." Source code for portable
applications that "must" run on local wall clock time should call
- "tzsetwall();" if such code is moved to "old" systems that don't provide
- tzsetwall, you won't be able to generate an executable program.
+ "tzsetwall();" if such code is moved to "old" systems that don't
+ provide tzsetwall, you won't be able to generate an executable program.
(These time zone functions also arrange for local wall clock time to be
used if tzset is called--directly or indirectly--and there's no "TZ"
environment variable; portable applications should not, however, rely
@@ -94,8 +94,8 @@ Points of interest to folks with Version 7 or BSD systems:
time zone abbreviation, and we refuse to guess.
Programs that in the past used the timezone function may now examine
tzname[localtime(&clock)->tm_isdst] to learn the correct time
- zone abbreviation to use. Alternatively, use localtime(&clock)->tm_zone
- if this has been enabled.
+ zone abbreviation to use. Alternatively, use
+ localtime(&clock)->tm_zone if this has been enabled.
* The BSD gettimeofday function is not used in this package;
this lets users control the time zone used in doing time conversions.
@@ -104,10 +104,10 @@ Points of interest to folks with Version 7 or BSD systems:
file "/etc/zoneinfo/localtime"; see the time zone compiler writeup for
information on how to initialize this file.
-The functions that are conditionally compiled if STD_INSPIRED is defined should,
-at this point, be looked on primarily as food for thought. They are not in
-any sense "standard compatible"--some are not, in fact, specified in *any*
-standard. They do, however, represent responses of various authors to
+The functions that are conditionally compiled if STD_INSPIRED is defined
+should, at this point, be looked on primarily as food for thought. They are
+not in any sense "standard compatible"--some are not, in fact, specified in
+*any* standard. They do, however, represent responses of various authors to
standardization proposals.
Other time conversion proposals, in particular the one developed by folks at
diff --git a/lib/libc/time/WWW b/lib/libc/time/WWW
new file mode 100644
index 00000000000..d2fd6844819
--- /dev/null
+++ b/lib/libc/time/WWW
@@ -0,0 +1,71 @@
+# '@(#)WWW 7.3'
+
+# From Paul Eggert <eggert@twinsun.com> (1995-11-03)
+#
+# The Web has several other sources for time zone and daylight savings data.
+# Here are some recent links that may be of interest.
+#
+# Date and Time Gateway
+# http://www.bsdi.com/date
+# A text-based source for tables of current time throughout the world.
+# Its point-and-click interface accesses a recent version of the tz data.
+#
+# Local Times Around the World
+# http://www.hilink.com.au/times/
+# This text-based system contains links to local time servers
+# throughout the world, and though the coverage is limited,
+# the live data provide a nice way to check one's tables.
+#
+# World Time Zones
+# http://tycho.usno.navy.mil/tzones.html
+# US Naval Observatory data, used as the source for `usno1995'.
+#
+# Standard Time Zones of the World
+# http://www.odci.gov/cia/publications/95fact/802389.gif [54 kB]
+# http://www.odci.gov/cia/publications/95fact/802389h.gif [1317 kB]
+# A static time zone map, available in both low-resolution and
+# high-resolution versions. The quality is good, but the map does not
+# indicate summer time, and parts of the data are a few years out of date.
+#
+# VIBE's World Map
+# http://pathfinder.com/vibe/vibeworld
+# An active time zone map. You can point to the map and find out what
+# time it is at that location. The map and data are not as good as
+# other sources.
+
+###############################################################################
+
+# From Manavendra Thakur <Manavendra_Thakur@NeXT.COM> (1995-11-06)
+#
+# To Paul's list of time zone information on the web, I would add the
+# following URL:
+# http://www.dhl.com/dhl/dhlinfo/1bb.html
+# or more simply:
+# http://www.dhl.com/
+#
+# This is run by DHL (the courier company), and it presents a list of the
+# countries served by that company. If you then click on a particular
+# country, here's an example of what you'll see (graphics stripped out):
+#
+# United Kingdom
+#
+# HOLIDAYS: Jan 1, 2, Apr 14, 17, May 1, 29, Aug 28, Dec 25, 26
+#
+# INTERNATIONAL DIALING CODE: +44
+#
+# CURRENT LOCAL TIME: 09:41 Monday 6 November 1995
+#
+# I find this rather handy, and given that DHL covers 217 countries and
+# territories, it's pretty comprehensive coverage.
+#
+# (I have no idea what system DHL is using to calculate the local time, but
+# it's been accurate so far.)
+
+###############################################################################
+
+
+# From Arthur David Olson <arthur_david_olson@nih.gov> (1996-01-04)
+#
+# A good source of information about ISO 8601 seems to be
+# http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html
+# maintained by Markus Kuhn.
diff --git a/lib/libc/time/ctime.3 b/lib/libc/time/ctime.3
index 3fa85134423..f4aabc8866e 100644
--- a/lib/libc/time/ctime.3
+++ b/lib/libc/time/ctime.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: ctime.3,v 1.6.2.1 1995/10/26 05:24:48 jtc Exp $
+.\" $NetBSD: ctime.3,v 1.8 1996/01/08 22:50:54 jtc Exp $
.TH CTIME 3
.SH NAME
asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time to ASCII
@@ -199,6 +199,7 @@ UTC leap seconds are loaded from
.BR /usr/share/zoneinfo/posixrules .
.SH SEE ALSO
getenv(3),
+strftime(3),
tzset(3),
time(3),
tzfile(5)
@@ -217,4 +218,4 @@ will also be overwritten at the next call
Avoid using out-of-range values with
.I mktime
when setting up lunch with promptness sticklers in Riyadh.
-.\" @(#)newctime.3 7.9
+.\" @(#)newctime.3 7.11
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c
index 5014b3f8571..79f88efff09 100644
--- a/lib/libc/time/localtime.c
+++ b/lib/libc/time/localtime.c
@@ -1,8 +1,8 @@
-/* $NetBSD: localtime.c,v 1.4 1995/03/16 19:14:16 jtc Exp $ */
+/* $NetBSD: localtime.c,v 1.5 1996/01/08 22:50:55 jtc Exp $ */
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)localtime.c 7.43";
+static char elsieid[] = "@(#)localtime.c 7.50";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -214,8 +214,8 @@ const char * const codep;
static void
settzname P((void))
{
- register struct state * const sp = lclptr;
- register int i;
+ register struct state * const sp = lclptr;
+ register int i;
tzname[0] = wildabbr;
tzname[1] = wildabbr;
@@ -430,7 +430,7 @@ register const char * strp;
{
register char c;
- while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' &&
+ while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
c != '+')
++strp;
return strp;
@@ -453,15 +453,15 @@ const int max;
register char c;
register int num;
- if (strp == NULL || !isdigit(*strp))
+ if (strp == NULL || !is_digit(c = *strp))
return NULL;
num = 0;
- while ((c = *strp) != '\0' && isdigit(c)) {
+ do {
num = num * 10 + (c - '0');
if (num > max)
return NULL; /* illegal value */
- ++strp;
- }
+ c = *++strp;
+ } while (is_digit(c));
if (num < min)
return NULL; /* illegal value */
*nump = num;
@@ -523,14 +523,13 @@ getoffset(strp, offsetp)
register const char * strp;
long * const offsetp;
{
- register int neg;
+ register int neg = 0;
if (*strp == '-') {
neg = 1;
++strp;
- } else if (isdigit(*strp) || *strp++ == '+')
- neg = 0;
- else return NULL; /* illegal offset */
+ } else if (*strp == '+')
+ ++strp;
strp = getsecs(strp, offsetp);
if (strp == NULL)
return NULL; /* illegal time */
@@ -575,7 +574,7 @@ register struct rule * const rulep;
if (*strp++ != '.')
return NULL;
strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
- } else if (isdigit(*strp)) {
+ } else if (is_digit(*strp)) {
/*
** Day of year.
*/
@@ -817,7 +816,8 @@ const int lastditch;
for (i = 0; i < sp->timecnt; ++i) {
j = sp->types[i];
if (!sp->ttis[j].tt_isdst) {
- theirstdoffset = -sp->ttis[j].tt_gmtoff;
+ theirstdoffset =
+ -sp->ttis[j].tt_gmtoff;
break;
}
}
@@ -825,7 +825,8 @@ const int lastditch;
for (i = 0; i < sp->timecnt; ++i) {
j = sp->types[i];
if (sp->ttis[j].tt_isdst) {
- theirdstoffset = -sp->ttis[j].tt_gmtoff;
+ theirdstoffset =
+ -sp->ttis[j].tt_gmtoff;
break;
}
}
@@ -1188,19 +1189,18 @@ register struct tm * const tmp;
if (tmp->tm_wday < 0)
tmp->tm_wday += DAYSPERWEEK;
y = EPOCH_YEAR;
- if (days >= 0)
- for ( ; ; ) {
- yleap = isleap(y);
- if (days < (long) year_lengths[yleap])
- break;
- ++y;
- days = days - (long) year_lengths[yleap];
- }
- else do {
- --y;
- yleap = isleap(y);
- days = days + (long) year_lengths[yleap];
- } while (days < 0);
+#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
+ while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
+ register int newy;
+
+ newy = y + days / DAYSPERNYEAR;
+ if (days < 0)
+ --newy;
+ days -= (newy - y) * DAYSPERNYEAR +
+ LEAPS_THRU_END_OF(newy - 1) -
+ LEAPS_THRU_END_OF(y - 1);
+ y = newy;
+ }
tmp->tm_year = y - TM_YEAR_BASE;
tmp->tm_yday = (int) days;
ip = mon_lengths[yleap];
@@ -1399,10 +1399,10 @@ int * const okayp;
if (sp == NULL)
return WRONG;
#endif /* defined ALL_STATE */
- for (i = 0; i < sp->typecnt; ++i) {
+ for (i = sp->typecnt - 1; i >= 0; --i) {
if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
continue;
- for (j = 0; j < sp->typecnt; ++j) {
+ for (j = sp->typecnt - 1; j >= 0; --j) {
if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
continue;
newt = t + sp->ttis[j].tt_gmtoff -
@@ -1434,7 +1434,7 @@ label:
static time_t
time1(tmp, funcp, offset)
struct tm * const tmp;
-void (* const funcp) P((const time_t*, long, struct tm*));
+void (* const funcp) P((const time_t *, long, struct tm *));
const long offset;
{
register time_t t;
@@ -1473,10 +1473,10 @@ const long offset;
if (sp == NULL)
return WRONG;
#endif /* defined ALL_STATE */
- for (samei = 0; samei < sp->typecnt; ++samei) {
+ for (samei = sp->typecnt - 1; samei >= 0; --samei) {
if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
continue;
- for (otheri = 0; otheri < sp->typecnt; ++otheri) {
+ for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) {
if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
continue;
tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h
index a7a25624e54..684547cc535 100644
--- a/lib/libc/time/private.h
+++ b/lib/libc/time/private.h
@@ -1,4 +1,4 @@
-/* $NetBSD: private.h,v 1.3 1995/03/14 18:49:49 jtc Exp $ */
+/* $NetBSD: private.h,v 1.4 1996/01/08 22:50:57 jtc Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@@ -23,7 +23,7 @@
#ifndef lint
#ifndef NOID
-static char privatehid[] = "@(#)private.h 7.33";
+static char privatehid[] = "@(#)private.h 7.35";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -54,7 +54,6 @@ static char privatehid[] = "@(#)private.h 7.33";
#include "sys/types.h" /* for time_t */
#include "stdio.h"
-#include "ctype.h"
#include "errno.h"
#include "string.h"
#include "limits.h" /* for CHAR_BIT */
@@ -74,6 +73,9 @@ static char privatehid[] = "@(#)private.h 7.33";
#endif /* !defined R_OK */
#endif /* !(HAVE_UNISTD_H - 0) */
+/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
+#define is_digit(c) ((unsigned)(c) - '0' <= 9)
+
/*
** Workarounds for compilers/systems.
*/
@@ -162,12 +164,19 @@ extern int unlink P((const char * filename));
#ifndef INT_STRLEN_MAXIMUM
/*
** 302 / 1000 is log10(2.0) rounded up.
-** Subtract one for the sign bit;
-** add one for integer division truncation;
-** add one more for a minus sign.
+** If type is signed:
+** subtract one for the sign bit;
+** add one for integer division truncation;
+** add one more for a minus sign.
+** If type is unsigned:
+** do not subtract one since there is no sign bit;
+** add one for integer division truncation;
+** do not add one more for a minus sign.
*/
#define INT_STRLEN_MAXIMUM(type) \
- ((sizeof(type) * CHAR_BIT - 1) * 302 / 1000 + 2)
+ ((((type) -1) < 0) ? \
+ ((sizeof(type) * CHAR_BIT - 1) * 302 / 1000 + 2) : \
+ ((sizeof(type) * CHAR_BIT) * 302 / 1000 + 1))
#endif /* !defined INT_STRLEN_MAXIMUM */
/*
diff --git a/lib/libc/time/scheck.c b/lib/libc/time/scheck.c
index aa6fbf6ce65..9d784b76e23 100644
--- a/lib/libc/time/scheck.c
+++ b/lib/libc/time/scheck.c
@@ -1,8 +1,8 @@
-/* $NetBSD: scheck.c,v 1.2 1995/03/10 18:12:42 jtc Exp $ */
+/* $NetBSD: scheck.c,v 1.3 1996/01/08 22:50:58 jtc Exp $ */
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)scheck.c 8.12";
+static char elsieid[] = "@(#)scheck.c 8.13";
#endif /* !defined lint */
#endif /* !defined NOID */
@@ -44,7 +44,7 @@ char * const format;
*tp++ = '*';
if (*fp == '*')
++fp;
- while (isascii(*fp) && isdigit(*fp))
+ while (is_digit(*fp))
*tp++ = *fp++;
if (*fp == 'l' || *fp == 'h')
*tp++ = *fp++;
diff --git a/lib/libc/time/tzset.3 b/lib/libc/time/tzset.3
index 04f6a9d82b7..31060140baa 100644
--- a/lib/libc/time/tzset.3
+++ b/lib/libc/time/tzset.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: tzset.3,v 1.5.2.1 1995/10/26 05:24:52 jtc Exp $
+.\" $NetBSD: tzset.3,v 1.7 1996/01/08 22:50:59 jtc Exp $
.TH TZSET 3
.SH NAME
tzset \- initialize time conversion information
@@ -231,6 +231,7 @@ UTC leap seconds are loaded from
.SH SEE ALSO
getenv(3),
ctime(3),
+strftime(3),
time(3),
tzfile(5)
-.\" @(#)newtzset.3 7.3
+.\" @(#)newtzset.3 7.4
diff --git a/lib/libc/time/zic.8 b/lib/libc/time/zic.8
index 31685ab925c..f44f2cb42db 100644
--- a/lib/libc/time/zic.8
+++ b/lib/libc/time/zic.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: zic.8,v 1.3 1995/08/22 19:28:18 jtc Exp $
+.\" $NetBSD: zic.8,v 1.4 1996/01/08 22:50:59 jtc Exp $
.TH ZIC 8
.SH NAME
zic \- time zone compiler
@@ -324,14 +324,13 @@ A link line has the form
.sp
.nf
.ti +.5i
-.if t .ta \w'Link\0\0'u +\w'LINK-FROM\0\0'u
-.if n .ta \w'Link\0\0'u +\w'US/Eastern\0\0'u
+.ta \w'Link\0\0'u +\w'Europe/Istanbul\0\0'u
Link LINK-FROM LINK-TO
.sp
For example:
.sp
.ti +.5i
-Link US/Eastern EST5EDT
+Link Europe/Istanbul Asia/Istanbul
.sp
.fi
The
@@ -407,4 +406,4 @@ the earliest transition time recorded in the compiled file is correct.
/usr/share/zoneinfo standard directory used for created files
.SH "SEE ALSO"
ctime(3), tzfile(5), zdump(8)
-.\" @(#)zic.8 7.11
+.\" @(#)zic.8 7.12
diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c
index d9e92aecdc3..ece2e3e8e62 100644
--- a/lib/libc/time/zic.c
+++ b/lib/libc/time/zic.c
@@ -1,8 +1,8 @@
-/* $NetBSD: zic.c,v 1.2 1995/03/10 18:12:44 jtc Exp $ */
+/* $NetBSD: zic.c,v 1.3 1996/01/08 22:51:01 jtc Exp $ */
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)zic.c 7.50";
+static char elsieid[] = "@(#)zic.c 7.57";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -12,6 +12,19 @@ static char elsieid[] = "@(#)zic.c 7.50";
#include "sys/stat.h" /* for umask manifest constants */
#endif /* defined unix */
+/*
+** On some ancient hosts, predicates like `isspace(C)' are defined
+** only if isascii(C) || C == EOF. Modern hosts obey the C Standard,
+** which says they are defined only if C == ((unsigned char) C) || C == EOF.
+** Neither the C Standard nor Posix require that `isascii' exist.
+** For portability, we check both ancient and modern requirements.
+** If isascii is not defined, the isascii check succeeds trivially.
+*/
+#include "ctype.h"
+#ifndef isascii
+#define isascii(x) 1
+#endif
+
struct rule {
const char * r_filename;
int r_linenum;
@@ -129,10 +142,8 @@ static int errors;
static const char * filename;
static int leapcnt;
static int linenum;
-static int max_int;
static time_t max_time;
static int max_year;
-static int min_int;
static time_t min_time;
static int min_year;
static int noise;
@@ -141,7 +152,6 @@ static int rlinenum;
static const char * progname;
static int timecnt;
static int typecnt;
-static int tt_signed;
/*
** Line codes.
@@ -569,36 +579,45 @@ const char * const tofile;
ifree(toname);
}
+#ifndef INT_MAX
+#define INT_MAX ((int) (((unsigned)~0)>>1))
+#endif /* !defined INT_MAX */
+
+#ifndef INT_MIN
+#define INT_MIN ((int) ~(((unsigned)~0)>>1))
+#endif /* !defined INT_MIN */
+
+#define TIME_T_SIGNED (((time_t) -1) < 0)
+#define TIME_T_BIT (sizeof (time_t) * CHAR_BIT)
+
+/*
+** The tz file format currently allows at most 32-bit quantities.
+** This restriction should be removed before signed 32-bit values
+** wrap around in 2038, but unfortunately this will require a
+** change to the tz file format.
+*/
+
+#define MAX_BITS_IN_FILE 32
+#define TIME_T_BITS_IN_FILE ((TIME_T_BIT < MAX_BITS_IN_FILE) ? \
+ TIME_T_BIT : MAX_BITS_IN_FILE)
+
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 (TIME_T_SIGNED) {
+ min_time = ~ (time_t) 0;
+ min_time <<= TIME_T_BITS_IN_FILE - 1;
+ max_time = ~ (time_t) 0 - min_time;
if (sflag)
min_time = 0;
+ } else {
+ min_time = 0;
+ max_time = 2 - sflag;
+ max_time <<= TIME_T_BITS_IN_FILE - 1;
+ --max_time;
}
min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year;
max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year;
-
- for (bii = 1; bii > 0; bii <<= 1)
- continue;
- min_int = bii;
- max_int = -1 - bii;
}
static int
@@ -718,7 +737,7 @@ const char * name;
while (fields[nfields] != NULL) {
static char nada;
- if (ciequal(fields[nfields], "-"))
+ if (strcmp(fields[nfields], "-") == 0)
fields[nfields] = &nada;
++nfields;
}
@@ -1033,7 +1052,7 @@ const int nfields;
return;
}
dayoff = oadd(dayoff, eitol(day - 1));
- if (dayoff < 0 && !tt_signed) {
+ if (dayoff < 0 && !TIME_T_SIGNED) {
error("time before zero");
return;
}
@@ -1156,10 +1175,10 @@ const char * const timep;
lp = byword(cp, begin_years);
if (lp != NULL) switch ((int) lp->l_value) {
case YR_MINIMUM:
- rp->r_loyear = min_int;
+ rp->r_loyear = INT_MIN;
break;
case YR_MAXIMUM:
- rp->r_loyear = max_int;
+ rp->r_loyear = INT_MAX;
break;
default: /* "cannot happen" */
(void) fprintf(stderr,
@@ -1173,10 +1192,10 @@ const char * const timep;
cp = hiyearp;
if ((lp = byword(cp, end_years)) != NULL) switch ((int) lp->l_value) {
case YR_MINIMUM:
- rp->r_hiyear = min_int;
+ rp->r_hiyear = INT_MIN;
break;
case YR_MAXIMUM:
- rp->r_hiyear = max_int;
+ rp->r_hiyear = INT_MAX;
break;
case YR_ONLY:
rp->r_hiyear = rp->r_loyear;
@@ -1699,8 +1718,9 @@ const char * const type;
static int
lowerit(a)
-const int a;
+int a;
{
+ a = (unsigned char) a;
return (isascii(a) && isupper(a)) ? tolower(a) : a;
}
@@ -1724,9 +1744,10 @@ register const char * word;
return FALSE;
++word;
while (*++abbr != '\0')
- do if (*word == '\0')
- return FALSE;
- while (lowerit(*word++) != lowerit(*abbr));
+ do {
+ if (*word == '\0')
+ return FALSE;
+ } while (lowerit(*word++) != lowerit(*abbr));
return TRUE;
}
@@ -1772,7 +1793,7 @@ register char * cp;
emalloc((int) ((strlen(cp) + 1) * sizeof *array));
nsubs = 0;
for ( ; ; ) {
- while (isascii(*cp) && isspace(*cp))
+ while (isascii(*cp) && isspace((unsigned char) *cp))
++cp;
if (*cp == '\0' || *cp == '#')
break;
@@ -1785,8 +1806,8 @@ register char * cp;
++dp;
else error("Odd number of quotation marks");
} while (*cp != '\0' && *cp != '#' &&
- (!isascii(*cp) || !isspace(*cp)));
- if (isascii(*cp) && isspace(*cp))
+ (!isascii(*cp) || !isspace((unsigned char) *cp)));
+ if (isascii(*cp) && isspace((unsigned char) *cp))
++cp;
*dp = '\0';
}
@@ -1842,9 +1863,9 @@ register const int wantedy;
register long dayoff; /* with a nod to Margaret O. */
register time_t t;
- if (wantedy == min_int)
+ if (wantedy == INT_MIN)
return min_time;
- if (wantedy == max_int)
+ if (wantedy == INT_MAX)
return max_time;
dayoff = 0;
m = TM_JANUARY;
@@ -1907,7 +1928,7 @@ register const int wantedy;
(void) exit(EXIT_FAILURE);
}
}
- if (dayoff < 0 && !tt_signed)
+ if (dayoff < 0 && !TIME_T_SIGNED)
return min_time;
t = (time_t) dayoff * SECSPERDAY;
/*
@@ -1949,8 +1970,8 @@ char * const argname;
/*
** DOS drive specifier?
*/
- if (strlen(name) == 2 && isascii(name[0]) &&
- isalpha(name[0]) && name[1] == ':') {
+ if (isalpha((unsigned char) name[0]) &&
+ name[1] == ':' && name[2] != '\0') {
*cp = '/';
continue;
}