tz
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1999 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1998 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1997 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1996 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1995 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1994 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1993 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1992 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1991 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1990 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1989 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1988 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1987 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 1986 -----
- December
- November
- 8 participants
- 7497 discussions
The tz source code predates C99 and so used int, 0 and 1 for boolean,
but nowadays bool is available and makes the code clearer.
Include backwards-compatibility definitions for pre-C99 platforms,
and don't go beyond what the backwards-compatibility defintions support.
* date.c (main, reset, sametm, convert, checkfinal, iffy, netsettime):
* localtime.c (struct ttinfo, struct state, gmt_is_set)
(differ_by_repeat, tzload, typesequiv, getoffset, transtime)
(tzparse, gmtload, tzsetwall_unlocked, tzset_unlocked, gmtcheck)
(localtime_tzset, timesub, increment_overflow)
(increment_overflow32, increment_overflow_time)
(normalize_overflow, normalize_overflow32, time2sub, time2)
(time1):
* strftime.c (_fmt, _yconv, _loc):
* zdump.c (warned, errout, is_alpha, my_localtime, abbrok)
(main, hunt, show):
* zic.c (struct rule, errors, warnings, leapseen, noise)
(leap_types, ttisstds, ttisgmts, error, warning, main, dolink)
(associate, infile, gethms, inzone, inzcont, inzsub, inleap)
(rulesub, is32, writezone, doabbr, stringoffset, stringrule)
(stringzone, outzone, addtype, leapadd, yearistype, is_space)
(is_alpha, ciequal, itsabbr, mkdirs):
Use bool for boolean.
* localtime.c (tzload, tzparse):
* zic.c (stringoffset, mkdirs):
Return true for success and false for failure instead of 0 and -1.
All callers changed.
* private.h, zdump.c (TRUE, FALSE): Remove, replacing by ...
(true, false, bool): Define by <stdbool.h> if C99 or later,
by macros otherwise.
* tzfile.h: Remove mention of TRUE and FALSE from commentary.
* zic.c (addtype): Remove now-unnecessary checks that a bool is a
boolean.
---
date.c | 63 +++++++--------
localtime.c | 193 ++++++++++++++++++++++----------------------
private.h | 14 ++--
strftime.c | 26 +++---
tzfile.h | 8 +-
zdump.c | 58 +++++++-------
zic.c | 262 ++++++++++++++++++++++++++++--------------------------------
7 files changed, 304 insertions(+), 320 deletions(-)
diff --git a/date.c b/date.c
index c2a39f2..c8fab75 100644
--- a/date.c
+++ b/date.c
@@ -54,7 +54,7 @@ extern char * tzname[2];
static int retval = EXIT_SUCCESS;
-static void checkfinal(const char *, int, time_t, time_t);
+static void checkfinal(char const *, bool, time_t, time_t);
static time_t convert(const char *, int, time_t);
static void display(const char *, time_t);
static void dogmt(void);
@@ -75,12 +75,12 @@ main(const int argc, char *argv[])
register const char * value;
register const char * cp;
register int ch;
- register int dousg;
- register int aflag = 0;
- register int dflag = 0;
- register int nflag = 0;
- register int tflag = 0;
- register int rflag = 0;
+ register bool dousg;
+ register bool aflag = false;
+ register bool dflag = false;
+ register bool nflag = false;
+ register bool tflag = false;
+ register bool rflag = false;
register int minuteswest;
register int dsttime;
register double adjust;
@@ -115,7 +115,7 @@ main(const int argc, char *argv[])
_("date: error: multiple -r's used"));
usage();
}
- rflag = 1;
+ rflag = true;
errno = 0;
secs = strtoimax (optarg, &endarg, 0);
if (*endarg || optarg == endarg)
@@ -130,7 +130,7 @@ main(const int argc, char *argv[])
t = secs;
break;
case 'n': /* don't set network */
- nflag = 1;
+ nflag = true;
break;
case 'd': /* daylight saving time */
if (dflag) {
@@ -138,7 +138,7 @@ main(const int argc, char *argv[])
_("date: error: multiple -d's used"));
usage();
}
- dflag = 1;
+ dflag = true;
cp = optarg;
dsttime = atoi(cp);
if (*cp == '\0' || *nondigit(cp) != '\0')
@@ -151,7 +151,7 @@ main(const int argc, char *argv[])
_("date: error: multiple -t's used"));
usage();
}
- tflag = 1;
+ tflag = true;
cp = optarg;
minuteswest = atoi(cp);
if (*cp == '+' || *cp == '-')
@@ -166,7 +166,7 @@ main(const int argc, char *argv[])
_("date: error: multiple -a's used"));
usage();
}
- aflag = 1;
+ aflag = true;
cp = optarg;
adjust = atof(cp);
if (*cp == '+' || *cp == '-')
@@ -208,9 +208,9 @@ _("date: error: multiple values in command line\n"));
** even if time_t's range all the way back to the thirteenth
** century. Do not change the order.
*/
- t = convert(value, (dousg = TRUE), now);
+ t = convert(value, (dousg = true), now);
if (t == -1)
- t = convert(value, (dousg = FALSE), now);
+ t = convert(value, (dousg = false), now);
if (t == -1) {
/*
** Out of range values,
@@ -231,9 +231,9 @@ _("date: error: multiple values in command line\n"));
_("out of range seconds given"));
}
dogmt();
- t = convert(value, FALSE, now);
+ t = convert(value, false, now);
if (t == -1)
- t = convert(value, TRUE, now);
+ t = convert(value, true, now);
wildinput(_("time"), value,
(t == -1) ?
_("out of range value given") :
@@ -334,7 +334,7 @@ dogmt(void)
/*ARGSUSED*/
static void
-reset(const time_t newt, const int nflag)
+reset(time_t newt, bool nflag)
{
register int fid;
time_t oldt;
@@ -433,14 +433,14 @@ extern int logwtmp();
#endif /* HAVE_SETTIMEOFDAY == 1 */
#ifdef TSP_SETDATE
-static int netsettime(struct timeval);
+static bool netsettime(struct timeval);
#endif
#ifndef TSP_SETDATE
/*ARGSUSED*/
#endif /* !defined TSP_SETDATE */
static void
-reset(const time_t newt, const int nflag)
+reset(time_t newt, bool nflag)
{
register const char * username;
static struct timeval tv; /* static so tv_usec is 0 */
@@ -578,7 +578,7 @@ timeout(FILE *const fp, const char *const format, const struct tm *tmp)
free(cp);
}
-static int
+static bool
sametm(register const struct tm *const atmp,
register const struct tm *const btmp)
{
@@ -598,7 +598,7 @@ sametm(register const struct tm *const atmp,
#define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2;
static time_t
-convert(register const char * const value, const int dousg, const time_t t)
+convert(char const *value, bool dousg, time_t t)
{
register const char * cp;
register const char * dotp;
@@ -705,10 +705,7 @@ convert(register const char * const value, const int dousg, const time_t t)
*/
static void
-checkfinal(const char * const value,
- const int didusg,
- const time_t t,
- const time_t oldnow)
+checkfinal(char const *value, bool didusg, time_t t, time_t oldnow)
{
time_t othert;
struct tm tm, *tmp;
@@ -776,7 +773,7 @@ iffy(const time_t thist, const time_t thatt,
const char * const value, const char * const reason)
{
struct tm *tmp;
- int dst;
+ bool dst;
fprintf(stderr, _("date: warning: ambiguous time \"%s\", %s.\n"),
value, reason);
@@ -788,7 +785,7 @@ iffy(const time_t thist, const time_t thatt,
%M\
%Y.%S\n"), tmp);
tmp = localtime(&thist);
- dst = tmp ? tmp->tm_isdst : 0;
+ dst = tmp && tmp->tm_isdst;
timeout(stderr, _("to get %c"), tmp);
fprintf(stderr, _(" (%s). Use\n"),
dst ? _("summer time") : _("standard time"));
@@ -797,7 +794,7 @@ iffy(const time_t thist, const time_t thatt,
%M\
%Y.%S\n"), tmp);
tmp = localtime(&thatt);
- dst = tmp ? tmp->tm_isdst : 0;
+ dst = tmp && tmp->tm_isdst;
timeout(stderr, _("to get %c"), tmp);
fprintf(stderr, _(" (%s).\n"),
dst ? _("summer time") : _("standard time"));
@@ -815,9 +812,9 @@ iffy(const time_t thist, const time_t thatt,
* If the timedaemon is in the master state, it performs the
* correction on all slaves. If it is in the slave state, it
* notifies the master that a correction is needed.
- * Returns 1 on success, 0 on failure.
+ * Return true on success.
*/
-static int
+static bool
netsettime(struct timeval ntv)
{
int s, length, port, timed_ack, found, err, waittime;
@@ -832,7 +829,7 @@ netsettime(struct timeval ntv)
if (! sp) {
fputs(_("udp/timed: unknown service\n"), stderr);
retval = 2;
- return (0);
+ return false;
}
dest.sin_port = sp->s_port;
dest.sin_family = AF_INET;
@@ -915,7 +912,7 @@ loop:
case TSP_DATEACK:
lose(s);
- return (1);
+ return true;
default:
fprintf(stderr,
@@ -931,6 +928,6 @@ loop:
bad:
lose(s);
retval = 2;
- return (0);
+ return false;
}
#endif /* defined TSP_SETDATE */
diff --git a/localtime.c b/localtime.c
index 58b3e6e..98faacd 100644
--- a/localtime.c
+++ b/localtime.c
@@ -92,10 +92,10 @@ static const char gmt[] = "GMT";
struct ttinfo { /* time type information */
int_fast32_t tt_gmtoff; /* UT offset in seconds */
- int tt_isdst; /* used to set tm_isdst */
+ bool tt_isdst; /* used to set tm_isdst */
int tt_abbrind; /* abbreviation list index */
- int tt_ttisstd; /* TRUE if transition is std time */
- int tt_ttisgmt; /* TRUE if transition is UT */
+ bool tt_ttisstd; /* transition is std time */
+ bool tt_ttisgmt; /* transition is UT */
};
struct lsinfo { /* leap second information */
@@ -117,8 +117,8 @@ struct state {
int timecnt;
int typecnt;
int charcnt;
- int goback;
- int goahead;
+ bool goback;
+ bool goahead;
time_t ats[TZ_MAX_TIMES];
unsigned char types[TZ_MAX_TIMES];
struct ttinfo ttis[TZ_MAX_TYPES];
@@ -141,13 +141,13 @@ struct rule {
#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d = month, week, day of week */
static struct tm *gmtsub(time_t const *, int_fast32_t, struct tm *);
-static int increment_overflow(int *, int);
-static int increment_overflow_time(time_t *, int_fast32_t);
-static int normalize_overflow32(int_fast32_t *, int *, int);
+static bool increment_overflow(int *, int);
+static bool increment_overflow_time(time_t *, int_fast32_t);
+static bool normalize_overflow32(int_fast32_t *, int *, int);
static struct tm *timesub(time_t const *, int_fast32_t, struct state const *,
struct tm *);
-static int typesequiv(struct state const *, int, int);
-static int tzparse(char const *, struct state *, int);
+static bool typesequiv(struct state const *, int, int);
+static bool tzparse(char const *, struct state *, bool);
#ifdef ALL_STATE
static struct state * lclptr;
@@ -167,7 +167,7 @@ static struct state gmtmem;
static char lcl_TZname[TZ_STRLEN_MAX + 1];
static int VOLATILE lcl_is_set;
-static int VOLATILE gmt_is_set;
+static bool VOLATILE gmt_is_set;
char * tzname[2] = {
(char *) wildabbr,
@@ -281,7 +281,7 @@ settzname(void)
}
}
-static int
+static bool
differ_by_repeat(const time_t t1, const time_t t0)
{
if (TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
@@ -289,9 +289,9 @@ differ_by_repeat(const time_t t1, const time_t t0)
return t1 - t0 == SECSPERREPEAT;
}
-static int
+static bool
tzload(register const char *name, register struct state *const sp,
- register const int doextend)
+ bool doextend)
{
register const char * p;
register int i;
@@ -322,12 +322,12 @@ tzload(register const char *name, register struct state *const sp,
};
register char *fullname;
register u_t *up;
- register int doaccess;
+ register bool doaccess;
register union local_storage *lsp;
#ifdef ALL_STATE
lsp = malloc(sizeof *lsp);
if (!lsp)
- return -1;
+ return false;
#else /* !defined ALL_STATE */
union local_storage ls;
lsp = &ls;
@@ -335,7 +335,7 @@ tzload(register const char *name, register struct state *const sp,
fullname = lsp->fullname;
up = &lsp->u.u;
- sp->goback = sp->goahead = FALSE;
+ sp->goback = sp->goahead = false;
if (! name) {
name = TZDEFAULT;
@@ -355,7 +355,7 @@ tzload(register const char *name, register struct state *const sp,
strcat(fullname, name);
/* Set doaccess if '.' (as in "../") shows up in name. */
if (strchr(name, '.'))
- doaccess = TRUE;
+ doaccess = true;
name = fullname;
}
if (doaccess && access(name, R_OK) != 0)
@@ -475,12 +475,11 @@ tzload(register const char *name, register struct state *const sp,
ttisp = &sp->ttis[i];
if (ttisstdcnt == 0)
- ttisp->tt_ttisstd = FALSE;
+ ttisp->tt_ttisstd = false;
else {
- ttisp->tt_ttisstd = *p++;
- if (ttisp->tt_ttisstd != TRUE &&
- ttisp->tt_ttisstd != FALSE)
+ if (*p != true && *p != false)
goto oops;
+ ttisp->tt_ttisstd = *p++;
}
}
for (i = 0; i < sp->typecnt; ++i) {
@@ -488,12 +487,11 @@ tzload(register const char *name, register struct state *const sp,
ttisp = &sp->ttis[i];
if (ttisgmtcnt == 0)
- ttisp->tt_ttisgmt = FALSE;
+ ttisp->tt_ttisgmt = false;
else {
- ttisp->tt_ttisgmt = *p++;
- if (ttisp->tt_ttisgmt != TRUE &&
- ttisp->tt_ttisgmt != FALSE)
+ if (*p != true && *p != false)
goto oops;
+ ttisp->tt_ttisgmt = *p++;
}
}
/*
@@ -514,12 +512,11 @@ tzload(register const char *name, register struct state *const sp,
up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
sp->typecnt + 2 <= TZ_MAX_TYPES) {
struct state *ts = &lsp->u.st;
- register int result;
up->buf[nread - 1] = '\0';
- result = tzparse(&up->buf[1], ts, FALSE);
- if (result == 0 && ts->typecnt == 2 &&
- sp->charcnt + ts->charcnt <= TZ_MAX_CHARS) {
+ if (tzparse(&up->buf[1], ts, false)
+ && ts->typecnt == 2
+ && sp->charcnt + ts->charcnt <= TZ_MAX_CHARS) {
for (i = 0; i < 2; ++i)
ts->ttis[i].tt_abbrind +=
sp->charcnt;
@@ -549,7 +546,7 @@ tzload(register const char *name, register struct state *const sp,
for (i = 1; i < sp->timecnt; ++i)
if (typesequiv(sp, sp->types[i], sp->types[0]) &&
differ_by_repeat(sp->ats[i], sp->ats[0])) {
- sp->goback = TRUE;
+ sp->goback = true;
break;
}
for (i = sp->timecnt - 2; i >= 0; --i)
@@ -557,7 +554,7 @@ tzload(register const char *name, register struct state *const sp,
sp->types[i]) &&
differ_by_repeat(sp->ats[sp->timecnt - 1],
sp->ats[i])) {
- sp->goahead = TRUE;
+ sp->goahead = true;
break;
}
}
@@ -598,23 +595,23 @@ tzload(register const char *name, register struct state *const sp,
#ifdef ALL_STATE
free(up);
#endif /* defined ALL_STATE */
- return 0;
+ return true;
oops:
#ifdef ALL_STATE
free(up);
#endif /* defined ALL_STATE */
- return -1;
+ return false;
}
-static int
+static bool
typesequiv(const struct state *const sp, const int a, const int b)
{
- register int result;
+ register bool result;
if (sp == NULL ||
a < 0 || a >= sp->typecnt ||
b < 0 || b >= sp->typecnt)
- result = FALSE;
+ result = false;
else {
register const struct ttinfo * ap = &sp->ttis[a];
register const struct ttinfo * bp = &sp->ttis[b];
@@ -752,10 +749,10 @@ getsecs(register const char *strp, int_fast32_t *const secsp)
static const char *
getoffset(register const char *strp, int_fast32_t *const offsetp)
{
- register int neg = 0;
+ register bool neg = false;
if (*strp == '-') {
- neg = 1;
+ neg = true;
++strp;
} else if (*strp == '+')
++strp;
@@ -829,7 +826,7 @@ static int_fast32_t ATTRIBUTE_PURE
transtime(const int year, register const struct rule *const rulep,
const int_fast32_t offset)
{
- register int leapyear;
+ register bool leapyear;
register int_fast32_t value;
register int i;
int d, m1, yy0, yy1, yy2, dow;
@@ -916,9 +913,9 @@ transtime(const int year, register const struct rule *const rulep,
** appropriate.
*/
-static int
+static bool
tzparse(const char *name, register struct state *const sp,
- const int lastditch)
+ bool lastditch)
{
const char * stdname;
const char * dstname;
@@ -927,7 +924,7 @@ tzparse(const char *name, register struct state *const sp,
int_fast32_t stdoffset;
int_fast32_t dstoffset;
register char * cp;
- register int load_result;
+ register bool load_ok;
static struct ttinfo zttinfo;
stdname = name;
@@ -943,7 +940,7 @@ tzparse(const char *name, register struct state *const sp,
stdname = name;
name = getqzname(name, '>');
if (*name != '>')
- return (-1);
+ return false;
stdlen = name - stdname;
name++;
} else {
@@ -951,20 +948,20 @@ tzparse(const char *name, register struct state *const sp,
stdlen = name - stdname;
}
if (*name == '\0')
- return -1;
+ return false;
name = getoffset(name, &stdoffset);
if (name == NULL)
- return -1;
+ return false;
}
- load_result = tzload(TZDEFRULES, sp, FALSE);
- if (load_result != 0)
+ load_ok = tzload(TZDEFRULES, sp, false);
+ if (!load_ok)
sp->leapcnt = 0; /* so, we're off a little */
if (*name != '\0') {
if (*name == '<') {
dstname = ++name;
name = getqzname(name, '>');
if (*name != '>')
- return -1;
+ return false;
dstlen = name - dstname;
name++;
} else {
@@ -975,9 +972,9 @@ tzparse(const char *name, register struct state *const sp,
if (*name != '\0' && *name != ',' && *name != ';') {
name = getoffset(name, &dstoffset);
if (name == NULL)
- return -1;
+ return false;
} else dstoffset = stdoffset - SECSPERHOUR;
- if (*name == '\0' && load_result != 0)
+ if (*name == '\0' && !load_ok)
name = TZDEFRULESTRING;
if (*name == ',' || *name == ';') {
struct rule start;
@@ -989,23 +986,23 @@ tzparse(const char *name, register struct state *const sp,
++name;
if ((name = getrule(name, &start)) == NULL)
- return -1;
+ return false;
if (*name++ != ',')
- return -1;
+ return false;
if ((name = getrule(name, &end)) == NULL)
- return -1;
+ return false;
if (*name != '\0')
- return -1;
+ return false;
sp->typecnt = 2; /* standard time and DST */
/*
** Two transitions per year, from EPOCH_YEAR forward.
*/
sp->ttis[0] = sp->ttis[1] = zttinfo;
sp->ttis[0].tt_gmtoff = -dstoffset;
- sp->ttis[0].tt_isdst = 1;
+ sp->ttis[0].tt_isdst = true;
sp->ttis[0].tt_abbrind = stdlen + 1;
sp->ttis[1].tt_gmtoff = -stdoffset;
- sp->ttis[1].tt_isdst = 0;
+ sp->ttis[1].tt_isdst = false;
sp->ttis[1].tt_abbrind = 0;
sp->defaulttype = 0;
timecnt = 0;
@@ -1018,7 +1015,7 @@ tzparse(const char *name, register struct state *const sp,
int_fast32_t
yearsecs = (year_lengths[isleap(year)]
* SECSPERDAY);
- int reversed = endtime < starttime;
+ bool reversed = endtime < starttime;
if (reversed) {
int_fast32_t swap = starttime;
starttime = endtime;
@@ -1053,12 +1050,12 @@ tzparse(const char *name, register struct state *const sp,
register int_fast32_t theirstdoffset;
register int_fast32_t theirdstoffset;
register int_fast32_t theiroffset;
- register int isdst;
+ register bool isdst;
register int i;
register int j;
if (*name != '\0')
- return -1;
+ return false;
/*
** Initial values of theirstdoffset and theirdstoffset.
*/
@@ -1083,7 +1080,7 @@ tzparse(const char *name, register struct state *const sp,
/*
** Initially we're assumed to be in standard time.
*/
- isdst = FALSE;
+ isdst = false;
theiroffset = theirstdoffset;
/*
** Now juggle transition times and types
@@ -1127,10 +1124,10 @@ tzparse(const char *name, register struct state *const sp,
*/
sp->ttis[0] = sp->ttis[1] = zttinfo;
sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = FALSE;
+ sp->ttis[0].tt_isdst = false;
sp->ttis[0].tt_abbrind = 0;
sp->ttis[1].tt_gmtoff = -dstoffset;
- sp->ttis[1].tt_isdst = TRUE;
+ sp->ttis[1].tt_isdst = true;
sp->ttis[1].tt_abbrind = stdlen + 1;
sp->typecnt = 2;
sp->defaulttype = 0;
@@ -1141,7 +1138,7 @@ tzparse(const char *name, register struct state *const sp,
sp->timecnt = 0;
sp->ttis[0] = zttinfo;
sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = 0;
+ sp->ttis[0].tt_isdst = false;
sp->ttis[0].tt_abbrind = 0;
sp->defaulttype = 0;
}
@@ -1149,7 +1146,7 @@ tzparse(const char *name, register struct state *const sp,
if (dstlen != 0)
sp->charcnt += dstlen + 1;
if ((size_t) sp->charcnt > sizeof sp->chars)
- return -1;
+ return false;
cp = sp->chars;
strncpy(cp, stdname, stdlen);
cp += stdlen;
@@ -1158,14 +1155,14 @@ tzparse(const char *name, register struct state *const sp,
strncpy(cp, dstname, dstlen);
*(cp + dstlen) = '\0';
}
- return 0;
+ return true;
}
static void
gmtload(struct state *const sp)
{
- if (tzload(gmt, sp, TRUE) != 0)
- tzparse(gmt, sp, TRUE);
+ if (! tzload(gmt, sp, true))
+ tzparse(gmt, sp, true);
}
static void
@@ -1177,7 +1174,7 @@ tzsetwall_unlocked(void)
if (! lclptr)
lclptr = malloc(sizeof *lclptr);
#endif
- if (lclptr && tzload(NULL, lclptr, TRUE) != 0)
+ if (lclptr && ! tzload(NULL, lclptr, true))
gmtload(lclptr);
settzname();
lcl_is_set = -1;
@@ -1197,7 +1194,7 @@ tzsetwall(void)
static void
tzset_unlocked(void)
{
- int shortname;
+ bool shortname;
register char const *name = getenv("TZ");
if (!name) {
@@ -1221,12 +1218,12 @@ tzset_unlocked(void)
lclptr->leapcnt = 0; /* so, we're off a little */
lclptr->timecnt = 0;
lclptr->typecnt = 0;
- lclptr->ttis[0].tt_isdst = 0;
+ lclptr->ttis[0].tt_isdst = false;
lclptr->ttis[0].tt_gmtoff = 0;
lclptr->ttis[0].tt_abbrind = 0;
strcpy(lclptr->chars, gmt);
- } else if (tzload(name, lclptr, TRUE) != 0)
- if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
+ } else if (! tzload(name, lclptr, true))
+ if (name[0] == ':' || ! tzparse(name, lclptr, false))
gmtload(lclptr);
}
settzname();
@@ -1252,7 +1249,7 @@ gmtcheck(void)
#endif
if (gmtptr)
gmtload(gmtptr);
- gmt_is_set = TRUE;
+ gmt_is_set = true;
}
/*
@@ -1342,7 +1339,7 @@ localsub(const time_t *const timep, const int_fast32_t offset,
}
static struct tm *
-localtime_tzset(time_t const *timep, struct tm *tmp, int skip_tzset)
+localtime_tzset(time_t const *timep, struct tm *tmp, bool skip_tzset)
{
int err = lock();
if (err) {
@@ -1461,11 +1458,11 @@ timesub(const time_t *const timep, const int_fast32_t offset,
int y;
register const int * ip;
register int_fast64_t corr;
- register int hit;
+ register bool hit;
register int i;
corr = 0;
- hit = 0;
+ hit = false;
i = (sp == NULL) ? 0 : sp->leapcnt;
while (--i >= 0) {
lp = &sp->lsis[i];
@@ -1614,7 +1611,7 @@ ctime_r(const time_t *const timep, char *buf)
** Normalize logic courtesy Paul Eggert.
*/
-static int
+static bool
increment_overflow(int *const ip, int j)
{
register int const i = *ip;
@@ -1626,23 +1623,23 @@ increment_overflow(int *const ip, int j)
** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
*/
if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
- return TRUE;
+ return true;
*ip += j;
- return FALSE;
+ return false;
}
-static int
+static bool
increment_overflow32(int_fast32_t *const lp, int const m)
{
register int_fast32_t const l = *lp;
if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l))
- return TRUE;
+ return true;
*lp += m;
- return FALSE;
+ return false;
}
-static int
+static bool
increment_overflow_time(time_t *tp, int_fast32_t j)
{
/*
@@ -1653,12 +1650,12 @@ increment_overflow_time(time_t *tp, int_fast32_t j)
if (! (j < 0
? (TYPE_SIGNED(time_t) ? time_t_min - j <= *tp : -1 - j < *tp)
: *tp <= time_t_max - j))
- return TRUE;
+ return true;
*tp += j;
- return FALSE;
+ return false;
}
-static int
+static bool
normalize_overflow(int *const tensptr, int *const unitsptr, const int base)
{
register int tensdelta;
@@ -1670,7 +1667,7 @@ normalize_overflow(int *const tensptr, int *const unitsptr, const int base)
return increment_overflow(tensptr, tensdelta);
}
-static int
+static bool
normalize_overflow32(int_fast32_t *const tensptr, int *const unitsptr,
const int base)
{
@@ -1703,8 +1700,8 @@ static time_t
time2sub(struct tm *const tmp,
struct tm *(*const funcp)(const time_t *, int_fast32_t, struct tm *),
const int_fast32_t offset,
- int *const okayp,
- const int do_norm_secs)
+ bool *okayp,
+ bool do_norm_secs)
{
register const struct state * sp;
register int dir;
@@ -1718,7 +1715,7 @@ time2sub(struct tm *const tmp,
time_t t;
struct tm yourtm, mytm;
- *okayp = FALSE;
+ *okayp = false;
yourtm = *tmp;
if (do_norm_secs) {
if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
@@ -1871,7 +1868,7 @@ label:
return WRONG;
t = newt;
if ((*funcp)(&t, offset, tmp))
- *okayp = TRUE;
+ *okayp = true;
return t;
}
@@ -1879,7 +1876,7 @@ static time_t
time2(struct tm * const tmp,
struct tm * (*const funcp)(const time_t *, int_fast32_t, struct tm *),
const int_fast32_t offset,
- int *const okayp)
+ bool *okayp)
{
time_t t;
@@ -1888,8 +1885,8 @@ time2(struct tm * const tmp,
** (in case tm_sec contains a value associated with a leap second).
** If that fails, try with normalization of seconds.
*/
- t = time2sub(tmp, funcp, offset, okayp, FALSE);
- return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE);
+ t = time2sub(tmp, funcp, offset, okayp, false);
+ return *okayp ? t : time2sub(tmp, funcp, offset, okayp, true);
}
static time_t
@@ -1905,7 +1902,7 @@ time1(struct tm *const tmp,
register int nseen;
char seen[TZ_MAX_TYPES];
unsigned char types[TZ_MAX_TYPES];
- int okay;
+ bool okay;
if (tmp == NULL) {
errno = EINVAL;
@@ -1935,11 +1932,11 @@ time1(struct tm *const tmp,
if (sp == NULL)
return WRONG;
for (i = 0; i < sp->typecnt; ++i)
- seen[i] = FALSE;
+ seen[i] = false;
nseen = 0;
for (i = sp->timecnt - 1; i >= 0; --i)
if (!seen[sp->types[i]]) {
- seen[sp->types[i]] = TRUE;
+ seen[sp->types[i]] = true;
types[nseen++] = sp->types[i];
}
for (sameind = 0; sameind < nseen; ++sameind) {
diff --git a/private.h b/private.h
index 2389e37..529b1dc 100644
--- a/private.h
+++ b/private.h
@@ -365,13 +365,13 @@ const char * scheck(const char * string, const char * format);
** Finally, some convenience items.
*/
-#ifndef TRUE
-#define TRUE 1
-#endif /* !defined TRUE */
-
-#ifndef FALSE
-#define FALSE 0
-#endif /* !defined FALSE */
+#if __STDC_VERSION__ < 199901
+# define true 1
+# define false 0
+# define bool int
+#else
+# include <stdbool.h>
+#endif
#ifndef TYPE_BIT
#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
diff --git a/strftime.c b/strftime.c
index 259c90a..8f75499 100644
--- a/strftime.c
+++ b/strftime.c
@@ -101,7 +101,7 @@ static char * _add(const char *, char *, const char *);
static char * _conv(int, const char *, char *, const char *);
static char * _fmt(const char *, const struct tm *, char *, const char *,
int *);
-static char * _yconv(int, int, int, int, char *, const char *);
+static char * _yconv(int, int, bool, bool, char *, char const *);
extern char * tzname[];
@@ -193,8 +193,8 @@ label:
** something completely different.
** (ado, 1993-05-24)
*/
- pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 0,
- pt, ptlim);
+ pt = _yconv(t->tm_year, TM_YEAR_BASE,
+ true, false, pt, ptlim);
continue;
case 'c':
{
@@ -422,9 +422,11 @@ label:
pt, ptlim);
else if (*format == 'g') {
*warnp = IN_ALL;
- pt = _yconv(year, base, 0, 1,
+ pt = _yconv(year, base,
+ false, true,
pt, ptlim);
- } else pt = _yconv(year, base, 1, 1,
+ } else pt = _yconv(year, base,
+ true, true,
pt, ptlim);
}
continue;
@@ -462,11 +464,13 @@ label:
continue;
case 'y':
*warnp = IN_ALL;
- pt = _yconv(t->tm_year, TM_YEAR_BASE, 0, 1,
+ pt = _yconv(t->tm_year, TM_YEAR_BASE,
+ false, true,
pt, ptlim);
continue;
case 'Y':
- pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 1,
+ pt = _yconv(t->tm_year, TM_YEAR_BASE,
+ true, true,
pt, ptlim);
continue;
case 'Z':
@@ -585,7 +589,7 @@ _add(const char *str, char *pt, const char *const ptlim)
*/
static char *
-_yconv(const int a, const int b, const int convert_top, const int convert_yy,
+_yconv(int a, int b, bool convert_top, bool convert_yy,
char *pt, const char *const ptlim)
{
register int lead;
@@ -621,7 +625,7 @@ _loc(void)
static char * locale_buf;
int fd;
- int oldsun; /* "...ain't got nothin' to do..." */
+ bool oldsun; /* "...ain't got nothin' to do..." */
char * lbuf;
char * name;
char * p;
@@ -659,14 +663,14 @@ _loc(void)
if (sizeof filename <
((sizeof locale_home) + namesize + (sizeof lc_time)))
goto no_locale;
- oldsun = 0;
+ oldsun = false;
sprintf(filename, "%s/%s/%s", locale_home, name, lc_time);
fd = open(filename, O_RDONLY);
if (fd < 0) {
/*
** Old Sun systems have a different naming and data convention.
*/
- oldsun = 1;
+ oldsun = true;
sprintf(filename, "%s/%s/%s", locale_home,
lc_time, name);
fd = open(filename, O_RDONLY);
diff --git a/tzfile.h b/tzfile.h
index 150f956..ebecd68 100644
--- a/tzfile.h
+++ b/tzfile.h
@@ -62,13 +62,13 @@ struct tzhead {
** tzh_leapcnt repetitions of
** one (char [4]) coded leap second transition times
** one (char [4]) total correction after above
-** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
-** time is standard time, if FALSE,
+** tzh_ttisstdcnt (char)s indexed by type; if 1, transition
+** time is standard time, if 0,
** transition time is wall clock time
** if absent, transition times are
** assumed to be wall clock time
-** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
-** time is UT, if FALSE,
+** tzh_ttisgmtcnt (char)s indexed by type; if 1, transition
+** time is UT, if 0,
** transition time is local time
** if absent, transition times are
** assumed to be local time
diff --git a/zdump.c b/zdump.c
index 070ad3c..f476621 100644
--- a/zdump.c
+++ b/zdump.c
@@ -89,13 +89,13 @@ typedef long intmax_t;
#define MAX_STRING_LENGTH 1024
#endif /* !defined MAX_STRING_LENGTH */
-#ifndef TRUE
-#define TRUE 1
-#endif /* !defined TRUE */
-
-#ifndef FALSE
-#define FALSE 0
-#endif /* !defined FALSE */
+#if __STDC_VERSION__ < 199901
+# define true 1
+# define false 0
+# define bool int
+#else
+# include <stdbool.h>
+#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
@@ -209,24 +209,24 @@ static time_t const absolute_max_time =
: -1);
static size_t longest;
static char * progname;
-static int warned;
-static int errout;
+static bool warned;
+static bool errout;
static char *abbr(struct tm *);
static intmax_t delta(struct tm *, struct tm *) ATTRIBUTE_PURE;
static void dumptime(struct tm const *);
static time_t hunt(char *, time_t, time_t);
-static void show(char *, time_t, int);
+static void show(char *, time_t, bool);
static const char *tformat(void);
static time_t yeartot(intmax_t) ATTRIBUTE_PURE;
/* Is A an alphabetic character in the C locale? */
-static int
+static bool
is_alpha(char a)
{
switch (a) {
default:
- return 0;
+ return false;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
@@ -235,7 +235,7 @@ is_alpha(char a)
case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
case 'v': case 'w': case 'x': case 'y': case 'z':
- return 1;
+ return true;
}
}
@@ -269,7 +269,7 @@ my_localtime(time_t *tp)
fprintf(stderr, " -> ");
fprintf(stderr, tformat(), t);
fprintf(stderr, "\n");
- errout = TRUE;
+ errout = true;
}
}
return tmp;
@@ -308,7 +308,7 @@ abbrok(const char *const abbrp, const char *const zone)
fprintf(stderr,
_("%s: warning: zone \"%s\" abbreviation \"%s\" %s\n"),
progname, zone, abbrp, wp);
- warned = errout = TRUE;
+ warned = errout = true;
}
static void
@@ -342,8 +342,8 @@ int
main(int argc, char *argv[])
{
register int i;
- register int vflag;
- register int Vflag;
+ register bool vflag;
+ register bool Vflag;
register char * cutarg;
register char * cuttimes;
register time_t cutlotime;
@@ -374,14 +374,14 @@ main(int argc, char *argv[])
} else if (strcmp(argv[i], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
}
- vflag = Vflag = 0;
+ vflag = Vflag = false;
cutarg = cuttimes = NULL;
for (;;)
switch (getopt(argc, argv, "c:t:vV")) {
case 'c': cutarg = optarg; break;
case 't': cuttimes = optarg; break;
- case 'v': vflag = 1; break;
- case 'V': Vflag = 1; break;
+ case 'v': vflag = true; break;
+ case 'V': Vflag = true; break;
case -1:
if (! (optind == argc - 1 && strcmp(argv[optind], "=") == 0))
goto arg_processing_done;
@@ -477,15 +477,15 @@ main(int argc, char *argv[])
strcpy(&fakeenv[0][3], argv[i]);
if (! (vflag | Vflag)) {
- show(argv[i], now, FALSE);
+ show(argv[i], now, false);
continue;
}
- warned = FALSE;
+ warned = false;
t = absolute_min_time;
if (!Vflag) {
- show(argv[i], t, TRUE);
+ show(argv[i], t, true);
t += SECSPERDAY;
- show(argv[i], t, TRUE);
+ show(argv[i], t, true);
}
if (t < cutlotime)
t = cutlotime;
@@ -523,9 +523,9 @@ main(int argc, char *argv[])
if (!Vflag) {
t = absolute_max_time;
t -= SECSPERDAY;
- show(argv[i], t, TRUE);
+ show(argv[i], t, true);
t += SECSPERDAY;
- show(argv[i], t, TRUE);
+ show(argv[i], t, true);
}
}
close_file(stdout, NULL);
@@ -614,8 +614,8 @@ hunt(char *name, time_t lot, time_t hit)
lotmp = tmp;
} else hit = t;
}
- show(name, lot, TRUE);
- show(name, hit, TRUE);
+ show(name, lot, true);
+ show(name, hit, true);
return hit;
}
@@ -645,7 +645,7 @@ delta(struct tm * newp, struct tm *oldp)
}
static void
-show(char *zone, time_t t, int v)
+show(char *zone, time_t t, bool v)
{
register struct tm * tmp;
diff --git a/zic.c b/zic.c
index d230663..73ae17d 100644
--- a/zic.c
+++ b/zic.c
@@ -41,8 +41,8 @@ struct rule {
zic_t r_loyear; /* for example, 1986 */
zic_t r_hiyear; /* for example, 1986 */
const char * r_yrtype;
- int r_lowasnum;
- int r_hiwasnum;
+ bool r_lowasnum;
+ bool r_hiwasnum;
int r_month; /* 0..11 */
@@ -51,10 +51,10 @@ struct rule {
int r_wday;
zic_t r_tod; /* time from midnight */
- int r_todisstd; /* above is standard time if TRUE */
- /* or wall clock time if FALSE */
- int r_todisgmt; /* above is GMT if TRUE */
- /* or local time if FALSE */
+ bool r_todisstd; /* above is standard time if 1 */
+ /* or wall clock time if 0 */
+ bool r_todisgmt; /* above is GMT if 1 */
+ /* or local time if 0 */
zic_t r_stdoff; /* offset from standard time */
const char * r_abbrvar; /* variable part of abbreviation */
@@ -102,26 +102,25 @@ extern int optind;
#endif
static void addtt(zic_t starttime, int type);
-static int addtype(zic_t gmtoff, const char * abbr, int isdst,
- int ttisstd, int ttisgmt);
-static void leapadd(zic_t t, int positive, int rolling, int count);
+static int addtype(zic_t, char const *, bool, bool, bool);
+static void leapadd(zic_t, bool, int, int);
static void adjleap(void);
static void associate(void);
static void dolink(const char * fromfield, const char * tofield);
static char ** getfields(char * buf);
static zic_t gethms(const char * string, const char * errstring,
- int signable);
+ bool);
static void infile(const char * filename);
static void inleap(char ** fields, int nfields);
static void inlink(char ** fields, int nfields);
static void inrule(char ** fields, int nfields);
static int inzcont(char ** fields, int nfields);
static int inzone(char ** fields, int nfields);
-static int inzsub(char ** fields, int nfields, int iscont);
+static bool inzsub(char **, int, bool);
static int itsdir(const char * name);
static int is_alpha(char a);
static char lowerit(char);
-static int mkdirs(char * filename);
+static bool mkdirs(char *);
static void newabbr(const char * abbr);
static zic_t oadd(zic_t t1, zic_t t2);
static void outzone(const struct zone * zp, int ntzones);
@@ -134,11 +133,11 @@ static zic_t tadd(zic_t t1, zic_t t2);
static int yearistype(int year, const char * type);
static int charcnt;
-static int errors;
-static int warnings;
+static bool errors;
+static bool warnings;
static const char * filename;
static int leapcnt;
-static int leapseen;
+static bool leapseen;
static zic_t leapminyear;
static zic_t leapmaxyear;
static int linenum;
@@ -146,7 +145,7 @@ static int max_abbrvar_len;
static int max_format_len;
static zic_t max_year;
static zic_t min_year;
-static int noise;
+static bool noise;
static const char * rfilename;
static int rlinenum;
static const char * progname;
@@ -322,8 +321,8 @@ static struct lookup const end_years[] = {
};
static struct lookup const leap_types[] = {
- { "Rolling", TRUE },
- { "Stationary", FALSE },
+ { "Rolling", true },
+ { "Stationary", false },
{ NULL, 0 }
};
@@ -343,8 +342,8 @@ static struct attype {
static zic_t gmtoffs[TZ_MAX_TYPES];
static char isdsts[TZ_MAX_TYPES];
static unsigned char abbrinds[TZ_MAX_TYPES];
-static char ttisstds[TZ_MAX_TYPES];
-static char ttisgmts[TZ_MAX_TYPES];
+static bool ttisstds[TZ_MAX_TYPES];
+static bool ttisgmts[TZ_MAX_TYPES];
static char chars[TZ_MAX_CHARS];
static zic_t trans[TZ_MAX_LEAPS];
static zic_t corr[TZ_MAX_LEAPS];
@@ -439,7 +438,7 @@ error(const char *const string, ...)
va_start(args, string);
verror(string, args);
va_end(args);
- errors = 1;
+ errors = true;
}
static void ATTRIBUTE_FORMAT((printf, 1, 2))
@@ -450,7 +449,7 @@ warning(const char *const string, ...)
va_start(args, string);
verror(string, args);
va_end(args);
- warnings = 1;
+ warnings = true;
}
static void
@@ -573,7 +572,7 @@ _("%s: More than one -L option specified\n"),
}
break;
case 'v':
- noise = TRUE;
+ noise = true;
break;
case 's':
warning(_("-s ignored\n"));
@@ -725,7 +724,7 @@ dolink(const char *const fromfield, const char *const tofield)
if (link(fromname, toname) != 0) {
int result;
- if (mkdirs(toname) != 0)
+ if (! mkdirs(toname))
exit(EXIT_FAILURE);
result = link(fromname, toname);
@@ -914,7 +913,7 @@ associate(void)
*/
eat(zp->z_filename, zp->z_linenum);
zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
- TRUE);
+ true);
/*
** Note, though, that if there's no rule,
** a '%s' in the format is a bad thing.
@@ -935,7 +934,7 @@ infile(const char *name)
register char * cp;
register const struct lookup * lp;
register int nfields;
- register int wantcont;
+ register bool wantcont;
register int num;
char buf[BUFSIZ];
@@ -949,7 +948,7 @@ infile(const char *name)
progname, name, e);
exit(EXIT_FAILURE);
}
- wantcont = FALSE;
+ wantcont = false;
for (num = 1; ; ++num) {
eat(name, num);
if (fgets(buf, sizeof buf, fp) != buf)
@@ -980,14 +979,14 @@ infile(const char *name)
else switch ((int) (lp->l_value)) {
case LC_RULE:
inrule(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;
break;
case LC_ZONE:
wantcont = inzone(fields, nfields);
break;
case LC_LINK:
inlink(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;
break;
case LC_LEAP:
if (name != leapsec)
@@ -995,7 +994,7 @@ infile(const char *name)
_("%s: Leap line in non leap seconds file %s\n"),
progname, name);
else inleap(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;
break;
default: /* "cannot happen" */
fprintf(stderr,
@@ -1020,7 +1019,7 @@ _("%s: panic: Invalid l_value %d\n"),
*/
static zic_t
-gethms(const char *string, const char *const errstring, const int signable)
+gethms(char const *string, char const *errstring, bool signable)
{
zic_t hh;
int mm, ss, sign;
@@ -1074,7 +1073,7 @@ inrule(register char **const fields, const int nfields)
}
r.r_filename = filename;
r.r_linenum = linenum;
- r.r_stdoff = gethms(fields[RF_STDOFF], _("invalid saved time"), TRUE);
+ r.r_stdoff = gethms(fields[RF_STDOFF], _("invalid saved time"), true);
rulesub(&r, fields[RF_LOYEAR], fields[RF_HIYEAR], fields[RF_COMMAND],
fields[RF_MONTH], fields[RF_DAY], fields[RF_TOD]);
r.r_name = ecpyalloc(fields[RF_NAME]);
@@ -1085,26 +1084,26 @@ inrule(register char **const fields, const int nfields)
rules[nrules++] = r;
}
-static int
+static bool
inzone(register char **const fields, const int nfields)
{
register int i;
if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) {
error(_("wrong number of fields on Zone line"));
- return FALSE;
+ return false;
}
if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0 && lcltime != NULL) {
error(
_("\"Zone %s\" line and -l option are mutually exclusive"),
TZDEFAULT);
- return FALSE;
+ return false;
}
if (strcmp(fields[ZF_NAME], TZDEFRULES) == 0 && psxrules != NULL) {
error(
_("\"Zone %s\" line and -p option are mutually exclusive"),
TZDEFRULES);
- return FALSE;
+ return false;
}
for (i = 0; i < nzones; ++i)
if (zones[i].z_name != NULL &&
@@ -1114,30 +1113,30 @@ _("duplicate zone name %s (file \"%s\", line %d)"),
fields[ZF_NAME],
zones[i].z_filename,
zones[i].z_linenum);
- return FALSE;
+ return false;
}
- return inzsub(fields, nfields, FALSE);
+ return inzsub(fields, nfields, false);
}
-static int
+static bool
inzcont(register char **const fields, const int nfields)
{
if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) {
error(_("wrong number of fields on Zone continuation line"));
- return FALSE;
+ return false;
}
- return inzsub(fields, nfields, TRUE);
+ return inzsub(fields, nfields, true);
}
-static int
-inzsub(register char **const fields, const int nfields, const int iscont)
+static bool
+inzsub(char **fields, int nfields, bool iscont)
{
register char * cp;
static struct zone z;
register int i_gmtoff, i_rule, i_format;
register int i_untilyear, i_untilmonth;
register int i_untilday, i_untiltime;
- register int hasuntil;
+ register bool hasuntil;
if (iscont) {
i_gmtoff = ZFC_GMTOFF;
@@ -1160,11 +1159,11 @@ inzsub(register char **const fields, const int nfields, const int iscont)
}
z.z_filename = filename;
z.z_linenum = linenum;
- z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UT offset"), TRUE);
+ z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UT offset"), true);
if ((cp = strchr(fields[i_format], '%')) != 0) {
if (*++cp != 's' || strchr(cp, '%') != 0) {
error(_("invalid abbreviation format"));
- return FALSE;
+ return false;
}
}
z.z_rule = ecpyalloc(fields[i_rule]);
@@ -1194,7 +1193,7 @@ inzsub(register char **const fields, const int nfields, const int iscont)
error(_(
"Zone continuation line end time is not after end time of previous line"
));
- return FALSE;
+ return false;
}
}
zones = growalloc(zones, sizeof *zones, nzones, &nzones_alloc);
@@ -1234,7 +1233,7 @@ inleap(register char ** const fields, const int nfields)
leapmaxyear = year;
if (!leapseen || leapminyear > year)
leapminyear = year;
- leapseen = TRUE;
+ leapseen = true;
j = EPOCH_YEAR;
while (j != year) {
if (year > j) {
@@ -1273,23 +1272,23 @@ inleap(register char ** const fields, const int nfields)
return;
}
t = dayoff * SECSPERDAY;
- tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
+ tod = gethms(fields[LP_TIME], _("invalid time of day"), false);
cp = fields[LP_CORR];
{
- register int positive;
+ register bool positive;
int count;
if (strcmp(cp, "") == 0) { /* infile() turns "-" into "" */
- positive = FALSE;
+ positive = false;
count = 1;
} else if (strcmp(cp, "--") == 0) {
- positive = FALSE;
+ positive = false;
count = 2;
} else if (strcmp(cp, "+") == 0) {
- positive = TRUE;
+ positive = true;
count = 1;
} else if (strcmp(cp, "++") == 0) {
- positive = TRUE;
+ positive = true;
count = 2;
} else {
error(_("illegal CORRECTION field on Leap line"));
@@ -1354,32 +1353,32 @@ rulesub(register struct rule *const rp,
return;
}
rp->r_month = lp->l_value;
- rp->r_todisstd = FALSE;
- rp->r_todisgmt = FALSE;
+ rp->r_todisstd = false;
+ rp->r_todisgmt = false;
dp = ecpyalloc(timep);
if (*dp != '\0') {
ep = dp + strlen(dp) - 1;
switch (lowerit(*ep)) {
case 's': /* Standard */
- rp->r_todisstd = TRUE;
- rp->r_todisgmt = FALSE;
+ rp->r_todisstd = true;
+ rp->r_todisgmt = false;
*ep = '\0';
break;
case 'w': /* Wall */
- rp->r_todisstd = FALSE;
- rp->r_todisgmt = FALSE;
+ rp->r_todisstd = false;
+ rp->r_todisgmt = false;
*ep = '\0';
break;
case 'g': /* Greenwich */
case 'u': /* Universal */
case 'z': /* Zulu */
- rp->r_todisstd = TRUE;
- rp->r_todisgmt = TRUE;
+ rp->r_todisstd = true;
+ rp->r_todisgmt = true;
*ep = '\0';
break;
}
}
- rp->r_tod = gethms(dp, _("invalid time of day"), FALSE);
+ rp->r_tod = gethms(dp, _("invalid time of day"), false);
free(dp);
/*
** Year work.
@@ -1534,7 +1533,7 @@ atcomp(const void *avp, const void *bvp)
return (a < b) ? -1 : (a > b);
}
-static int
+static bool
is32(const zic_t x)
{
return INT32_MIN <= x && x <= INT32_MAX;
@@ -1648,7 +1647,7 @@ writezone(const char *const name, const char *const string, char version)
exit(EXIT_FAILURE);
}
if ((fp = fopen(fullname, "wb")) == NULL) {
- if (mkdirs(fullname) != 0)
+ if (! mkdirs(fullname))
exit(EXIT_FAILURE);
if ((fp = fopen(fullname, "wb")) == NULL) {
const char *e = strerror(errno);
@@ -1690,16 +1689,16 @@ writezone(const char *const name, const char *const string, char version)
** (32- or 64-bit) window.
*/
if (typecnt != 0)
- writetype[typecnt - 1] = TRUE;
+ writetype[typecnt - 1] = true;
} else {
for (i = thistimei - 1; i < thistimelim; ++i)
if (i >= 0)
- writetype[types[i]] = TRUE;
+ writetype[types[i]] = true;
/*
** For America/Godthab and Antarctica/Palmer
*/
if (thistimei == 0)
- writetype[0] = TRUE;
+ writetype[0] = true;
}
#ifndef LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH
/*
@@ -1729,22 +1728,22 @@ writezone(const char *const name, const char *const string, char version)
isdsts[mrudst] = -1;
type = addtype(gmtoffs[mrudst],
&chars[abbrinds[mrudst]],
- TRUE,
+ true,
ttisstds[mrudst],
ttisgmts[mrudst]);
- isdsts[mrudst] = TRUE;
- writetype[type] = TRUE;
+ isdsts[mrudst] = 1;
+ writetype[type] = true;
}
if (histd >= 0 && mrustd >= 0 && histd != mrustd &&
gmtoffs[histd] != gmtoffs[mrustd]) {
isdsts[mrustd] = -1;
type = addtype(gmtoffs[mrustd],
&chars[abbrinds[mrustd]],
- FALSE,
+ false,
ttisstds[mrustd],
ttisgmts[mrustd]);
- isdsts[mrustd] = FALSE;
- writetype[type] = TRUE;
+ isdsts[mrustd] = 0;
+ writetype[type] = true;
}
}
#endif /* !defined LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH */
@@ -1855,7 +1854,7 @@ writezone(const char *const name, const char *const string, char version)
static void
doabbr(char *const abbr, const char *const format, const char *const letters,
- const int isdst, const int doquotes)
+ bool isdst, bool doquotes)
{
register char * cp;
register char * slashp;
@@ -1896,7 +1895,7 @@ updateminmax(const zic_t x)
max_year = x;
}
-static int
+static bool
stringoffset(char *result, zic_t offset)
{
register int hours;
@@ -1915,7 +1914,7 @@ stringoffset(char *result, zic_t offset)
hours = offset;
if (hours >= HOURSPERDAY * DAYSPERWEEK) {
result[0] = '\0';
- return -1;
+ return false;
}
sprintf(end(result), "%d", hours);
if (minutes != 0 || seconds != 0) {
@@ -1923,7 +1922,7 @@ stringoffset(char *result, zic_t offset)
if (seconds != 0)
sprintf(end(result), ":%02d", seconds);
}
- return 0;
+ return true;
}
static int
@@ -1982,7 +1981,7 @@ stringrule(char *result, const struct rule *const rp, const zic_t dstoff,
tod += dstoff;
if (tod != 2 * SECSPERMIN * MINSPERHOUR) {
strcat(result, "/");
- if (stringoffset(end(result), tod) != 0)
+ if (! stringoffset(end(result), tod))
return -1;
if (tod < 0) {
if (compat < 2013)
@@ -2071,14 +2070,14 @@ stringzone(char *result, const struct zone *const zpfirst, const int zonecount)
dstr.r_dycode = DC_DOM;
dstr.r_dayofmonth = 1;
dstr.r_tod = 0;
- dstr.r_todisstd = dstr.r_todisgmt = FALSE;
+ dstr.r_todisstd = dstr.r_todisgmt = false;
dstr.r_stdoff = stdrp->r_stdoff;
dstr.r_abbrvar = stdrp->r_abbrvar;
stdr.r_month = TM_DECEMBER;
stdr.r_dycode = DC_DOM;
stdr.r_dayofmonth = 31;
stdr.r_tod = SECSPERDAY + stdrp->r_stdoff;
- stdr.r_todisstd = stdr.r_todisgmt = FALSE;
+ stdr.r_todisstd = stdr.r_todisgmt = false;
stdr.r_stdoff = 0;
stdr.r_abbrvar
= (stdabbrrp ? stdabbrrp->r_abbrvar : "");
@@ -2089,17 +2088,17 @@ stringzone(char *result, const struct zone *const zpfirst, const int zonecount)
if (stdrp == NULL && (zp->z_nrules != 0 || zp->z_stdoff != 0))
return -1;
abbrvar = (stdrp == NULL) ? "" : stdrp->r_abbrvar;
- doabbr(result, zp->z_format, abbrvar, FALSE, TRUE);
- if (stringoffset(end(result), -zp->z_gmtoff) != 0) {
+ doabbr(result, zp->z_format, abbrvar, false, true);
+ if (! stringoffset(end(result), -zp->z_gmtoff)) {
result[0] = '\0';
return -1;
}
if (dstrp == NULL)
return compat;
- doabbr(end(result), zp->z_format, dstrp->r_abbrvar, TRUE, TRUE);
+ doabbr(end(result), zp->z_format, dstrp->r_abbrvar, true, true);
if (dstrp->r_stdoff != SECSPERMIN * MINSPERHOUR)
- if (stringoffset(end(result),
- -(zp->z_gmtoff + dstrp->r_stdoff)) != 0) {
+ if (! stringoffset(end(result),
+ -(zp->z_gmtoff + dstrp->r_stdoff))) {
result[0] = '\0';
return -1;
}
@@ -2128,23 +2127,23 @@ outzone(const struct zone * const zpfirst, const int zonecount)
register const struct zone * zp;
register struct rule * rp;
register int i, j;
- register int usestart, useuntil;
+ register bool usestart, useuntil;
register zic_t starttime, untiltime;
register zic_t gmtoff;
register zic_t stdoff;
register zic_t year;
register zic_t startoff;
- register int startttisstd;
- register int startttisgmt;
+ register bool startttisstd;
+ register bool startttisgmt;
register int type;
register char * startbuf;
register char * ab;
register char * envvar;
register int max_abbr_len;
register int max_envvar_len;
- register int prodstic; /* all rules are min to max */
+ register bool prodstic; /* all rules are min to max */
register int compat;
- register int do_extend;
+ register bool do_extend;
register char version;
max_abbr_len = 2 + max_format_len + max_abbrvar_len;
@@ -2165,8 +2164,8 @@ outzone(const struct zone * const zpfirst, const int zonecount)
** Thanks to Earl Chew
** for noting the need to unconditionally initialize startttisstd.
*/
- startttisstd = FALSE;
- startttisgmt = FALSE;
+ startttisstd = false;
+ startttisgmt = false;
min_year = max_year = EPOCH_YEAR;
if (leapseen) {
updateminmax(leapminyear);
@@ -2183,7 +2182,7 @@ outzone(const struct zone * const zpfirst, const int zonecount)
if (rp->r_hiwasnum)
updateminmax(rp->r_hiyear);
if (rp->r_lowasnum || rp->r_hiwasnum)
- prodstic = FALSE;
+ prodstic = false;
}
}
/*
@@ -2264,13 +2263,13 @@ outzone(const struct zone * const zpfirst, const int zonecount)
if (zp->z_nrules == 0) {
stdoff = zp->z_stdoff;
doabbr(startbuf, zp->z_format,
- NULL, stdoff != 0, FALSE);
+ NULL, stdoff != 0, false);
type = addtype(oadd(zp->z_gmtoff, stdoff),
startbuf, stdoff != 0, startttisstd,
startttisgmt);
if (usestart) {
addtt(starttime, type);
- usestart = FALSE;
+ usestart = false;
} else addtt(big_bang_time, type);
} else for (year = min_year; year <= max_year; ++year) {
if (useuntil && year > zp->z_untilrule.r_hiyear)
@@ -2336,12 +2335,12 @@ outzone(const struct zone * const zpfirst, const int zonecount)
if (k < 0)
break; /* go on to next year */
rp = &zp->z_rules[k];
- rp->r_todo = FALSE;
+ rp->r_todo = false;
if (useuntil && ktime >= untiltime)
break;
stdoff = rp->r_stdoff;
if (usestart && ktime == starttime)
- usestart = FALSE;
+ usestart = false;
if (usestart) {
if (ktime < starttime) {
startoff = oadd(zp->z_gmtoff,
@@ -2349,7 +2348,7 @@ outzone(const struct zone * const zpfirst, const int zonecount)
doabbr(startbuf, zp->z_format,
rp->r_abbrvar,
rp->r_stdoff != 0,
- FALSE);
+ false);
continue;
}
if (*startbuf == '\0' &&
@@ -2359,14 +2358,14 @@ outzone(const struct zone * const zpfirst, const int zonecount)
zp->z_format,
rp->r_abbrvar,
rp->r_stdoff !=
- 0,
- FALSE);
+ false,
+ false);
}
}
eats(zp->z_filename, zp->z_linenum,
rp->r_filename, rp->r_linenum);
doabbr(ab, zp->z_format, rp->r_abbrvar,
- rp->r_stdoff != 0, FALSE);
+ rp->r_stdoff != 0, false);
offset = oadd(zp->z_gmtoff, rp->r_stdoff);
type = addtype(offset, ab, rp->r_stdoff != 0,
rp->r_todisstd, rp->r_todisgmt);
@@ -2469,23 +2468,10 @@ addtt(const zic_t starttime, int type)
}
static int
-addtype(const zic_t gmtoff, const char *const abbr, const int isdst,
- const int ttisstd, const int ttisgmt)
+addtype(zic_t gmtoff, char const *abbr, bool isdst, bool ttisstd, bool ttisgmt)
{
register int i, j;
- if (isdst != TRUE && isdst != FALSE) {
- error(_("internal error: addtype called with bad isdst"));
- exit(EXIT_FAILURE);
- }
- if (ttisstd != TRUE && ttisstd != FALSE) {
- error(_("internal error: addtype called with bad ttisstd"));
- exit(EXIT_FAILURE);
- }
- if (ttisgmt != TRUE && ttisgmt != FALSE) {
- error(_("internal error: addtype called with bad ttisgmt"));
- exit(EXIT_FAILURE);
- }
/*
** See if there's already an entry for this zone type.
** If so, just return its index.
@@ -2525,7 +2511,7 @@ addtype(const zic_t gmtoff, const char *const abbr, const int isdst,
}
static void
-leapadd(const zic_t t, const int positive, const int rolling, int count)
+leapadd(zic_t t, bool positive, int rolling, int count)
{
register int i, j;
@@ -2569,22 +2555,22 @@ adjleap(void)
}
}
-static int
+static bool
yearistype(const int year, const char *const type)
{
static char * buf;
int result;
if (type == NULL || *type == '\0')
- return TRUE;
+ return true;
buf = erealloc(buf, 132 + strlen(yitcommand) + strlen(type));
sprintf(buf, "%s %d %s", yitcommand, year, type);
result = system(buf);
if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
case 0:
- return TRUE;
+ return true;
case 1:
- return FALSE;
+ return false;
}
error(_("Wild result from command execution"));
fprintf(stderr, _("%s: command was '%s', result was %d\n"),
@@ -2594,24 +2580,24 @@ yearistype(const int year, const char *const type)
}
/* Is A a space character in the C locale? */
-static int
+static bool
is_space(char a)
{
switch (a) {
default:
- return 0;
+ return false;
case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
- return 1;
+ return true;
}
}
/* Is A an alphabetic character in the C locale? */
-static int
+static bool
is_alpha(char a)
{
switch (a) {
default:
- return 0;
+ return false;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
@@ -2620,7 +2606,7 @@ is_alpha(char a)
case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
case 'v': case 'w': case 'x': case 'y': case 'z':
- return 1;
+ return true;
}
}
@@ -2644,27 +2630,27 @@ lowerit(char a)
}
/* case-insensitive equality */
-static ATTRIBUTE_PURE int
+static ATTRIBUTE_PURE bool
ciequal(register const char *ap, register const char *bp)
{
while (lowerit(*ap) == lowerit(*bp++))
if (*ap++ == '\0')
- return TRUE;
- return FALSE;
+ return true;
+ return false;
}
-static ATTRIBUTE_PURE int
+static ATTRIBUTE_PURE bool
itsabbr(register const char *abbr, register const char *word)
{
if (lowerit(*abbr) != lowerit(*word))
- return FALSE;
+ return false;
++word;
while (*++abbr != '\0')
do {
if (*word == '\0')
- return FALSE;
+ return false;
} while (lowerit(*word++) != lowerit(*abbr));
- return TRUE;
+ return true;
}
static ATTRIBUTE_PURE const struct lookup *
@@ -2887,14 +2873,14 @@ mp = _("time zone abbreviation differs from POSIX standard");
charcnt += i;
}
-static int
+static bool
mkdirs(char *argname)
{
register char * name;
register char * cp;
if (argname == NULL || *argname == '\0')
- return 0;
+ return true;
cp = name = ecpyalloc(argname);
while ((cp = strchr(cp + 1, '/')) != 0) {
*cp = '\0';
@@ -2920,11 +2906,11 @@ mkdirs(char *argname)
" %s: %s\n"),
progname, name, e);
free(name);
- return -1;
+ return false;
}
}
*cp = '/';
}
free(name);
- return 0;
+ return true;
}
--
1.9.1
1
0
[PROPOSED PATCH] Port to GCC 3.4.6, which does not define __LONG_LONG_MIN__ on Irix.
by Paul Eggert Aug. 19, 2014
by Paul Eggert Aug. 19, 2014
Aug. 19, 2014
* private.h (INT_FAST64_MIN, INTMAX_MIN): Don't use
__LONG_LONG_MIN__ when defining backwards-compatibility workaround.
---
private.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/private.h b/private.h
index 38f3f43..9482790 100644
--- a/private.h
+++ b/private.h
@@ -144,7 +144,7 @@ typedef long long int_fast64_t;
# define INT_FAST64_MIN LLONG_MIN
# define INT_FAST64_MAX LLONG_MAX
# else
-# define INT_FAST64_MIN __LONG_LONG_MIN__
+# define INT_FAST64_MIN (-1 - __LONG_LONG_MAX__)
# define INT_FAST64_MAX __LONG_LONG_MAX__
# endif
# define SCNdFAST64 "lld"
@@ -182,7 +182,7 @@ typedef long long intmax_t;
# define INTMAX_MIN LLONG_MIN
# else
# define INTMAX_MAX __LONG_LONG_MAX__
-# define INTMAX_MIN __LONG_LONG_MIN__
+# define INTMAX_MIN (-1 - __LONG_LONG_MAX__)
# endif
# else
typedef long intmax_t;
--
1.9.1
1
0
[PROPOSED PATCH 1/5] Port to platforms with leap seconds and unsigned time_t.
by Paul Eggert Aug. 19, 2014
by Paul Eggert Aug. 19, 2014
Aug. 19, 2014
* localtime.c (tzload): On platforms where time_t is unsigned,
don't mishandle zones that contain leap seconds but no ordinary
transitions after 1970. This problem can be reproduced by running
'zdump -v right/Asia/Dubai' on a platform where time_t is an
unsigned 32-bit integer.
---
localtime.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/localtime.c b/localtime.c
index 8a66650..a1e6601 100644
--- a/localtime.c
+++ b/localtime.c
@@ -395,28 +395,28 @@ tzload(register const char *name, register struct state *const sp,
ttisstdcnt + /* ttisstds */
ttisgmtcnt) /* ttisgmts */
goto oops;
+
+ /* Read transitions, discarding those out of time_t range.
+ But pretend the last transition before time_t_min
+ occurred at time_t_min. */
timecnt = 0;
for (i = 0; i < sp->timecnt; ++i) {
int_fast64_t at
= stored == 4 ? detzcode(p) : detzcode64(p);
- sp->types[i] = ((TYPE_SIGNED(time_t)
- ? time_t_min <= at
- : 0 <= at)
- && at <= time_t_max);
+ sp->types[i] = at <= time_t_max;
if (sp->types[i]) {
- if (i && !timecnt && at != time_t_min) {
- /*
- ** Keep the earlier record, but tweak
- ** it so that it starts with the
- ** minimum time_t value.
- */
- sp->types[i - 1] = 1;
- sp->ats[timecnt++] = time_t_min;
- }
- sp->ats[timecnt++] = at;
+ time_t attime
+ = ((TYPE_SIGNED(time_t) ? at < time_t_min : at < 0)
+ ? time_t_min : at);
+ if (timecnt && sp->ats[timecnt - 1] == attime) {
+ sp->types[i - 1] = 0;
+ timecnt--;
+ }
+ sp->ats[timecnt++] = attime;
}
p += stored;
}
+
timecnt = 0;
for (i = 0; i < sp->timecnt; ++i) {
unsigned char typ = *p++;
--
1.9.1
1
4
Re: [tz] [PROPOSED PATCH] * northamerica (TC, America/Grand_Turk): Switch from EST/EDT to AST.
by Matt Johnson Aug. 19, 2014
by Matt Johnson Aug. 19, 2014
Aug. 19, 2014
Typo. I think you mean "UTC-4 year round". Not +4.
Sent from my Windows Phone
________________________________
From: Paul Eggert<mailto:eggert@cs.ucla.edu>
Sent: ‎8/‎19/‎2014 1:15 AM
To: tz(a)iana.org<mailto:tz@iana.org>
Subject: [tz] [PROPOSED PATCH] * northamerica (TC, America/Grand_Turk): Switch from EST/EDT to AST.
* NEWS: Document this.
---
NEWS | 5 +++++
northamerica | 12 +++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 1a78041..6fb00b0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ News for the tz database
Unreleased, experimental changes
+ Changes affecting future time stamps
+
+ Turks & Caicos is switching from US eastern time to UTC+4 year-round,
+ modeled as a switch from EST/EDT to AST on 2014-11-02 at 02:00.
+
Changes affecting past time stamps
Time in Russia or the USSR before 1926 or so has been corrected by
diff --git a/northamerica b/northamerica
index c6ed74b..4c1d4bd 100644
--- a/northamerica
+++ b/northamerica
@@ -3117,16 +3117,22 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre
# Shanks & Pottenger say they use US DST rules, but IATA SSIM (1991/1998)
# says they switch at midnight. Go with Shanks & Pottenger.
#
+# From Paul Eggert (2014-08-19):
+# The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round. See:
+# http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm
+# Model this as a switch from EST/EDT to AST on 2014-11-02 at 02:00.
+#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule TC 1979 1986 - Apr lastSun 2:00 1:00 D
Rule TC 1979 2006 - Oct lastSun 2:00 0 S
Rule TC 1987 2006 - Apr Sun>=1 2:00 1:00 D
-Rule TC 2007 max - Mar Sun>=8 2:00 1:00 D
-Rule TC 2007 max - Nov Sun>=1 2:00 0 S
+Rule TC 2007 2014 - Mar Sun>=8 2:00 1:00 D
+Rule TC 2007 2014 - Nov Sun>=1 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Grand_Turk -4:44:32 - LMT 1890
-5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 TC E%sT
+ -5:00 TC E%sT 2014 Nov 2 2:00
+ -4:00 - AST
# British Virgin Is
# Virgin Is
--
1.9.1
2
1
* northamerica (TC): Remove, as it's now a duplicate of the US rules.
Remove obsolescent comment about this.
(America/Grand_Turk): Use US rather than TC.
---
northamerica | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/northamerica b/northamerica
index 4c1d4bd..ebfe5e3 100644
--- a/northamerica
+++ b/northamerica
@@ -3113,25 +3113,16 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre
# Clocks are set back one hour at 2:00 a.m. local Daylight Saving Time"
# indicating that the normal ET rules are followed.
#
-# From Paul Eggert (2006-05-01):
-# Shanks & Pottenger say they use US DST rules, but IATA SSIM (1991/1998)
-# says they switch at midnight. Go with Shanks & Pottenger.
-#
# From Paul Eggert (2014-08-19):
# The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round. See:
# http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm
# Model this as a switch from EST/EDT to AST on 2014-11-02 at 02:00.
#
-# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule TC 1979 1986 - Apr lastSun 2:00 1:00 D
-Rule TC 1979 2006 - Oct lastSun 2:00 0 S
-Rule TC 1987 2006 - Apr Sun>=1 2:00 1:00 D
-Rule TC 2007 2014 - Mar Sun>=8 2:00 1:00 D
-Rule TC 2007 2014 - Nov Sun>=1 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Grand_Turk -4:44:32 - LMT 1890
-5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 TC E%sT 2014 Nov 2 2:00
+ -5:00 - EST 1979
+ -5:00 US E%sT 2014 Nov 2 2:00
-4:00 - AST
# British Virgin Is
--
1.9.1
1
0
[PROPOSED PATCH] * northamerica (TC, America/Grand_Turk): Switch from EST/EDT to AST.
by Paul Eggert Aug. 19, 2014
by Paul Eggert Aug. 19, 2014
Aug. 19, 2014
* NEWS: Document this.
---
NEWS | 5 +++++
northamerica | 12 +++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 1a78041..6fb00b0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ News for the tz database
Unreleased, experimental changes
+ Changes affecting future time stamps
+
+ Turks & Caicos is switching from US eastern time to UTC+4 year-round,
+ modeled as a switch from EST/EDT to AST on 2014-11-02 at 02:00.
+
Changes affecting past time stamps
Time in Russia or the USSR before 1926 or so has been corrected by
diff --git a/northamerica b/northamerica
index c6ed74b..4c1d4bd 100644
--- a/northamerica
+++ b/northamerica
@@ -3117,16 +3117,22 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre
# Shanks & Pottenger say they use US DST rules, but IATA SSIM (1991/1998)
# says they switch at midnight. Go with Shanks & Pottenger.
#
+# From Paul Eggert (2014-08-19):
+# The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round. See:
+# http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm
+# Model this as a switch from EST/EDT to AST on 2014-11-02 at 02:00.
+#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule TC 1979 1986 - Apr lastSun 2:00 1:00 D
Rule TC 1979 2006 - Oct lastSun 2:00 0 S
Rule TC 1987 2006 - Apr Sun>=1 2:00 1:00 D
-Rule TC 2007 max - Mar Sun>=8 2:00 1:00 D
-Rule TC 2007 max - Nov Sun>=1 2:00 0 S
+Rule TC 2007 2014 - Mar Sun>=8 2:00 1:00 D
+Rule TC 2007 2014 - Nov Sun>=1 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Grand_Turk -4:44:32 - LMT 1890
-5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 TC E%sT
+ -5:00 TC E%sT 2014 Nov 2 2:00
+ -4:00 - AST
# British Virgin Is
# Virgin Is
--
1.9.1
1
0
Yesterday the BBC reported that Scottish independence could mean
Scotland will part ways with the rest of the UK in the matter of time
zones, which presumably would mean we'd need a Zone for Europe/Glasgow.
The article does not discuss what might ensue in Ireland.
Webber E. Scottish independence: Could vote help shift the debate on
clocks? BBC News 2014-08-13. http://www.bbc.com/news/magazine-28744490
As a historical note, the article gives 1840 for the "first recorded
occasion when local times in different parts of the UK were synchronised
... by the Great Western Railway". This refers to GWR's November 1840
order that London time be used in all its timetables and stations. For
more, see:
Carradice P. The Great Western Railway creates standard time. BBC Wales
2012-09-05.
http://www.bbc.co.uk/blogs/wales/posts/the-great-western-railway-creates-st…
5
6
Aug. 18, 2014
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 3d24c2a..e4e2742 100644
--- a/Makefile
+++ b/Makefile
@@ -626,7 +626,7 @@ difftime.o: private.h
ialloc.o: private.h
localtime.o: private.h tzfile.h
scheck.o: private.h
-strftime.o: tzfile.h
+strftime.o: private.h tzfile.h
zdump.o: version.h
zic.o: private.h tzfile.h version.h
--
1.9.1
1
0
---
NEWS | 10 +++++-----
Theory | 4 ++--
africa | 2 +-
asia | 7 +++----
australasia | 2 +-
europe | 2 +-
newctime.3 | 2 +-
northamerica | 2 +-
southamerica | 2 +-
tzfile.5 | 6 +++---
zic.8 | 2 +-
11 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/NEWS b/NEWS
index 4be8450..9765e56 100644
--- a/NEWS
+++ b/NEWS
@@ -427,7 +427,7 @@ Release 2014a - 2014-03-07 23:30:29 -0800
Microsoft has some support for tz database names.
- CLDR data is available in both XML and JSON form.
+ CLDR data are available in both XML and JSON form.
Mention Maggiolo's map of solar vs standard time.
(Thanks to Arthur David Olson.)
@@ -671,8 +671,8 @@ Release 2013e - 2013-09-19 23:50:04 -0700
some errors before 1947.
Some zones have been turned into links, when they differ from
- existing zones only in older data that was likely invented or that
- differs only in LMT or transition from LMT. These changes affect
+ existing zones only in older data that were likely invented or that
+ differ only in LMT or transitions from LMT. These changes affect
only time stamps before 1943. The affected zones are:
Africa/Juba, America/Anguilla, America/Aruba, America/Dominica,
America/Grenada, America/Guadeloupe, America/Marigot,
@@ -2543,7 +2543,7 @@ Release 94h - 1994-12-10 12:51:14 -0500
data files.
Think of this as "TZ Classic" - the software has been set up not to break if
- universal time shows up in its input, and the data has been left as is so as
+ universal time shows up in its input, and the data have been left as is so as
not to break existing implementations.
@@ -2623,7 +2623,7 @@ Release 93f - 1993-10-15 12:27:46 -0400
Release 93e - 1993-09-05 21:21:44 -0400
- There's updated data for Israel, England, and Kwajalein; there's
+ There are updated data for Israel, England, and Kwajalein; there's
also an update to "zdump" to cope with Kwajalein's 24-hour jump.
Thanks to Paul Eggert and Peter Ilieve for the changes.
diff --git a/Theory b/Theory
index 2a3a911..15c695e 100644
--- a/Theory
+++ b/Theory
@@ -254,7 +254,7 @@ Errors in the tz database arise from many sources:
the current single entry for France would need to split into dozens
of entries, perhaps hundreds.
- * Most of the pre-1970 data comes from unreliable sources, often
+ * Most of the pre-1970 data come from unreliable sources, often
astrology books that lack citations and whose compilers evidently
invented entries when the true facts were unknown, without
reporting which entries were known and which were invented.
@@ -283,7 +283,7 @@ Errors in the tz database arise from many sources:
Caledonian railways.
* The tz database does not record the earliest time for which a
- zone's data is thereafter valid for every location in the region.
+ zone's data are thereafter valid for every location in the region.
For example, Europe/London is valid for all locations in its
region after GMT was made the standard time, but the date of
standardization (1880-08-02) is not in the tz database, other than
diff --git a/africa b/africa
index d251500..7e3a860 100644
--- a/africa
+++ b/africa
@@ -1,7 +1,7 @@
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
diff --git a/asia b/asia
index f8237f4..fbb9391 100644
--- a/asia
+++ b/asia
@@ -1,7 +1,7 @@
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
@@ -386,7 +386,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D
# Xujiahui Observatory was under French control and stuck with UT+8.
#
# In earlier versions of this file, China had many separate Zone entries, but
-# this was based on what was apparently incorrect data in Shanks & Pottenger.
+# this was based on what were apparently incorrect data in Shanks & Pottenger.
# This has now been simplified to the two entries Asia/Shanghai and
# Asia/Urumqi, with the others being links for backward compatibility.
# Proposed in 1918 and theoretically in effect until 1949 (although in practice
@@ -2630,8 +2630,7 @@ Rule Syria 2007 only - Nov Fri>=1 0:00 0 -
# From Stephen Colebourne (2008-03-17):
# For everyone's info, I saw an IATA time zone change for [Syria] for
-# this month (March 2008) in the last day or so...This is the data IATA
-# are now using:
+# this month (March 2008) in the last day or so....
# Country Time Standard --- DST Start --- --- DST End --- DST
# Name Zone Variation Time Date Time Date
# Variation
diff --git a/australasia b/australasia
index 094383e..117e841 100644
--- a/australasia
+++ b/australasia
@@ -761,7 +761,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# NOTES
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
diff --git a/europe b/europe
index 68a0dc7..261b619 100644
--- a/europe
+++ b/europe
@@ -1,7 +1,7 @@
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
diff --git a/newctime.3 b/newctime.3
index dccab77..5a3f65a 100644
--- a/newctime.3
+++ b/newctime.3
@@ -235,7 +235,7 @@ time(2),
tzfile(5)
.SH NOTES
The return values point to static data;
-the data is overwritten by each call.
+the data are overwritten by each call.
The
.B tm_zone
field of a returned
diff --git a/northamerica b/northamerica
index 8958588..07cb33a 100644
--- a/northamerica
+++ b/northamerica
@@ -3,7 +3,7 @@
# also includes Central America and the Caribbean
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
diff --git a/southamerica b/southamerica
index 08a0731..0f0c233 100644
--- a/southamerica
+++ b/southamerica
@@ -1,7 +1,7 @@
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
-# This data is by no means authoritative; if you think you know better,
+# This file is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
# tz(a)iana.org for general use in the future). For more, please see
# the file CONTRIBUTING in the tz distribution.
diff --git a/tzfile.5 b/tzfile.5
index f413349..182cc43 100644
--- a/tzfile.5
+++ b/tzfile.5
@@ -25,14 +25,14 @@ The number of UT/local indicators stored in the file.
The number of standard/wall indicators stored in the file.
.TP
.I tzh_leapcnt
-The number of leap seconds for which data is stored in the file.
+The number of leap seconds for which data are stored in the file.
.TP
.I tzh_timecnt
-The number of "transition times" for which data is stored
+The number of "transition times" for which data are stored
in the file.
.TP
.I tzh_typecnt
-The number of "local time types" for which data is stored
+The number of "local time types" for which data are stored
in the file (must not be zero).
.TP
.I tzh_charcnt
diff --git a/zic.8 b/zic.8
index a2e275d..2e5318a 100644
--- a/zic.8
+++ b/zic.8
@@ -72,7 +72,7 @@ no leap second information appears in output files.
Be more verbose, and complain about the following situations:
.RS
.PP
-The input data specifies a link to a link.
+The input specifies a link to a link.
.PP
A year that appears in a data file is outside the range
of years representable by
--
1.9.1
13
15
In Vox yesterday Matthew Yglesias argued that time zones ought to be
abolished, writing "They were a good idea at the time, but in the modern
world they cause more trouble than they are worth." It's tempting to
agree. See:
Yglesias M. The case against time zones: They're impractical & outdated.
Vox 2014-08-05. http://www.vox.com/2014/8/5/5970767/case-against-time-zones
Yglesias's underlying justification is essentially the same one that
McCarthy and Klepczynski used in their proposal to discontinue leap
seconds; see Steve Allen's summary of the resulting controversy in
<http://www.ucolick.org/~sla/leapsecs/>.
9
14