glibc/time/zdump.c
Ulrich Drepper 4cca6b868f Update.
1997-03-08 05:30  Ulrich Drepper  <drepper@cygnus.com>

	* argp/Makefile (routines): Add argp-eexst.
	* argp/argp-ba.c (argp_program_bug_address): Make `const'.
	* argp/argp-eexst.c: New file.  Define exit status variable.
	* argp/argp-help.c (__argp_state_help): Use argp_err_exit_status
	variable instead of always exiting with value 1.
	* argp/argp-pv.c (argp_program_version): Make `const'.
	* argp/argp.h: Declare argp_err_exit_status.
	Patches by Miles Bader <miles@gnu.ai.mit.edu>.

	* locale/programs/localedef.c: Use argp_err_exit_status to
	terminate with correct value.

	* inet/rcmd.c (iruserok): Use euidaccess instead of half-hearted
	switching of UID before opening .rhosts.

	* libio/vsnprintf.c: Change implementation to follow ISO C 9X
	proposal.  The return value now is always the number of characters
	which would be written if enough space is available.
	* manual/stdio.texi: Update description for new behaviour.

	* locale/locale.h (__locale_t): Don't use __locale_t for struct
	name and pointer to struct since old gccs cannot keep the namespaces
	apart.  Rename struct to __locale_struct.
	* locale/duplocale.h: Likewise.
	* locale/newlocale.h: Likewise.

	* math/Makefile (headers): Add complex.h and cmathcalls.h.
	(routines): Remove w_cabs.  Add conj, cimag, creal, and cabs.
	* math/math.h: Undefine __MATHDECL_1, __MATHDECL, and __MATHCALL
	after use.
	(signgam): Move declaration to here from mathcalls.h.
	* math/mathcalls.h (cabs, __cabs_complex, signgam): Remove definition.
	Correct comment for fmin and fmax.
	Start implementing complex math function from ISO C 9X.
	* math/complex.h: New file.
	* math/cmathcalls.h: New file.
	* math/cabs.c: New file.
	* math/cabsf.c: New file.
	* math/cabsl.c: New file.
	* math/cimag.c: New file.
	* math/cimagf.c: New file.
	* math/cimagl.c: New file.
	* math/conj.c: New file.
	* math/conjf.c: New file.
	* math/conjl.c: New file.
	* math/creal.c: New file.
	* math/crealf.c: New file.
	* math/creall.c: New file.
	* sysdeps/libm-ieee754/w_cabs.c: Removed.
	* sysdeps/libm-ieee754/w_cabsf.c: Removed.
	* sysdeps/libm-ieee754/w_cabsl.c: Removed.

	* posix/regex.c: Merge with regex sources from Arnold Robbins'
	version in GNU awk.
	* posix/regex.h: Likewise.

	Add regex test suite by Tom Lord.
	* posix/Makefile (distribute): Add TESTS, TESTS2C.sed, and testcases.h.
	(tests): Add runtests.
	(before-compile): Add testcases.h.
	(testcases.h): New rule to generate header with tests.
	* posix/TESTS: New file.
	* posix/TESTS2C.sed.: New file.
	* posix/runtests.c: New file.
	* posix/testcases.h: New file.

	* sysdeps/unix/sysv/linux/poll.c: Test whether poll syscall is
	available and use fall-back implementation if not.

	* sysdeps/unix/sysv/linux/syscalls.list: Sort entries.

	* time/ialloc.c: Update from tzcode1997c.
	* time/private.h: Likewise.
	* time/scheck.c: Likewise.
	* time/tzselect.ksh: Likewise.
	* time/zdump.c: Likewise.
	* time/zic.c: Likewise.

	* time/tzfile.c: Pretty print.

