1989-03-05 17:23:15 -05:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1985, 1987, 1988 The Regents of the University of California.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
|
* by the University of California, Berkeley. The name of the
|
|
|
|
|
* University may not be used to endorse or promote products derived
|
|
|
|
|
* from this software without specific prior written permission.
|
Don't abuse "`" to mean open quote.
This was appropriate before Unicode, where "`" and "'" often balanced
in visual output, but that's been obsolete for a while.
Overall, single-quote 'like this' instead of `like this', and
double-quote "like this" or (in typeset output) “like this”
instead of ``like this''. While we're at it, fix some glitches
with hyphens versus minus versus en dash versus em dash.
* Makefile ($(MANTXTS)): Use UTF-8 locale to produce *.txt output.
* checktab.awk, tzselect.ksh:
Quote 'like this' in diagnostics, instead of `like this'.
* date.1, newctime.3, newtzset.3, time2posix.3, zic.8 (q, lq, rq):
New macros. Use them for better double-quoting in output.
* workman.sh: Tell Perl that its stdin and stdout are UTF-8.
* NEWS: Document this.
2014-06-15 13:27:37 -07:00
|
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
1989-03-05 17:23:15 -05:00
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
2014-08-06 22:51:12 -07:00
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
1989-03-05 17:23:15 -05:00
|
|
|
*/
|
|
|
|
|
|
1989-03-21 11:37:12 -05:00
|
|
|
#include "private.h"
|
1995-01-03 11:08:21 -05:00
|
|
|
#if HAVE_ADJTIME || HAVE_SETTIMEOFDAY
|
|
|
|
|
#include "sys/time.h" /* for struct timeval, struct timezone */
|
|
|
|
|
#endif /* HAVE_ADJTIME || HAVE_SETTIMEOFDAY */
|
|
|
|
|
#include "locale.h"
|
1989-04-10 20:07:08 -04:00
|
|
|
#include "utmp.h" /* for OLD_TIME (or its absence) */
|
1996-01-10 16:44:46 -05:00
|
|
|
#if HAVE_UTMPX_H
|
|
|
|
|
#include "utmpx.h"
|
|
|
|
|
#endif
|
1989-03-06 18:59:18 -05:00
|
|
|
|
2001-10-09 13:31:19 -04:00
|
|
|
#ifndef OTIME_MSG
|
|
|
|
|
#define OTIME_MSG "old time"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef NTIME_MSG
|
|
|
|
|
#define NTIME_MSG "new time"
|
|
|
|
|
#endif
|
2014-08-14 21:27:54 -07:00
|
|
|
#if !defined WTMPX_FILE && defined _PATH_WTMPX
|
|
|
|
|
# define WTMPX_FILE _PATH_WTMPX
|
|
|
|
|
#endif
|
2001-10-09 13:31:19 -04:00
|
|
|
|
1989-03-22 20:08:39 -05:00
|
|
|
/*
|
|
|
|
|
** The two things date knows about time are. . .
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef TM_YEAR_BASE
|
|
|
|
|
#define TM_YEAR_BASE 1900
|
|
|
|
|
#endif /* !defined TM_YEAR_BASE */
|
|
|
|
|
|
|
|
|
|
#ifndef SECSPERMIN
|
|
|
|
|
#define SECSPERMIN 60
|
|
|
|
|
#endif /* !defined SECSPERMIN */
|
|
|
|
|
|
1989-03-07 21:51:45 -05:00
|
|
|
extern char ** environ;
|
|
|
|
|
extern char * optarg;
|
|
|
|
|
extern int optind;
|
1989-03-07 19:58:19 -05:00
|
|
|
extern char * tzname[2];
|
1989-03-05 17:23:15 -05:00
|
|
|
|
1989-03-07 14:14:29 -05:00
|
|
|
static int retval = EXIT_SUCCESS;
|
|
|
|
|
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
static void checkfinal(char const *, bool, time_t, time_t);
|
2014-08-25 19:41:21 -07:00
|
|
|
static time_t convert(const char *, bool, time_t);
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
static void display(const char *, time_t);
|
2007-11-08 09:21:56 -05:00
|
|
|
static void dogmt(void);
|
|
|
|
|
static void errensure(void);
|
|
|
|
|
static void iffy(time_t, time_t, const char *, const char *);
|
|
|
|
|
static const char * nondigit(const char *);
|
|
|
|
|
static void oops(const char *);
|
2014-08-25 19:41:21 -07:00
|
|
|
static void reset(time_t, bool);
|
2007-11-08 09:21:56 -05:00
|
|
|
static void timeout(FILE *, const char *, const struct tm *);
|
|
|
|
|
static void usage(void);
|
|
|
|
|
static void wildinput(const char *, const char *,
|
|
|
|
|
const char *);
|
1989-03-07 19:58:19 -05:00
|
|
|
|
1989-03-06 04:26:22 -05:00
|
|
|
int
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
main(const int argc, char *argv[])
|
1989-03-05 17:23:15 -05:00
|
|
|
{
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register const char * format;
|
|
|
|
|
register const char * value;
|
|
|
|
|
register const char * cp;
|
|
|
|
|
register int ch;
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
register bool dousg;
|
|
|
|
|
register bool aflag = false;
|
|
|
|
|
register bool dflag = false;
|
|
|
|
|
register bool nflag = false;
|
|
|
|
|
register bool tflag = false;
|
|
|
|
|
register bool rflag = false;
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register int minuteswest;
|
|
|
|
|
register int dsttime;
|
|
|
|
|
register double adjust;
|
|
|
|
|
time_t now;
|
|
|
|
|
time_t t;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
intmax_t secs;
|
|
|
|
|
char * endarg;
|
1989-03-05 17:23:15 -05:00
|
|
|
|
1994-06-04 17:05:46 -04:00
|
|
|
INITIALIZE(dousg);
|
2004-11-08 10:19:01 -05:00
|
|
|
#ifdef LC_ALL
|
2014-08-18 19:10:48 -07:00
|
|
|
setlocale(LC_ALL, "");
|
2004-11-08 10:48:47 -05:00
|
|
|
#endif /* defined(LC_ALL) */
|
2004-11-08 10:19:01 -05:00
|
|
|
#if HAVE_GETTEXT
|
1996-02-21 15:47:21 -05:00
|
|
|
#ifdef TZ_DOMAINDIR
|
2014-08-18 19:10:48 -07:00
|
|
|
bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
|
1996-02-21 15:47:21 -05:00
|
|
|
#endif /* defined(TEXTDOMAINDIR) */
|
2014-08-18 19:10:48 -07:00
|
|
|
textdomain(TZ_DOMAIN);
|
2004-11-08 10:19:01 -05:00
|
|
|
#endif /* HAVE_GETTEXT */
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
t = now = time(NULL);
|
1989-03-06 05:10:58 -05:00
|
|
|
format = value = NULL;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
while ((ch = getopt(argc, argv, "ucr:nd:t:a:")) != EOF && ch != -1) {
|
1989-03-06 18:59:18 -05:00
|
|
|
switch (ch) {
|
1989-03-07 21:51:45 -05:00
|
|
|
default:
|
|
|
|
|
usage();
|
2013-09-04 19:07:31 -07:00
|
|
|
case 'u': /* do it in UT */
|
1989-04-11 10:25:52 -04:00
|
|
|
case 'c':
|
1989-03-11 11:56:53 -05:00
|
|
|
dogmt();
|
1989-03-05 17:23:15 -05:00
|
|
|
break;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
case 'r': /* seconds since 1970 */
|
|
|
|
|
if (rflag) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
_("date: error: multiple -r's used"));
|
|
|
|
|
usage();
|
|
|
|
|
}
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
rflag = true;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
errno = 0;
|
|
|
|
|
secs = strtoimax (optarg, &endarg, 0);
|
|
|
|
|
if (*endarg || optarg == endarg)
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
else if (! (time_t_min <= secs && secs <= time_t_max))
|
|
|
|
|
errno = ERANGE;
|
|
|
|
|
if (errno) {
|
|
|
|
|
perror(optarg);
|
|
|
|
|
errensure();
|
|
|
|
|
exit(retval);
|
|
|
|
|
}
|
|
|
|
|
t = secs;
|
|
|
|
|
break;
|
1989-03-05 17:23:15 -05:00
|
|
|
case 'n': /* don't set network */
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
nflag = true;
|
1989-03-05 17:23:15 -05:00
|
|
|
break;
|
2001-03-13 12:32:17 -05:00
|
|
|
case 'd': /* daylight saving time */
|
1989-03-07 21:51:45 -05:00
|
|
|
if (dflag) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: multiple -d's used"));
|
1989-03-07 21:51:45 -05:00
|
|
|
usage();
|
|
|
|
|
}
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
dflag = true;
|
1989-03-10 22:05:54 -05:00
|
|
|
cp = optarg;
|
1989-03-11 11:56:53 -05:00
|
|
|
dsttime = atoi(cp);
|
|
|
|
|
if (*cp == '\0' || *nondigit(cp) != '\0')
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("-t value"), optarg,
|
|
|
|
|
_("must be a non-negative number"));
|
1989-03-05 17:23:15 -05:00
|
|
|
break;
|
1997-12-29 09:31:36 -05:00
|
|
|
case 't': /* minutes west of UTC */
|
1989-03-07 21:51:45 -05:00
|
|
|
if (tflag) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: multiple -t's used"));
|
1989-03-07 21:51:45 -05:00
|
|
|
usage();
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
tflag = true;
|
1989-03-10 22:05:54 -05:00
|
|
|
cp = optarg;
|
1989-03-11 11:56:53 -05:00
|
|
|
minuteswest = atoi(cp);
|
1989-03-10 22:05:54 -05:00
|
|
|
if (*cp == '+' || *cp == '-')
|
|
|
|
|
++cp;
|
|
|
|
|
if (*cp == '\0' || *nondigit(cp) != '\0')
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("-d value"), optarg,
|
|
|
|
|
_("must be a number"));
|
1989-03-09 13:20:49 -05:00
|
|
|
break;
|
|
|
|
|
case 'a': /* adjustment */
|
|
|
|
|
if (aflag) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: multiple -a's used"));
|
1989-03-09 13:20:49 -05:00
|
|
|
usage();
|
|
|
|
|
}
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
aflag = true;
|
1989-03-10 22:05:54 -05:00
|
|
|
cp = optarg;
|
1989-03-11 11:56:53 -05:00
|
|
|
adjust = atof(cp);
|
|
|
|
|
if (*cp == '+' || *cp == '-')
|
|
|
|
|
++cp;
|
|
|
|
|
if (*cp == '\0' || strcmp(cp, ".") == 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("-a value"), optarg,
|
|
|
|
|
_("must be a number"));
|
1989-03-11 11:56:53 -05:00
|
|
|
cp = nondigit(cp);
|
|
|
|
|
if (*cp == '.')
|
|
|
|
|
++cp;
|
|
|
|
|
if (*nondigit(cp) != '\0')
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("-a value"), optarg,
|
|
|
|
|
_("must be a number"));
|
1989-03-07 21:51:45 -05:00
|
|
|
break;
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
1989-03-07 21:51:45 -05:00
|
|
|
}
|
1989-03-06 18:59:18 -05:00
|
|
|
while (optind < argc) {
|
|
|
|
|
cp = argv[optind++];
|
|
|
|
|
if (*cp == '+')
|
|
|
|
|
if (format == NULL)
|
|
|
|
|
format = cp + 1;
|
1989-03-07 21:51:45 -05:00
|
|
|
else {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: multiple formats in command line\n"));
|
1989-03-07 21:51:45 -05:00
|
|
|
usage();
|
|
|
|
|
}
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
else if (value == NULL && !rflag)
|
1989-03-06 18:59:18 -05:00
|
|
|
value = cp;
|
1989-03-07 21:51:45 -05:00
|
|
|
else {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: multiple values in command line\n"));
|
1989-03-07 21:51:45 -05:00
|
|
|
usage();
|
|
|
|
|
}
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
1989-03-07 21:51:45 -05:00
|
|
|
if (value != NULL) {
|
1989-04-05 03:41:05 -04:00
|
|
|
/*
|
|
|
|
|
** This order ensures that "reasonable" twelve-digit inputs
|
|
|
|
|
** (such as 120203042006) won't be misinterpreted
|
|
|
|
|
** even if time_t's range all the way back to the thirteenth
|
|
|
|
|
** century. Do not change the order.
|
|
|
|
|
*/
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
t = convert(value, (dousg = true), now);
|
1989-03-07 21:51:45 -05:00
|
|
|
if (t == -1)
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
t = convert(value, (dousg = false), now);
|
1989-03-10 22:58:42 -05:00
|
|
|
if (t == -1) {
|
|
|
|
|
/*
|
1989-03-11 11:56:53 -05:00
|
|
|
** Out of range values,
|
|
|
|
|
** or time that falls in a DST transition hole?
|
1989-03-10 22:58:42 -05:00
|
|
|
*/
|
1989-03-11 21:07:04 -05:00
|
|
|
if ((cp = strchr(value, '.')) != NULL) {
|
|
|
|
|
/*
|
|
|
|
|
** Ensure that the failure of
|
1995-10-30 09:54:02 -05:00
|
|
|
** TZ=America/New_York date 8712312359.60
|
1989-03-11 21:07:04 -05:00
|
|
|
** doesn't get misdiagnosed. (It was
|
1995-10-30 09:54:02 -05:00
|
|
|
** TZ=America/New_York date 8712311859.60
|
1989-03-11 21:07:04 -05:00
|
|
|
** when the leap second was inserted.)
|
|
|
|
|
** The normal check won't work since
|
1997-12-29 09:31:36 -05:00
|
|
|
** the given time is valid in UTC.
|
1989-03-11 21:07:04 -05:00
|
|
|
*/
|
1989-03-22 20:08:39 -05:00
|
|
|
if (atoi(cp + 1) >= SECSPERMIN)
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("time"), value,
|
|
|
|
|
_("out of range seconds given"));
|
1989-03-11 21:07:04 -05:00
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
dogmt();
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
t = convert(value, false, now);
|
1989-03-11 11:56:53 -05:00
|
|
|
if (t == -1)
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
t = convert(value, true, now);
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("time"), value,
|
1989-03-11 11:56:53 -05:00
|
|
|
(t == -1) ?
|
1996-02-21 15:47:21 -05:00
|
|
|
_("out of range value given") :
|
|
|
|
|
_("time skipped when clock springs forward"));
|
1989-03-10 22:58:42 -05:00
|
|
|
}
|
1989-03-07 19:58:19 -05:00
|
|
|
}
|
1989-03-07 21:51:45 -05:00
|
|
|
/*
|
|
|
|
|
** Entire command line has now been checked.
|
|
|
|
|
*/
|
1989-03-10 20:45:11 -05:00
|
|
|
if (aflag) {
|
1995-01-03 11:08:21 -05:00
|
|
|
#if HAVE_ADJTIME
|
1989-03-11 11:56:53 -05:00
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
tv.tv_sec = (int) adjust;
|
2006-02-16 11:05:14 -05:00
|
|
|
tv.tv_usec = (int) ((adjust - tv.tv_sec) * 1000000L);
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
if (adjtime(&tv, NULL) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops("adjtime");
|
1995-01-03 11:12:36 -05:00
|
|
|
#endif /* HAVE_ADJTIME */
|
|
|
|
|
#if !HAVE_ADJTIME
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
reset(now + adjust, nflag);
|
1995-01-03 11:18:56 -05:00
|
|
|
#endif /* !HAVE_ADJTIME */
|
1989-03-10 20:45:11 -05:00
|
|
|
/*
|
|
|
|
|
** Sun silently ignores everything else; we follow suit.
|
|
|
|
|
*/
|
2005-12-12 10:46:35 -05:00
|
|
|
exit(retval);
|
1989-03-10 20:45:11 -05:00
|
|
|
}
|
1989-03-10 20:01:20 -05:00
|
|
|
if (dflag || tflag) {
|
1995-01-03 11:08:21 -05:00
|
|
|
#if HAVE_SETTIMEOFDAY == 2
|
1989-03-11 11:56:53 -05:00
|
|
|
struct timezone tz;
|
1989-03-10 20:01:20 -05:00
|
|
|
|
|
|
|
|
if (!dflag || !tflag)
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
if (gettimeofday(NULL, &tz) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops("gettimeofday");
|
1989-03-10 20:01:20 -05:00
|
|
|
if (dflag)
|
1989-03-11 11:56:53 -05:00
|
|
|
tz.tz_dsttime = dsttime;
|
1989-03-10 20:01:20 -05:00
|
|
|
if (tflag)
|
1989-03-11 11:56:53 -05:00
|
|
|
tz.tz_minuteswest = minuteswest;
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
if (settimeofday(NULL, &tz) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops("settimeofday");
|
1995-01-03 11:12:36 -05:00
|
|
|
#endif /* HAVE_SETTIMEOFDAY == 2 */
|
|
|
|
|
#if HAVE_SETTIMEOFDAY != 2
|
2013-08-08 10:18:15 -07:00
|
|
|
(void) dsttime;
|
|
|
|
|
(void) minuteswest;
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: warning: kernel doesn't keep -d/-t information, option ignored\n"));
|
1995-01-03 11:08:21 -05:00
|
|
|
#endif /* HAVE_SETTIMEOFDAY != 2 */
|
1989-03-10 20:01:20 -05:00
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
if (value) {
|
|
|
|
|
reset(t, nflag);
|
|
|
|
|
checkfinal(value, dousg, t, now);
|
|
|
|
|
t = time(NULL);
|
1989-03-11 21:07:04 -05:00
|
|
|
}
|
|
|
|
|
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
display(format, t);
|
|
|
|
|
return retval;
|
1989-03-11 11:56:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-12-03 09:42:13 -05:00
|
|
|
dogmt(void)
|
1989-03-11 11:56:53 -05:00
|
|
|
{
|
1994-12-08 23:48:04 -05:00
|
|
|
static char ** fakeenv;
|
1989-03-11 11:56:53 -05:00
|
|
|
|
1994-12-08 23:48:04 -05:00
|
|
|
if (fakeenv == NULL) {
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register int from;
|
|
|
|
|
register int to;
|
|
|
|
|
register int n;
|
1995-01-06 16:04:10 -05:00
|
|
|
static char tzegmt0[] = "TZ=GMT0";
|
1994-12-08 23:48:04 -05:00
|
|
|
|
|
|
|
|
for (n = 0; environ[n] != NULL; ++n)
|
|
|
|
|
continue;
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
fakeenv = malloc((n + 2) * sizeof *fakeenv);
|
1994-12-08 23:48:04 -05:00
|
|
|
if (fakeenv == NULL) {
|
2014-08-18 19:10:48 -07:00
|
|
|
perror(_("Memory exhausted"));
|
1994-12-08 23:48:04 -05:00
|
|
|
errensure();
|
2005-12-12 10:46:35 -05:00
|
|
|
exit(retval);
|
1994-12-08 23:48:04 -05:00
|
|
|
}
|
|
|
|
|
to = 0;
|
1995-01-06 16:04:10 -05:00
|
|
|
fakeenv[to++] = tzegmt0;
|
1994-12-08 23:48:04 -05:00
|
|
|
for (from = 1; environ[from] != NULL; ++from)
|
|
|
|
|
if (strncmp(environ[from], "TZ=", 3) != 0)
|
|
|
|
|
fakeenv[to++] = environ[from];
|
|
|
|
|
fakeenv[to] = NULL;
|
|
|
|
|
environ = fakeenv;
|
|
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-22 21:06:43 -05:00
|
|
|
#ifdef OLD_TIME
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** We assume we're on a System-V-based system,
|
|
|
|
|
** should use stime,
|
|
|
|
|
** should write System-V-format utmp entries,
|
|
|
|
|
** and don't have network notification to worry about.
|
|
|
|
|
*/
|
|
|
|
|
|
1989-04-10 20:23:10 -04:00
|
|
|
#include "fcntl.h" /* for O_WRONLY, O_APPEND */
|
|
|
|
|
|
1989-03-22 21:06:43 -05:00
|
|
|
/*ARGSUSED*/
|
|
|
|
|
static void
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
reset(time_t newt, bool nflag)
|
1989-03-22 21:06:43 -05:00
|
|
|
{
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register int fid;
|
1989-03-22 21:06:43 -05:00
|
|
|
time_t oldt;
|
|
|
|
|
static struct {
|
|
|
|
|
struct utmp before;
|
|
|
|
|
struct utmp after;
|
|
|
|
|
} s;
|
1996-01-10 16:44:46 -05:00
|
|
|
#if HAVE_UTMPX_H
|
|
|
|
|
static struct {
|
|
|
|
|
struct utmpx before;
|
|
|
|
|
struct utmpx after;
|
|
|
|
|
} sx;
|
|
|
|
|
#endif
|
1989-03-22 21:06:43 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Wouldn't it be great if stime returned the old time?
|
|
|
|
|
*/
|
2014-08-18 19:10:48 -07:00
|
|
|
oldt = time(NULL);
|
1989-03-22 21:06:43 -05:00
|
|
|
if (stime(&newt) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops("stime");
|
1989-03-22 21:06:43 -05:00
|
|
|
s.before.ut_type = OLD_TIME;
|
|
|
|
|
s.before.ut_time = oldt;
|
2014-08-18 19:10:48 -07:00
|
|
|
strcpy(s.before.ut_line, OTIME_MSG);
|
1989-03-22 21:06:43 -05:00
|
|
|
s.after.ut_type = NEW_TIME;
|
|
|
|
|
s.after.ut_time = newt;
|
2014-08-18 19:10:48 -07:00
|
|
|
strcpy(s.after.ut_line, NTIME_MSG);
|
1989-03-22 21:06:43 -05:00
|
|
|
fid = open(WTMP_FILE, O_WRONLY | O_APPEND);
|
|
|
|
|
if (fid < 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file open"));
|
1989-03-22 21:06:43 -05:00
|
|
|
if (write(fid, (char *) &s, sizeof s) != sizeof s)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file write"));
|
1989-03-22 21:06:43 -05:00
|
|
|
if (close(fid) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file close"));
|
1996-01-10 16:44:46 -05:00
|
|
|
#if !HAVE_UTMPX_H
|
1989-03-22 21:06:43 -05:00
|
|
|
pututline(&s.before);
|
|
|
|
|
pututline(&s.after);
|
1996-01-10 16:44:46 -05:00
|
|
|
#endif /* !HAVE_UTMPX_H */
|
|
|
|
|
#if HAVE_UTMPX_H
|
|
|
|
|
sx.before.ut_type = OLD_TIME;
|
|
|
|
|
sx.before.ut_tv.tv_sec = oldt;
|
2014-08-18 19:10:48 -07:00
|
|
|
strcpy(sx.before.ut_line, OTIME_MSG);
|
1996-01-10 16:44:46 -05:00
|
|
|
sx.after.ut_type = NEW_TIME;
|
|
|
|
|
sx.after.ut_tv.tv_sec = newt;
|
2014-08-18 19:10:48 -07:00
|
|
|
strcpy(sx.after.ut_line, NTIME_MSG);
|
2014-08-14 21:27:54 -07:00
|
|
|
#if defined WTMPX_FILE && !SUPPRESS_WTMPX_FILE_UPDATE
|
1996-01-10 16:44:46 -05:00
|
|
|
/* In Solaris 2.5 (and presumably other systems),
|
Don't abuse "`" to mean open quote.
This was appropriate before Unicode, where "`" and "'" often balanced
in visual output, but that's been obsolete for a while.
Overall, single-quote 'like this' instead of `like this', and
double-quote "like this" or (in typeset output) “like this”
instead of ``like this''. While we're at it, fix some glitches
with hyphens versus minus versus en dash versus em dash.
* Makefile ($(MANTXTS)): Use UTF-8 locale to produce *.txt output.
* checktab.awk, tzselect.ksh:
Quote 'like this' in diagnostics, instead of `like this'.
* date.1, newctime.3, newtzset.3, time2posix.3, zic.8 (q, lq, rq):
New macros. Use them for better double-quoting in output.
* workman.sh: Tell Perl that its stdin and stdout are UTF-8.
* NEWS: Document this.
2014-06-15 13:27:37 -07:00
|
|
|
'date' does not update /var/adm/wtmpx.
|
1996-01-10 16:44:46 -05:00
|
|
|
This must be a bug. If you'd like to reproduce the bug,
|
|
|
|
|
define SUPPRESS_WTMPX_FILE_UPDATE to be nonzero. */
|
|
|
|
|
fid = open(WTMPX_FILE, O_WRONLY | O_APPEND);
|
|
|
|
|
if (fid < 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file open"));
|
1996-01-10 16:44:46 -05:00
|
|
|
if (write(fid, (char *) &sx, sizeof sx) != sizeof sx)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file write"));
|
1996-01-10 16:44:46 -05:00
|
|
|
if (close(fid) != 0)
|
1996-02-21 15:47:21 -05:00
|
|
|
oops(_("log file close"));
|
2014-08-14 21:27:54 -07:00
|
|
|
# endif
|
1996-01-10 16:44:46 -05:00
|
|
|
pututxline(&sx.before);
|
|
|
|
|
pututxline(&sx.after);
|
|
|
|
|
#endif /* HAVE_UTMPX_H */
|
1989-03-22 21:06:43 -05:00
|
|
|
}
|
|
|
|
|
|
1993-11-22 12:58:06 -05:00
|
|
|
#endif /* defined OLD_TIME */
|
|
|
|
|
#ifndef OLD_TIME
|
1989-03-22 21:06:43 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** We assume we're on a BSD-based system,
|
|
|
|
|
** should use settimeofday,
|
|
|
|
|
** should write BSD-format utmp entries (using logwtmp),
|
|
|
|
|
** and may get to worry about network notification.
|
|
|
|
|
** The "time name" changes between 4.3-tahoe and 4.4;
|
|
|
|
|
** we include sys/param.h to determine which we should use.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef TIME_NAME
|
|
|
|
|
#include "sys/param.h"
|
|
|
|
|
#ifdef BSD4_4
|
|
|
|
|
#define TIME_NAME "date"
|
1993-11-22 12:58:06 -05:00
|
|
|
#endif /* defined BSD4_4 */
|
|
|
|
|
#ifndef BSD4_4
|
1989-03-22 21:06:43 -05:00
|
|
|
#define TIME_NAME ""
|
|
|
|
|
#endif /* !defined BSD4_4 */
|
|
|
|
|
#endif /* !defined TIME_NAME */
|
|
|
|
|
|
|
|
|
|
#include "syslog.h"
|
|
|
|
|
#include "sys/socket.h"
|
|
|
|
|
#include "netinet/in.h"
|
|
|
|
|
#include "netdb.h"
|
|
|
|
|
#define TSPTYPES
|
|
|
|
|
#include "protocols/timed.h"
|
|
|
|
|
|
1996-01-10 16:44:46 -05:00
|
|
|
extern int logwtmp();
|
|
|
|
|
|
1995-01-03 11:08:21 -05:00
|
|
|
#if HAVE_SETTIMEOFDAY == 1
|
|
|
|
|
#define settimeofday(t, tz) (settimeofday)(t)
|
1995-01-03 11:26:22 -05:00
|
|
|
#endif /* HAVE_SETTIMEOFDAY == 1 */
|
1995-01-03 11:08:21 -05:00
|
|
|
|
More C modernization.
* Makefile (typecheck): Add -D__time_t_defined to CFLAGS,
for glibc 2.15.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Omit 'register', as it adds no value these days. See Christos Zoulas in
<http://mm.icann.org/pipermail/tz/2012-October/018376.html>.
* date.c (netsettime) [TSP_SETDATE]: Add forward decl.
Don't rely on implicit int. Now static. Use NULL, not 0.
* zdump.c: Include "limits.h".
(absolute_min_time, absolute_max_time): Compute at compile-time,
as the run-time tests relied on undefined behavior.
(checkabsolutes): Rename from setabsolutes. Just check, since
there's nothing to set now. All uses changed.
2012-10-26 00:48:01 -07:00
|
|
|
#ifdef TSP_SETDATE
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
static bool netsettime(struct timeval);
|
More C modernization.
* Makefile (typecheck): Add -D__time_t_defined to CFLAGS,
for glibc 2.15.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Omit 'register', as it adds no value these days. See Christos Zoulas in
<http://mm.icann.org/pipermail/tz/2012-October/018376.html>.
* date.c (netsettime) [TSP_SETDATE]: Add forward decl.
Don't rely on implicit int. Now static. Use NULL, not 0.
* zdump.c: Include "limits.h".
(absolute_min_time, absolute_max_time): Compute at compile-time,
as the run-time tests relied on undefined behavior.
(checkabsolutes): Rename from setabsolutes. Just check, since
there's nothing to set now. All uses changed.
2012-10-26 00:48:01 -07:00
|
|
|
#endif
|
|
|
|
|
|
1989-03-11 21:07:04 -05:00
|
|
|
#ifndef TSP_SETDATE
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
|
#endif /* !defined TSP_SETDATE */
|
1989-03-11 11:56:53 -05:00
|
|
|
static void
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
reset(time_t newt, bool nflag)
|
1989-03-11 11:56:53 -05:00
|
|
|
{
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register const char * username;
|
1989-03-11 11:56:53 -05:00
|
|
|
static struct timeval tv; /* static so tv_usec is 0 */
|
|
|
|
|
|
1989-03-05 17:23:15 -05:00
|
|
|
username = getlogin();
|
1989-03-07 21:51:45 -05:00
|
|
|
if (username == NULL || *username == '\0') /* single-user or no tty */
|
1989-03-05 17:23:15 -05:00
|
|
|
username = "root";
|
1989-03-22 21:06:43 -05:00
|
|
|
tv.tv_sec = newt;
|
1989-03-10 12:02:03 -05:00
|
|
|
#ifdef TSP_SETDATE
|
1989-03-10 19:00:37 -05:00
|
|
|
if (nflag || !netsettime(tv))
|
1989-03-09 13:20:49 -05:00
|
|
|
#endif /* defined TSP_SETDATE */
|
1989-03-10 19:00:37 -05:00
|
|
|
{
|
1989-03-22 21:06:43 -05:00
|
|
|
/*
|
1989-04-07 17:31:22 -04:00
|
|
|
** "old" entry is always written, for compatibility.
|
1989-03-22 21:06:43 -05:00
|
|
|
*/
|
|
|
|
|
logwtmp("|", TIME_NAME, "");
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
if (settimeofday(&tv, NULL) == 0) {
|
1989-03-22 21:06:43 -05:00
|
|
|
logwtmp("{", TIME_NAME, ""); /* } */
|
1996-02-21 15:47:21 -05:00
|
|
|
syslog(LOG_AUTH | LOG_NOTICE, _("date set by %s"),
|
1989-03-10 19:00:37 -05:00
|
|
|
username);
|
1996-02-21 15:47:21 -05:00
|
|
|
} else oops("settimeofday");
|
1989-03-10 19:00:37 -05:00
|
|
|
}
|
1989-03-07 19:58:19 -05:00
|
|
|
}
|
1989-03-07 14:14:29 -05:00
|
|
|
|
1989-03-22 21:06:43 -05:00
|
|
|
#endif /* !defined OLD_TIME */
|
|
|
|
|
|
1989-03-10 22:05:54 -05:00
|
|
|
static void
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
wildinput(const char *const item, const char *const value,
|
|
|
|
|
const char *const reason)
|
1989-03-10 22:05:54 -05:00
|
|
|
{
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: bad command line %s \"%s\", %s\n"),
|
1989-03-10 22:05:54 -05:00
|
|
|
item, value, reason);
|
|
|
|
|
usage();
|
|
|
|
|
}
|
|
|
|
|
|
1989-03-10 19:07:58 -05:00
|
|
|
static void
|
2007-11-08 09:21:56 -05:00
|
|
|
errensure(void)
|
1989-03-10 19:07:58 -05:00
|
|
|
{
|
|
|
|
|
if (retval == EXIT_SUCCESS)
|
|
|
|
|
retval = EXIT_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-16 22:02:27 -07:00
|
|
|
static const char * ATTRIBUTE_PURE
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
nondigit(register const char *cp)
|
1989-03-09 13:20:49 -05:00
|
|
|
{
|
1995-10-30 10:19:59 -05:00
|
|
|
while (is_digit(*cp))
|
1989-03-09 13:20:49 -05:00
|
|
|
++cp;
|
|
|
|
|
return cp;
|
|
|
|
|
}
|
1989-03-07 21:51:45 -05:00
|
|
|
|
|
|
|
|
static void
|
2007-11-08 09:21:56 -05:00
|
|
|
usage(void)
|
1989-03-06 04:26:22 -05:00
|
|
|
{
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
_("date: usage: date [-u] [-c] [-r seconds] [-n]"
|
|
|
|
|
" [-d dst] [-t min-west] [-a sss.fff]"
|
|
|
|
|
" [[yyyy]mmddhhmm[yyyy][.ss]] [+format]\n"));
|
1989-03-10 19:07:58 -05:00
|
|
|
errensure();
|
2005-12-12 10:46:35 -05:00
|
|
|
exit(retval);
|
1989-03-06 04:26:22 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-08 18:42:17 -05:00
|
|
|
static void
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
oops(const char *const string)
|
1989-03-08 18:42:17 -05:00
|
|
|
{
|
1996-02-21 15:47:21 -05:00
|
|
|
int e = errno;
|
|
|
|
|
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr, _("date: error: "));
|
1996-02-21 15:47:21 -05:00
|
|
|
errno = e;
|
2014-08-18 19:10:48 -07:00
|
|
|
perror(string);
|
1989-03-10 19:07:58 -05:00
|
|
|
errensure();
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
display(NULL, time(NULL));
|
|
|
|
|
exit(retval);
|
1989-03-08 18:42:17 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-06 04:26:22 -05:00
|
|
|
static void
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
display(const char *const format, time_t const now)
|
1989-03-06 04:26:22 -05:00
|
|
|
{
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
struct tm *tmp;
|
1989-03-06 04:26:22 -05:00
|
|
|
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
tmp = localtime(&now);
|
|
|
|
|
if (!tmp) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
_("date: error: time out of range\n"));
|
|
|
|
|
errensure();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
timeout(stdout, format ? format : "%+", tmp);
|
2014-08-18 19:10:48 -07:00
|
|
|
putchar('\n');
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
fflush(stderr);
|
1989-03-07 14:14:29 -05:00
|
|
|
if (ferror(stdout) || ferror(stderr)) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: couldn't write results\n"));
|
1989-03-10 19:07:58 -05:00
|
|
|
errensure();
|
1989-03-07 14:14:29 -05:00
|
|
|
}
|
1989-03-06 04:26:22 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-11 21:07:04 -05:00
|
|
|
#define INCR 1024
|
|
|
|
|
|
1989-03-10 19:28:00 -05:00
|
|
|
static void
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
timeout(FILE *const fp, const char *const format, const struct tm *tmp)
|
1989-03-10 19:28:00 -05:00
|
|
|
{
|
1989-03-11 21:07:04 -05:00
|
|
|
char * cp;
|
1994-06-04 17:05:46 -04:00
|
|
|
size_t result;
|
|
|
|
|
size_t size;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
struct tm tm;
|
1989-03-10 19:28:00 -05:00
|
|
|
|
1989-03-10 20:06:15 -05:00
|
|
|
if (*format == '\0')
|
|
|
|
|
return;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
if (!tmp) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr, _("date: error: time out of range\n"));
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
errensure();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
tm = *tmp;
|
|
|
|
|
tmp = &tm;
|
1989-03-11 21:07:04 -05:00
|
|
|
size = INCR;
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
cp = malloc(size);
|
1989-03-11 21:07:04 -05:00
|
|
|
for ( ; ; ) {
|
|
|
|
|
if (cp == NULL) {
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: error: can't get memory\n"));
|
1989-03-11 21:07:04 -05:00
|
|
|
errensure();
|
2005-12-12 10:46:35 -05:00
|
|
|
exit(retval);
|
1989-03-11 21:07:04 -05:00
|
|
|
}
|
2000-04-20 15:36:18 -04:00
|
|
|
cp[0] = '\1';
|
1989-03-11 21:07:04 -05:00
|
|
|
result = strftime(cp, size, format, tmp);
|
2000-04-20 15:36:18 -04:00
|
|
|
if (result != 0 || cp[0] == '\0')
|
1989-03-11 21:07:04 -05:00
|
|
|
break;
|
|
|
|
|
size += INCR;
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
cp = realloc(cp, size);
|
1989-03-10 19:28:00 -05:00
|
|
|
}
|
2014-08-18 19:10:48 -07:00
|
|
|
fwrite(cp, 1, result, fp);
|
1989-03-11 21:07:04 -05:00
|
|
|
free(cp);
|
1989-03-10 19:28:00 -05:00
|
|
|
}
|
|
|
|
|
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
static bool
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
sametm(register const struct tm *const atmp,
|
|
|
|
|
register const struct tm *const btmp)
|
1989-03-10 22:58:42 -05:00
|
|
|
{
|
2011-01-25 16:12:48 -05:00
|
|
|
return atmp->tm_year == btmp->tm_year &&
|
|
|
|
|
atmp->tm_mon == btmp->tm_mon &&
|
|
|
|
|
atmp->tm_mday == btmp->tm_mday &&
|
|
|
|
|
atmp->tm_hour == btmp->tm_hour &&
|
|
|
|
|
atmp->tm_min == btmp->tm_min &&
|
|
|
|
|
atmp->tm_sec == btmp->tm_sec;
|
1989-03-10 22:58:42 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-07 14:14:29 -05:00
|
|
|
/*
|
1989-03-10 22:58:42 -05:00
|
|
|
** convert --
|
1989-03-07 22:57:44 -05:00
|
|
|
** convert user's input into a time_t.
|
|
|
|
|
*/
|
1989-03-07 14:14:29 -05:00
|
|
|
|
1993-11-22 12:39:02 -05:00
|
|
|
#define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2;
|
1989-03-05 17:23:15 -05:00
|
|
|
|
1989-03-07 14:14:29 -05:00
|
|
|
static time_t
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
convert(char const *value, bool dousg, time_t t)
|
1989-03-05 17:23:15 -05:00
|
|
|
{
|
Restore 'register'.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Restore the uses of 'register', reverting that part of the
"More C modernization" patch. See Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2012-October/018385.html>.
2012-10-26 17:37:42 -07:00
|
|
|
register const char * cp;
|
|
|
|
|
register const char * dotp;
|
|
|
|
|
register int cent, year_in_cent, month, hour, day, mins, secs;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
struct tm tm, outtm, *tmp;
|
1989-03-10 22:58:42 -05:00
|
|
|
time_t outt;
|
|
|
|
|
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
tmp = localtime(&t);
|
|
|
|
|
if (!tmp)
|
|
|
|
|
return -1;
|
|
|
|
|
tm = *tmp;
|
2004-11-08 10:48:47 -05:00
|
|
|
#define DIVISOR 100
|
|
|
|
|
year_in_cent = tm.tm_year % DIVISOR + TM_YEAR_BASE % DIVISOR;
|
|
|
|
|
cent = tm.tm_year / DIVISOR + TM_YEAR_BASE / DIVISOR +
|
|
|
|
|
year_in_cent / DIVISOR;
|
|
|
|
|
year_in_cent %= DIVISOR;
|
|
|
|
|
if (year_in_cent < 0) {
|
|
|
|
|
year_in_cent += DIVISOR;
|
|
|
|
|
--cent;
|
|
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
month = tm.tm_mon + 1;
|
|
|
|
|
day = tm.tm_mday;
|
|
|
|
|
hour = tm.tm_hour;
|
|
|
|
|
mins = tm.tm_min;
|
1989-03-11 21:07:04 -05:00
|
|
|
secs = 0;
|
1989-03-11 11:56:53 -05:00
|
|
|
|
1989-03-11 21:07:04 -05:00
|
|
|
dotp = strchr(value, '.');
|
|
|
|
|
for (cp = value; *cp != '\0'; ++cp)
|
1995-10-30 10:19:59 -05:00
|
|
|
if (!is_digit(*cp) && cp != dotp)
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("time"), value, _("contains a nondigit"));
|
1989-03-11 21:07:04 -05:00
|
|
|
|
|
|
|
|
if (dotp == NULL)
|
|
|
|
|
dotp = strchr(value, '\0');
|
|
|
|
|
else {
|
|
|
|
|
cp = dotp + 1;
|
1989-03-10 23:29:33 -05:00
|
|
|
if (strlen(cp) != 2)
|
1996-02-21 15:47:21 -05:00
|
|
|
wildinput(_("time"), value,
|
|
|
|
|
_("seconds part is not two digits"));
|
1989-03-11 11:56:53 -05:00
|
|
|
secs = ATOI2(cp);
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
|
|
|
|
|
cp = value;
|
1989-03-11 21:07:04 -05:00
|
|
|
switch (dotp - cp) {
|
1989-03-07 14:14:29 -05:00
|
|
|
default:
|
2005-01-31 14:06:04 -05:00
|
|
|
wildinput(_("time"), value,
|
|
|
|
|
_("main part is wrong length"));
|
1989-04-05 03:37:47 -04:00
|
|
|
case 12:
|
|
|
|
|
if (!dousg) {
|
|
|
|
|
cent = ATOI2(cp);
|
|
|
|
|
year_in_cent = ATOI2(cp);
|
|
|
|
|
}
|
1989-04-04 16:13:08 -04:00
|
|
|
month = ATOI2(cp);
|
|
|
|
|
day = ATOI2(cp);
|
|
|
|
|
hour = ATOI2(cp);
|
|
|
|
|
mins = ATOI2(cp);
|
1989-04-05 03:37:47 -04:00
|
|
|
if (dousg) {
|
|
|
|
|
cent = ATOI2(cp);
|
|
|
|
|
year_in_cent = ATOI2(cp);
|
|
|
|
|
}
|
1989-04-04 16:13:08 -04:00
|
|
|
break;
|
1989-03-10 23:29:33 -05:00
|
|
|
case 8: /* mmddhhmm */
|
1989-03-11 11:56:53 -05:00
|
|
|
month = ATOI2(cp);
|
1989-03-10 23:29:33 -05:00
|
|
|
/* fall through to. . . */
|
|
|
|
|
case 6: /* ddhhmm */
|
1989-03-11 11:56:53 -05:00
|
|
|
day = ATOI2(cp);
|
1989-03-10 23:29:33 -05:00
|
|
|
/* fall through to. . . */
|
|
|
|
|
case 4: /* hhmm */
|
1989-03-11 11:56:53 -05:00
|
|
|
hour = ATOI2(cp);
|
|
|
|
|
mins = ATOI2(cp);
|
1989-03-10 23:29:33 -05:00
|
|
|
break;
|
1989-03-11 11:56:53 -05:00
|
|
|
case 10:
|
|
|
|
|
if (!dousg) {
|
|
|
|
|
year_in_cent = ATOI2(cp);
|
|
|
|
|
}
|
|
|
|
|
month = ATOI2(cp);
|
|
|
|
|
day = ATOI2(cp);
|
|
|
|
|
hour = ATOI2(cp);
|
|
|
|
|
mins = ATOI2(cp);
|
1989-03-10 22:58:42 -05:00
|
|
|
if (dousg) {
|
1989-03-11 11:56:53 -05:00
|
|
|
year_in_cent = ATOI2(cp);
|
1989-03-10 22:58:42 -05:00
|
|
|
}
|
|
|
|
|
break;
|
1989-03-07 14:14:29 -05:00
|
|
|
}
|
1989-03-11 11:56:53 -05:00
|
|
|
|
|
|
|
|
tm.tm_year = cent * 100 + year_in_cent - TM_YEAR_BASE;
|
|
|
|
|
tm.tm_mon = month - 1;
|
|
|
|
|
tm.tm_mday = day;
|
|
|
|
|
tm.tm_hour = hour;
|
|
|
|
|
tm.tm_min = mins;
|
|
|
|
|
tm.tm_sec = secs;
|
1989-03-10 23:29:33 -05:00
|
|
|
tm.tm_isdst = -1;
|
1989-03-10 22:58:42 -05:00
|
|
|
outtm = tm;
|
|
|
|
|
outt = mktime(&outtm);
|
2011-01-25 16:12:48 -05:00
|
|
|
return sametm(&tm, &outtm) ? outt : -1;
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-11 21:07:04 -05:00
|
|
|
/*
|
1994-06-04 17:09:44 -04:00
|
|
|
** Code from here on out is either based on code provided by UCB
|
1989-03-11 21:07:04 -05:00
|
|
|
** or is only called just before the program exits.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Check for iffy input.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
checkfinal(char const *value, bool didusg, time_t t, time_t oldnow)
|
1989-03-11 21:07:04 -05:00
|
|
|
{
|
|
|
|
|
time_t othert;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
struct tm tm, *tmp;
|
1989-03-11 21:07:04 -05:00
|
|
|
struct tm othertm;
|
Port to NetBSD, where, e.g., 'time_t' is wider than 'long'.
I audited the code and fixed as many width-asssumptions as I could
find, including several places where the code assumed that 'time_t'
was no wider than 'long'; this assumption is not true on 32-bit
NetBSD platforms. This caught every problem that is already fixed
in the NetBSD zic.c, and caught quite a few more.
* Makefile: Add comments re HAVE_DOS_FILE_NAMES and HAVE_INTTYPES_H.
* date.c (checkfinal, netsettime): Don't use 'long' where 'int' will do.
* difftime.c (difftime): Mark with ATTRIBUTE_CONST.
Use uintmax_t, not unsigned long, for the widest unsigned integer type.
Use long double, not double, if time_t is wider than uintmax_t;
this can in theory help on nonstandard platforms, such as GCC
with 64-bit uintmax_t and 128-bit __int128_t.
* localtime.c (struct ttinfo.tt_gmtoff, struct rule.r_time)
(detzcode, getsecs, getoffset, gmtsub, localsub, increment_overflow32)
(normalize_overflow32, time1, time2, timesub, transtime, tzparse)
(time2sub, timeoff, gtime):
* tzfile.h (SECSPERDAY):
* zdump.c (SECSPERDAY):
* zic.c (convert, puttzcode):
Use int_fast32_t, not long, when all we care is that values up to
2**31 can be stored. This doesn't fix any bugs, but it allows
more opportunity for compiler optimization.
(struct lsinfo.ls_corr, timesub, leapcorr):
Use int_fast64_t, not long, when values up to 2**63 can be stored.
(timesub): Make it clearer when we are truncating 0.5 to 0.
(increment_overflow32): Rename from long_increment_overflow.
All uses changed.
(normalize_overflow32): Rename from long_normalize_overflow.
All uses changed.
* private.h (HAVE_INTTYPES_H, ATTRIBUTE_CONST): New macros.
Include <inttypes.h> if HAVE_INTTYPES_H.
(INT_FAST64_MIN, INT_FAST64_MAX, SCNdFAST64, int_fast32_t, PRIdMAX)
(uintmax_t, PRIuMAX, _Noreturn):
Define to reasonable values if it's an older compiler.
* scheck.c (scheck): Add support for arbitrary formats, such as
those that SCNdFAST64 can expand to, at the price of no longer
supporting weird conversion specs like "%[%]".
* strftime.c (_fmt): Use intmax_t and uintmax_t to format time_t,
not long and unsigned long.
* zdump.c (int_fast32_t, intmax_t, PRIdMAX, SCNdMAX):
Define for pre-C99 compilers, like private.h does.
(delta, yeartot, main): Use intmax_t, not long.
(hunt): Use time_t, not long, since the diff must be nonnegative.
(tformat): Allow for time_t wider than long.
* zic.c (ZIC_MIN, ZIC_MAX, SCNdZIC): New macros.
(OFFSET_STRLEN_MAXIMUM, RULE_STRLEN_MAXIMUM): Remove.
(struct rule): Make r_loyear, r_hiyear, r_tod, r_stdoff, z_gmtoff,
z_stdoff zic_t, not long.
(addtype, gethms, oadd, rpytime, tadd, gmtoffs, corr, inleap)
(stringoffset, stringrule, outzone, addtype, adjleap, rpytime)
(LDAYSPERWEEK):
Use zic_t, not long.
(leapminyear, leapmaxyear, min_year, max_year, rulesub, updateminmax)
(outzone, rpytime):
Use zic_t, not int.
(usage): Now _Noreturn.
(main): Use S_IWGRP, not 'unix', to determine whether to call umask.
(writezone): Omit unnecessary cast.
(mkdirs): Use HAVE_DOS_FILE_NAMES, not 'unix', to determine
whether to parse DOS file anmes.
(eitol): Remove; no longer needed.
2013-05-27 21:26:18 -07:00
|
|
|
register int pass, offset;
|
1989-03-30 22:02:45 -05:00
|
|
|
|
1989-03-11 21:07:04 -05:00
|
|
|
/*
|
|
|
|
|
** See if there's both a USG and a BSD interpretation.
|
|
|
|
|
*/
|
|
|
|
|
othert = convert(value, !didusg, oldnow);
|
|
|
|
|
if (othert != -1 && othert != t)
|
1996-02-21 15:47:21 -05:00
|
|
|
iffy(t, othert, value, _("year could be at start or end"));
|
1989-03-11 21:07:04 -05:00
|
|
|
/*
|
|
|
|
|
** See if there's both a DST and a STD version.
|
|
|
|
|
*/
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
tmp = localtime(&t);
|
|
|
|
|
if (!tmp)
|
|
|
|
|
iffy(t, othert, value, _("time out of range"));
|
|
|
|
|
othertm = tm = *tmp;
|
1989-03-11 21:07:04 -05:00
|
|
|
othertm.tm_isdst = !tm.tm_isdst;
|
|
|
|
|
othert = mktime(&othertm);
|
|
|
|
|
if (othert != -1 && othertm.tm_isdst != tm.tm_isdst &&
|
2011-01-25 16:12:48 -05:00
|
|
|
sametm(&tm, &othertm))
|
1989-03-11 21:07:04 -05:00
|
|
|
iffy(t, othert, value,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("both standard and summer time versions exist"));
|
1989-03-11 21:07:04 -05:00
|
|
|
/*
|
|
|
|
|
** Final check.
|
|
|
|
|
**
|
|
|
|
|
** If a jurisdiction shifts time *without* shifting whether time is
|
|
|
|
|
** summer or standard (as Hawaii, the United Kingdom, and Saudi Arabia
|
|
|
|
|
** have done), routine checks for iffy times may not work.
|
|
|
|
|
** So we perform this final check, deferring it until after the time has
|
2014-06-17 18:46:31 -07:00
|
|
|
** been set; it may take a while, and we don't want to introduce an unnecessary
|
1989-03-11 21:07:04 -05:00
|
|
|
** lag between the time the user enters their command and the time that
|
|
|
|
|
** stime/settimeofday is called.
|
1989-03-30 22:02:45 -05:00
|
|
|
**
|
1993-11-22 12:58:06 -05:00
|
|
|
** We just check nearby times to see if any have the same representation
|
1989-03-11 21:07:04 -05:00
|
|
|
** as the time that convert returned. We work our way out from the center
|
2014-06-17 18:46:31 -07:00
|
|
|
** for quick response in solar time situations. We only handle common cases:
|
1989-03-11 21:07:04 -05:00
|
|
|
** offsets of at most a minute, and offsets of exact numbers of minutes
|
|
|
|
|
** and at most an hour.
|
|
|
|
|
*/
|
|
|
|
|
for (offset = 1; offset <= 60; ++offset)
|
|
|
|
|
for (pass = 1; pass <= 4; ++pass) {
|
|
|
|
|
if (pass == 1)
|
|
|
|
|
othert = t + offset;
|
|
|
|
|
else if (pass == 2)
|
|
|
|
|
othert = t - offset;
|
|
|
|
|
else if (pass == 3)
|
|
|
|
|
othert = t + 60 * offset;
|
|
|
|
|
else othert = t - 60 * offset;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
tmp = localtime(&othert);
|
|
|
|
|
if (!tmp)
|
|
|
|
|
iffy(t, othert, value,
|
|
|
|
|
_("time out of range"));
|
|
|
|
|
othertm = *tmp;
|
2011-01-25 16:12:48 -05:00
|
|
|
if (sametm(&tm, &othertm))
|
1989-03-11 21:07:04 -05:00
|
|
|
iffy(t, othert, value,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("multiple matching times exist"));
|
1989-03-11 21:07:04 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-16 11:05:00 -05:00
|
|
|
iffy(const time_t thist, const time_t thatt,
|
|
|
|
|
const char * const value, const char * const reason)
|
1989-03-11 21:07:04 -05:00
|
|
|
{
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
struct tm *tmp;
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
bool dst;
|
1989-03-11 21:07:04 -05:00
|
|
|
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr, _("date: warning: ambiguous time \"%s\", %s.\n"),
|
1989-03-11 21:07:04 -05:00
|
|
|
value, reason);
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
tmp = gmtime(&thist);
|
1989-03-11 21:07:04 -05:00
|
|
|
/*
|
|
|
|
|
** Avoid running afoul of SCCS!
|
|
|
|
|
*/
|
1996-02-21 15:47:21 -05:00
|
|
|
timeout(stderr, _("Time was set as if you used\n\tdate -u %m%d%H\
|
|
|
|
|
%M\
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
%Y.%S\n"), tmp);
|
|
|
|
|
tmp = localtime(&thist);
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
dst = tmp && tmp->tm_isdst;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
timeout(stderr, _("to get %c"), tmp);
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr, _(" (%s). Use\n"),
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
dst ? _("summer time") : _("standard time"));
|
|
|
|
|
tmp = gmtime(&thatt);
|
1996-02-21 15:47:21 -05:00
|
|
|
timeout(stderr, _("\tdate -u %m%d%H\
|
|
|
|
|
%M\
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
%Y.%S\n"), tmp);
|
|
|
|
|
tmp = localtime(&thatt);
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
dst = tmp && tmp->tm_isdst;
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
timeout(stderr, _("to get %c"), tmp);
|
2014-08-18 19:10:48 -07:00
|
|
|
fprintf(stderr, _(" (%s).\n"),
|
Add FreeBSD-style -r option to 'date'.
* date.1: Document -r.
* date.c (main, usage): Support -r.
(main, reset): Remove EBUG code.
(display): New argument NOW. Do not exit; that's now the
caller's responsibility. All callers changed.
(display, timeout, convert, checkfinal, iffy):
Don't assume that localtime and gmtime succeed.
This prevents a core dump for, e.g., 'date -r 0xffffffffffffffff'.
* private.h: Include float.h.
(strtoimax): New macro, for pre-C99 systems that lack strtoimax.
(time_t_min, time_t_max): New constants, from zdump, with
different names to avoid a clash when zdump.c includes private.h.
2013-08-09 00:40:14 -07:00
|
|
|
dst ? _("summer time") : _("standard time"));
|
1989-03-11 21:07:04 -05:00
|
|
|
errensure();
|
2005-12-12 10:46:35 -05:00
|
|
|
exit(retval);
|
1989-03-11 21:07:04 -05:00
|
|
|
}
|
|
|
|
|
|
1989-03-09 13:20:49 -05:00
|
|
|
#ifdef TSP_SETDATE
|
1993-11-22 12:39:02 -05:00
|
|
|
#define WAITACK 2 /* seconds */
|
|
|
|
|
#define WAITDATEACK 5 /* seconds */
|
1989-03-05 17:23:15 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Set the date in the machines controlled by timedaemons
|
1993-11-22 12:34:55 -05:00
|
|
|
* by communicating the new date to the local timedaemon.
|
1989-03-05 17:23:15 -05:00
|
|
|
* 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.
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
* Return true on success.
|
1989-03-05 17:23:15 -05:00
|
|
|
*/
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
static bool
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
netsettime(struct timeval ntv)
|
1989-03-05 17:23:15 -05:00
|
|
|
{
|
Port to NetBSD, where, e.g., 'time_t' is wider than 'long'.
I audited the code and fixed as many width-asssumptions as I could
find, including several places where the code assumed that 'time_t'
was no wider than 'long'; this assumption is not true on 32-bit
NetBSD platforms. This caught every problem that is already fixed
in the NetBSD zic.c, and caught quite a few more.
* Makefile: Add comments re HAVE_DOS_FILE_NAMES and HAVE_INTTYPES_H.
* date.c (checkfinal, netsettime): Don't use 'long' where 'int' will do.
* difftime.c (difftime): Mark with ATTRIBUTE_CONST.
Use uintmax_t, not unsigned long, for the widest unsigned integer type.
Use long double, not double, if time_t is wider than uintmax_t;
this can in theory help on nonstandard platforms, such as GCC
with 64-bit uintmax_t and 128-bit __int128_t.
* localtime.c (struct ttinfo.tt_gmtoff, struct rule.r_time)
(detzcode, getsecs, getoffset, gmtsub, localsub, increment_overflow32)
(normalize_overflow32, time1, time2, timesub, transtime, tzparse)
(time2sub, timeoff, gtime):
* tzfile.h (SECSPERDAY):
* zdump.c (SECSPERDAY):
* zic.c (convert, puttzcode):
Use int_fast32_t, not long, when all we care is that values up to
2**31 can be stored. This doesn't fix any bugs, but it allows
more opportunity for compiler optimization.
(struct lsinfo.ls_corr, timesub, leapcorr):
Use int_fast64_t, not long, when values up to 2**63 can be stored.
(timesub): Make it clearer when we are truncating 0.5 to 0.
(increment_overflow32): Rename from long_increment_overflow.
All uses changed.
(normalize_overflow32): Rename from long_normalize_overflow.
All uses changed.
* private.h (HAVE_INTTYPES_H, ATTRIBUTE_CONST): New macros.
Include <inttypes.h> if HAVE_INTTYPES_H.
(INT_FAST64_MIN, INT_FAST64_MAX, SCNdFAST64, int_fast32_t, PRIdMAX)
(uintmax_t, PRIuMAX, _Noreturn):
Define to reasonable values if it's an older compiler.
* scheck.c (scheck): Add support for arbitrary formats, such as
those that SCNdFAST64 can expand to, at the price of no longer
supporting weird conversion specs like "%[%]".
* strftime.c (_fmt): Use intmax_t and uintmax_t to format time_t,
not long and unsigned long.
* zdump.c (int_fast32_t, intmax_t, PRIdMAX, SCNdMAX):
Define for pre-C99 compilers, like private.h does.
(delta, yeartot, main): Use intmax_t, not long.
(hunt): Use time_t, not long, since the diff must be nonnegative.
(tformat): Allow for time_t wider than long.
* zic.c (ZIC_MIN, ZIC_MAX, SCNdZIC): New macros.
(OFFSET_STRLEN_MAXIMUM, RULE_STRLEN_MAXIMUM): Remove.
(struct rule): Make r_loyear, r_hiyear, r_tod, r_stdoff, z_gmtoff,
z_stdoff zic_t, not long.
(addtype, gethms, oadd, rpytime, tadd, gmtoffs, corr, inleap)
(stringoffset, stringrule, outzone, addtype, adjleap, rpytime)
(LDAYSPERWEEK):
Use zic_t, not long.
(leapminyear, leapmaxyear, min_year, max_year, rulesub, updateminmax)
(outzone, rpytime):
Use zic_t, not int.
(usage): Now _Noreturn.
(main): Use S_IWGRP, not 'unix', to determine whether to call umask.
(writezone): Omit unnecessary cast.
(mkdirs): Use HAVE_DOS_FILE_NAMES, not 'unix', to determine
whether to parse DOS file anmes.
(eitol): Remove; no longer needed.
2013-05-27 21:26:18 -07:00
|
|
|
int s, length, port, timed_ack, found, err, waittime;
|
1989-03-05 17:23:15 -05:00
|
|
|
fd_set ready;
|
|
|
|
|
struct timeval tout;
|
|
|
|
|
struct servent *sp;
|
|
|
|
|
struct tsp msg;
|
|
|
|
|
struct sockaddr_in sin, dest, from;
|
|
|
|
|
|
|
|
|
|
sp = getservbyname("timed", "udp");
|
More C modernization.
* Makefile (typecheck): Add -D__time_t_defined to CFLAGS,
for glibc 2.15.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Omit 'register', as it adds no value these days. See Christos Zoulas in
<http://mm.icann.org/pipermail/tz/2012-October/018376.html>.
* date.c (netsettime) [TSP_SETDATE]: Add forward decl.
Don't rely on implicit int. Now static. Use NULL, not 0.
* zdump.c: Include "limits.h".
(absolute_min_time, absolute_max_time): Compute at compile-time,
as the run-time tests relied on undefined behavior.
(checkabsolutes): Rename from setabsolutes. Just check, since
there's nothing to set now. All uses changed.
2012-10-26 00:48:01 -07:00
|
|
|
if (! sp) {
|
1996-02-21 15:47:21 -05:00
|
|
|
fputs(_("udp/timed: unknown service\n"), stderr);
|
1989-03-05 17:23:15 -05:00
|
|
|
retval = 2;
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
return false;
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
|
|
|
|
dest.sin_port = sp->s_port;
|
|
|
|
|
dest.sin_family = AF_INET;
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
dest.sin_addr.s_addr = htonl(INADDR_ANY);
|
1989-03-05 17:23:15 -05:00
|
|
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (s < 0) {
|
|
|
|
|
if (errno != EPROTONOSUPPORT)
|
|
|
|
|
perror("date: socket");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
bzero((char *)&sin, sizeof (sin));
|
|
|
|
|
sin.sin_family = AF_INET;
|
|
|
|
|
for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
sin.sin_port = htons(port);
|
1989-03-05 17:23:15 -05:00
|
|
|
if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0)
|
|
|
|
|
break;
|
|
|
|
|
if (errno != EADDRINUSE) {
|
|
|
|
|
if (errno != EADDRNOTAVAIL)
|
|
|
|
|
perror("date: bind");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (port == IPPORT_RESERVED / 2) {
|
1996-02-21 15:47:21 -05:00
|
|
|
fputs(_("date: All ports in use\n"), stderr);
|
1989-03-05 17:23:15 -05:00
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
msg.tsp_type = TSP_SETDATE;
|
|
|
|
|
msg.tsp_vers = TSPVERSION;
|
2014-08-21 12:01:55 -07:00
|
|
|
msg.tsp_name[sizeof msg.tsp_name - 1] = '\0';
|
|
|
|
|
if (gethostname(msg.tsp_name, sizeof msg.tsp_name) != 0) {
|
1989-03-11 22:35:14 -05:00
|
|
|
perror("gethostname");
|
1989-03-05 17:23:15 -05:00
|
|
|
goto bad;
|
|
|
|
|
}
|
2014-08-21 12:01:55 -07:00
|
|
|
if (msg.tsp_name[sizeof msg.tsp_name - 1]) {
|
|
|
|
|
fprintf(stderr, "hostname too long\n");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
Assume C89.
* Makefile (GCC_DEBUG_FLAGS): Modernize for GCC 4.6.3 x86.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, wildinput, nondigit, oops, display)
(timeout, sametm, netsettime):
* difftime.c (difftime):
* ialloc.c (icatalloc, icpyalloc):
* localtime.c (detzcode, detzcode64, differ_by_repeat)
(tzload, typesequiv, getzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, gmtload, tzsetwall, tzset)
(localsub, localtime, localtime_r, gmtsub, gmtime, gmtime_r)
(offtime, leaps_thru_end_of, timesub, ctime, ctime_r)
(increment_overflow, long_increment_overflow)
(normalize_overflow, long_normalize_overflow, tmcomp, time2sub)
(time2, time1, mktime, timelocal, timegm, timeoff, gtime)
(leapcorr, time2posix, posix2time):
* scheck.c (scheck):
* strftime.c (strftime, _fmt, _conv, _add, _yconv, _loc):
* zdump.c (my_localtime, abbrok, usage, main, yeartot)
(delta, abbr, dumptime):
* zic.c (memcheck, eats, eat, error, warning, main)
(dolink, itsdir, rcomp, associate, infile, gethms, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert)
(convert64, puttzcode, puttzcode64, atcomp, is32, writezone, DO)
(doabbr, updateminmax, stringoffset, stringrule, stringzone)
(outzone, addtt, addtype, leapadd, yearistype, lowerit, ciequal)
(itsabbr, byword, getfields, oadd, tadd, rpytime, newabbr)
(mkdirs, eitol):
Assume C89 or better. Mostly this consists of using function
prototypes. In a few places, prototypes are required for
portability to hosts where time_t does not promote to itself and
where a preceding prototype does not override a definition. But
while we're at it we might as well be consistent: it's safe to
assume at-least-C89 these days.
* ialloc.c (nonzero, imalloc, icalloc, irealloc, ifree, icfree):
Remove; no longer needed now that we assume C89 or better.
All callers changed to use malloc, calloc, realloc, free.
* localtime.c (getzname, getqzname, leaps_thru_end_of, transtime):
* zdump.c (delta, yeartot):
* zic.c (eitol):
Now pure.
* private.h, zdump.c (ATTRIBUTE_PURE): New macro.
* private.h (icalloc, imalloc, irealloc, icfree, ifree): Remove decls.
* zic.c: Remove no-longer-necessary forward decls.
(max_time, min_time): Now const.
(setboundaries): Remove.
2012-10-12 07:53:12 -07:00
|
|
|
msg.tsp_seq = htons(0);
|
|
|
|
|
msg.tsp_time.tv_sec = htonl(ntv.tv_sec);
|
|
|
|
|
msg.tsp_time.tv_usec = htonl(ntv.tv_usec);
|
1989-03-05 17:23:15 -05:00
|
|
|
length = sizeof (struct sockaddr_in);
|
|
|
|
|
if (connect(s, &dest, length) < 0) {
|
|
|
|
|
perror("date: connect");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
if (send(s, (char *)&msg, sizeof (struct tsp), 0) < 0) {
|
|
|
|
|
if (errno != ECONNREFUSED)
|
|
|
|
|
perror("date: send");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
timed_ack = -1;
|
|
|
|
|
waittime = WAITACK;
|
|
|
|
|
loop:
|
|
|
|
|
tout.tv_sec = waittime;
|
|
|
|
|
tout.tv_usec = 0;
|
|
|
|
|
FD_ZERO(&ready);
|
|
|
|
|
FD_SET(s, &ready);
|
More C modernization.
* Makefile (typecheck): Add -D__time_t_defined to CFLAGS,
for glibc 2.15.
* asctime.c (asctime_r, asctime):
* date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal):
* ialloc.c (icatalloc):
* localtime.c (detzcode, detzcode64, settzname, tzload)
(typesequiv, getzname, getqzname, getnum, getsecs, getoffset)
(getrule, transtime, tzparse, tzset, localsub, gmtsub)
(leaps_thru_end_of, timesub, increment_overflow)
(long_increment_overflow, normalize_overflow)
(long_normalize_overflow, tmcomp, time2sub, time1, leapcorr):
* scheck.c (scheck):
* strftime.c (_yconv):
* zdump.c (my_localtime, abbrok, main, yeartot, hunt)
(delta, show, abbr, dumptime):
* zic.c (main, dolink, itsdir, associate, infile, inrule)
(inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64)
(writezone, doabbr, stringoffset, stringrule, stringzone)
(outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword)
(getfields, rpytime, newabbr, mkdirs):
Omit 'register', as it adds no value these days. See Christos Zoulas in
<http://mm.icann.org/pipermail/tz/2012-October/018376.html>.
* date.c (netsettime) [TSP_SETDATE]: Add forward decl.
Don't rely on implicit int. Now static. Use NULL, not 0.
* zdump.c: Include "limits.h".
(absolute_min_time, absolute_max_time): Compute at compile-time,
as the run-time tests relied on undefined behavior.
(checkabsolutes): Rename from setabsolutes. Just check, since
there's nothing to set now. All uses changed.
2012-10-26 00:48:01 -07:00
|
|
|
found = select(FD_SETSIZE, &ready, NULL, NULL, &tout);
|
2001-06-22 13:31:26 -04:00
|
|
|
length = sizeof err;
|
1989-03-05 17:23:15 -05:00
|
|
|
if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char *)&err, &length) == 0
|
|
|
|
|
&& err) {
|
|
|
|
|
errno = err;
|
|
|
|
|
if (errno != ECONNREFUSED)
|
1996-02-21 15:47:21 -05:00
|
|
|
perror(_("date: send (delayed error)"));
|
1989-03-05 17:23:15 -05:00
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
if (found > 0 && FD_ISSET(s, &ready)) {
|
|
|
|
|
length = sizeof (struct sockaddr_in);
|
|
|
|
|
if (recvfrom(s, (char *)&msg, sizeof (struct tsp), 0, &from,
|
|
|
|
|
&length) < 0) {
|
|
|
|
|
if (errno != ECONNREFUSED)
|
|
|
|
|
perror("date: recvfrom");
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
msg.tsp_seq = ntohs(msg.tsp_seq);
|
|
|
|
|
msg.tsp_time.tv_sec = ntohl(msg.tsp_time.tv_sec);
|
|
|
|
|
msg.tsp_time.tv_usec = ntohl(msg.tsp_time.tv_usec);
|
|
|
|
|
switch (msg.tsp_type) {
|
|
|
|
|
|
|
|
|
|
case TSP_ACK:
|
|
|
|
|
timed_ack = TSP_ACK;
|
|
|
|
|
waittime = WAITDATEACK;
|
|
|
|
|
goto loop;
|
|
|
|
|
|
|
|
|
|
case TSP_DATEACK:
|
2014-08-18 19:10:48 -07:00
|
|
|
lose(s);
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
return true;
|
1989-03-05 17:23:15 -05:00
|
|
|
|
|
|
|
|
default:
|
1989-03-11 22:35:14 -05:00
|
|
|
fprintf(stderr,
|
1996-02-21 15:47:21 -05:00
|
|
|
_("date: Wrong ack received from timed: %s\n"),
|
1993-11-22 12:58:06 -05:00
|
|
|
tsptype[msg.tsp_type]);
|
1989-03-05 17:23:15 -05:00
|
|
|
timed_ack = -1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (timed_ack == -1)
|
1996-02-21 15:47:21 -05:00
|
|
|
fputs(_("date: Can't reach time daemon, time set locally.\n"),
|
1993-11-22 12:58:06 -05:00
|
|
|
stderr);
|
1989-03-05 17:23:15 -05:00
|
|
|
bad:
|
2014-08-18 19:10:48 -07:00
|
|
|
lose(s);
|
1989-03-05 17:23:15 -05:00
|
|
|
retval = 2;
|
Use bool for boolean.
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.
2014-08-20 08:13:31 -07:00
|
|
|
return false;
|
1989-03-05 17:23:15 -05:00
|
|
|
}
|
1989-03-09 13:20:49 -05:00
|
|
|
#endif /* defined TSP_SETDATE */
|