1997-03-06 07:37  Geoff Keating  <geoffk@ozemail.com.au>

	Port to powerpc-*-linux-gnu.  Slightly tested, under MkLinux,
	on a 601.

	* sysdeps/powerpc/Implies: Added.
	* sysdeps/powerpc/__longjmp.S: Added.
	* sysdeps/powerpc/__math.h: Added.
	* sysdeps/powerpc/bsd-_setjmp.S: Added.
	* sysdeps/powerpc/bsd-setjmp.S: Added.
	* sysdeps/powerpc/dl-machine.h: Added.
	* sysdeps/powerpc/ffs.c: Added.
	* sysdeps/powerpc/fpu_control.h: Added.
	* sysdeps/powerpc/jmp_buf.h: Added.
	* sysdeps/powerpc/setjmp.S: Added.
	* sysdeps/powerpc/strlen.s: Added.
	* sysdeps/powerpc/elf/start.c: Added.
	* sysdeps/powerpc/fpu_control.h: Added.
	* sysdeps/powerpc/jmp_buf.h: Added.

	* sysdeps/unix/sysv/linux/powerpc/Dist: Added.
	* sysdeps/unix/sysv/linux/powerpc/_exit.S: Added.
	* sysdeps/unix/sysv/linux/powerpc/brk.c: Added.
	* sysdeps/unix/sysv/linux/powerpc/clone.S: Added.
	* sysdeps/unix/sysv/linux/powerpc/init-first.h: Added.
	* sysdeps/unix/sysv/linux/powerpc/ioctl-types.h: Added.
	* sysdeps/unix/sysv/linux/powerpc/profil.c: Added.
	* sysdeps/unix/sysv/linux/powerpc/sigreturn.S: Added.
	* sysdeps/unix/sysv/linux/powerpc/socket.S: Added.
	* sysdeps/unix/sysv/linux/powerpc/syscall.S: Added.
	* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Added.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.c: Added.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Added.
	* sysdeps/unix/sysv/linux/powerpc/termbits.h: Added.
	* sysdeps/unix/sysv/linux/powerpc/sys/syscall.h: Added.

1997-03-05 05:24  Geoff Keating  <geoffk@ozemail.com.au>

	* elf/dl-runtime.c (fixup): Add ELF_FIXUP_RETURNS_ADDRESS switch,
	because knowing the first instruction of a PowerPC PLT trampoline
	is not very helpful.

1997-03-04 08:04  Geoff Keating  <geoffk@ozemail.com.au>

	* elf/dl-load.c (ELF_PREFERRED_ADDRESS, ELF_PREFERRED_ADDRESS_DATA,
	ELF_FIXED_ADDRESS): Added. These are for dl-machine.h to indicate
	a preference as to where executables should be loaded.

1997-02-28 08:50  Geoff Keating  <geoffk@ozemail.com.au>

	* elf/elf.h: Add in all those PowerPC reloc types.

1997-02-24 07:12  Geoff Keating  <geoffk@ozemail.com.au>

	* stdio-common/vfscanf.c: Use __va_copy if available.

1997-03-06 13:50  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* malloc/malloc.c (mprotect) [_LIBC]: Define as __mprotect to
	clean up namespace.

1997-03-07 14:27  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/libm-ieee754/s_fpclassify.c (__fpclassify): Don't use
	non-existing GET_WORDS macro, use EXTRACT_WORDS.
	Reported by Andres Schwab <schwab@issan.informatik.uni-dortmund.de>.

1997-03-07 05:27  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/i386/sigaction.c: The user- and
	kernel-level sigaction structure is different.  handle this
	correctly.
	Bug report by Andres Jaeger <jaeger@informatik.uni-kl.de>.

1997-03-06 05:55  David Engel  <david@sw.ods.com>

	* sysdeps/generic/dl-cache.c (_dl_load_cache_lookup): Also
	recognize cache entries with flag == 3.

1997-03-06 01:05  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/generic/netinet/in.h (INADDR_NONE): Cast to unsigned int.
	(INADDR_LOOPBACK): Likewise.
	* sysdeps/unix/sysv/linux/netinet/in.h: Likewise.

	* manual/socket.texi: Correct types of INADDR_* constants from
	unsigned long to unsigned.

1997-03-05 23:14  Ulrich Drepper  <drepper@cygnus.com>

	* time/antarctica: Update from tzdata1997c.
	* time/asia: Likewise.
	* time/zone.tab: Likewise.

1997-03-05 00:43  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* configure.in (libc_cv_asm_symver_directive,
	libc_cv_ld_version_script_option): Remove unknown instruction from
	assembler test file.

1997-03-04 19:14  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/m68k/fpu/__math.h: Update feature tests to use
	__USE_ISOC9X.
	[__USE_ISOC9X]: Define __log2 and __exp2 inlines.
	(fabs): Remove defininition, it is a gcc builtin.
	(sqrt, __sqrt): Remove definition, they have wrappers in libm.

1997-03-04 10:11  H.J. Lu  <hjl@lucon.org>

	* sunrpc/Makefile ($(objpfx)rpc-proto.c): Create subdir before
	generating file.

1997-03-05 03:59  Ulrich Drepper  <drepper@cygnus.com>

	* inet/rcmd.c (__ivaliduser): Don't use getline, but __getline
	instead to avoid namespace problems.
	Reported by David Mosberger-Tang <davidm@AZStarNet.COM>.

1997-03-03 19:01  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* login/utmp_file.c: Fix previous change.  Make portable by
	checking the _HAVE_UT_* feature macros.

	* libio/fileops.c (_IO_file_finish): Likewise.
1997-03-08 05:28:20 +00:00

373 lines
8.2 KiB
C

#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)zdump.c 7.26";
#endif /* !defined NOID */
#endif /* !defined lint */
/*
** This code has been made independent of the rest of the time
** conversion package to increase confidence in the verification it provides.
** You can use this code to help in verifying other implementations.
*/
#include "stdio.h" /* for stdout, stderr, perror */
#include "string.h" /* for strcpy */
#include "sys/types.h" /* for time_t */
#include "time.h" /* for struct tm */
#include "stdlib.h" /* for exit, malloc, atoi */
#ifndef MAX_STRING_LENGTH
#define MAX_STRING_LENGTH 1024
#endif /* !defined MAX_STRING_LENGTH */
#ifndef TRUE
#define TRUE 1
#endif /* !defined TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* !defined FALSE */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */
#ifndef SECSPERMIN
#define SECSPERMIN 60
#endif /* !defined SECSPERMIN */
#ifndef MINSPERHOUR
#define MINSPERHOUR 60
#endif /* !defined MINSPERHOUR */
#ifndef SECSPERHOUR
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#endif /* !defined SECSPERHOUR */
#ifndef HOURSPERDAY
#define HOURSPERDAY 24
#endif /* !defined HOURSPERDAY */
#ifndef EPOCH_YEAR
#define EPOCH_YEAR 1970
#endif /* !defined EPOCH_YEAR */
#ifndef TM_YEAR_BASE
#define TM_YEAR_BASE 1900
#endif /* !defined TM_YEAR_BASE */
#ifndef DAYSPERNYEAR
#define DAYSPERNYEAR 365
#endif /* !defined DAYSPERNYEAR */
#ifndef isleap
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
#endif /* !defined isleap */
#if HAVE_GETTEXT - 0
#include "locale.h" /* for setlocale */
#include "libintl.h"
#endif /* HAVE_GETTEXT - 0 */
#ifndef GNUC_or_lint
#ifdef lint
#define GNUC_or_lint
#endif /* defined lint */
#ifndef lint
#ifdef __GNUC__
#define GNUC_or_lint
#endif /* defined __GNUC__ */
#endif /* !defined lint */
#endif /* !defined GNUC_or_lint */
#ifndef INITIALIZE
#ifdef GNUC_or_lint
#define INITIALIZE(x) ((x) = 0)
#endif /* defined GNUC_or_lint */
#ifndef GNUC_or_lint
#define INITIALIZE(x)
#endif /* !defined GNUC_or_lint */
#endif /* !defined INITIALIZE */
/*
** For the benefit of GNU folk...
** `_(MSGID)' uses the current locale's message library string for MSGID.
** The default is to use gettext if available, and use MSGID otherwise.
*/
#ifndef _
#if HAVE_GETTEXT - 0
#define _(msgid) gettext(msgid)
#else /* !(HAVE_GETTEXT - 0) */
#define _(msgid) msgid
#endif /* !(HAVE_GETTEXT - 0) */
#endif /* !defined _ */
#ifndef TZ_DOMAIN
#define TZ_DOMAIN "tz"
#endif /* !defined TZ_DOMAIN */
#ifndef P
#ifdef __STDC__
#define P(x) x
#endif /* defined __STDC__ */
#ifndef __STDC__
#define P(x) ()
#endif /* !defined __STDC__ */
#endif /* !defined P */
extern char ** environ;
extern int getopt P((int argc, char * const argv[],
const char * options));
extern char * optarg;
extern int optind;
extern char * tzname[2];
static char * abbr P((struct tm * tmp));
static long delta P((struct tm * newp, struct tm * oldp));
static time_t hunt P((char * name, time_t lot, time_t hit));
static size_t longest;
static char * progname;
static void show P((char * zone, time_t t, int v));
int
main(argc, argv)
int argc;
char * argv[];
{
register int i;
register int c;
register int vflag;
register char * cutoff;
register int cutyear;
register long cuttime;
char ** fakeenv;
time_t now;
time_t t;
time_t newt;
time_t hibit;
struct tm tm;
struct tm newtm;
INITIALIZE(cuttime);
#if HAVE_GETTEXT - 0
(void) setlocale(LC_MESSAGES, "");
#ifdef TZ_DOMAINDIR
(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined(TEXTDOMAINDIR) */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
progname = argv[0];
vflag = 0;
cutoff = NULL;
while ((c = getopt(argc, argv, "c:v")) == 'c' || c == 'v')
if (c == 'v')
vflag = 1;
else cutoff = optarg;
if ((c != EOF && c != -1) ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
(void) fprintf(stderr,
_("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
argv[0], argv[0]);
(void) exit(EXIT_FAILURE);
}
if (cutoff != NULL) {
int y;
cutyear = atoi(cutoff);
cuttime = 0;
for (y = EPOCH_YEAR; y < cutyear; ++y)
cuttime += DAYSPERNYEAR + isleap(y);
cuttime *= SECSPERHOUR * HOURSPERDAY;
}
(void) time(&now);
longest = 0;
for (i = optind; i < argc; ++i)
if (strlen(argv[i]) > longest)
longest = strlen(argv[i]);
for (hibit = 1; (hibit << 1) != 0; hibit <<= 1)
continue;
{
register int from;
register int to;
for (i = 0; environ[i] != NULL; ++i)
continue;
fakeenv = (char **) malloc((size_t) ((i + 2) *
sizeof *fakeenv));
if (fakeenv == NULL ||
(fakeenv[0] = (char *) malloc(longest + 4)) == NULL) {
(void) perror(progname);
(void) exit(EXIT_FAILURE);
}
to = 0;
(void) strcpy(fakeenv[to++], "TZ=");
for (from = 0; environ[from] != NULL; ++from)
if (strncmp(environ[from], "TZ=", 3) != 0)
fakeenv[to++] = environ[from];
fakeenv[to] = NULL;
environ = fakeenv;
}
for (i = optind; i < argc; ++i) {
static char buf[MAX_STRING_LENGTH];
(void) strcpy(&fakeenv[0][3], argv[i]);
if (!vflag) {
show(argv[i], now, FALSE);
continue;
}
/*
** Get lowest value of t.
*/
t = hibit;
if (t > 0) /* time_t is unsigned */
t = 0;
show(argv[i], t, TRUE);
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
tm = *localtime(&t);
(void) strncpy(buf, abbr(&tm), (sizeof buf) - 1);
for ( ; ; ) {
if (cutoff != NULL && t >= cuttime)
break;
newt = t + SECSPERHOUR * 12;
if (cutoff != NULL && newt >= cuttime)
break;
if (newt <= t)
break;
newtm = *localtime(&newt);
if (delta(&newtm, &tm) != (newt - t) ||
newtm.tm_isdst != tm.tm_isdst ||
strcmp(abbr(&newtm), buf) != 0) {
newt = hunt(argv[i], t, newt);
newtm = *localtime(&newt);
(void) strncpy(buf, abbr(&newtm),
(sizeof buf) - 1);
}
t = newt;
tm = newtm;
}
/*
** Get highest value of t.
*/
t = ~((time_t) 0);
if (t < 0) /* time_t is signed */
t &= ~hibit;
t -= SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
}
if (fflush(stdout) || ferror(stdout)) {
(void) fprintf(stderr, _("%s: Error writing standard output "),
argv[0]);
(void) perror(_("standard output"));
(void) exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
/* gcc -Wall pacifier */
for ( ; ; )
continue;
}
static time_t
hunt(name, lot, hit)
char * name;
time_t lot;
time_t hit;
{
time_t t;
struct tm lotm;
struct tm tm;
static char loab[MAX_STRING_LENGTH];
lotm = *localtime(&lot);
(void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1);
while ((hit - lot) >= 2) {
t = lot / 2 + hit / 2;
if (t <= lot)
++t;
else if (t >= hit)
--t;
tm = *localtime(&t);
if (delta(&tm, &lotm) == (t - lot) &&
tm.tm_isdst == lotm.tm_isdst &&
strcmp(abbr(&tm), loab) == 0) {
lot = t;
lotm = tm;
} else hit = t;
}
show(name, lot, TRUE);
show(name, hit, TRUE);
return hit;
}
/*
** Thanks to Paul Eggert (eggert@twinsun.com) for logic used in delta.
*/
static long
delta(newp, oldp)
struct tm * newp;
struct tm * oldp;
{
long result;
int tmy;
if (newp->tm_year < oldp->tm_year)
return -delta(oldp, newp);
result = 0;
for (tmy = oldp->tm_year; tmy < newp->tm_year; ++tmy)
result += DAYSPERNYEAR + isleap(tmy + TM_YEAR_BASE);
result += newp->tm_yday - oldp->tm_yday;
result *= HOURSPERDAY;
result += newp->tm_hour - oldp->tm_hour;
result *= MINSPERHOUR;
result += newp->tm_min - oldp->tm_min;
result *= SECSPERMIN;
result += newp->tm_sec - oldp->tm_sec;
return result;
}
static void
show(zone, t, v)
char * zone;
time_t t;
int v;
{
struct tm * tmp;
(void) printf("%-*s ", (int) longest, zone);
if (v)
(void) printf("%.24s GMT = ", asctime(gmtime(&t)));
tmp = localtime(&t);
(void) printf("%.24s", asctime(tmp));
if (*abbr(tmp) != '\0')
(void) printf(" %s", abbr(tmp));
if (v) {
(void) printf(" isdst=%d", tmp->tm_isdst);
#ifdef TM_GMTOFF
(void) printf(" gmtoff=%ld", tmp->TM_GMTOFF);
#endif /* defined TM_GMTOFF */
}
(void) printf("\n");
}
static char *
abbr(tmp)
struct tm * tmp;
{
register char * result;
static char nada;
if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1)
return &nada;
result = tzname[tmp->tm_isdst];
return (result == NULL) ? &nada : result;
}