mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 15:20:10 +00:00
740152054e
1998-01-22 00:55 Ulrich Drepper <drepper@happy.cygnus.com> * libc.map: Add __libc_uid, __libc_pid, __syscall_rt_sigqueueinfo, __pread64, __pwrite64, and __getpid. * libc/rt/aio_misc.c: Use pread and pwrite instead of __ protected versions. 1998-01-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/alpha/syscalls.list: Define the cancelable socket functions as __libc_xxx with __xxx as weak alias. * sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/m68k/socket.S: Allow __socket to be redefined. * sysdeps/unix/sysv/linux/i386/socket.S: Likewise. * sysdeps/unix/sysv/linux/arm/socket.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/socket.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/socket.S: Likewise. * sysdeps/unix/sysv/linux/accept.S: Make __libc_xxx the main name and __xxx a weak alias. * sysdeps/unix/sysv/linux/connect.S: Likewise. * sysdeps/unix/sysv/linux/recv.S: Likewise. * sysdeps/unix/sysv/linux/recvfrom.S: Likewise. * sysdeps/unix/sysv/linux/recvmsg.S: Likewise. * sysdeps/unix/sysv/linux/send.S: Likewise. * sysdeps/unix/sysv/linux/sendmsg.S: Likewise. * sysdeps/unix/sysv/linux/sendto.S: Likewise. 1998-01-21 Andreas Jaeger <aj@arthur.rhein-neckar.de> * locale/langinfo.h: Add defines. * dirent/dirent.h: Add defines for DT_*, check also for _DIRENT_HAVE_D_TYPE. Suggested by Roland McGrath. 1998-01-16 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/netinet/ip_fw.h: Update from Linux 2.1.73+79. * README.template: Update information about possible configurations. * manual/mbyte.texi (Wide String Conversion): Fix declaration of wcstombs. Pointed out by Jochen Voss <voss@mathematik.uni-kl.de>. [PR libc/417]. * manual/time.texi (Priority): Correct description of PRIO_MAX. Pointed out by Jochen Voss <voss@mathematik.uni-kl.de>. [PR libc/416]. 11998-01-21 21:34 Ulrich Drepper <drepper@cygnus.com> * sysdeps/alpha/fpu/bits/mathdef.h: Add definition of FP_ILOGB0 and FP_ILOGNAN. Patch by a sun <asun@zoology.washington.edu>. 1998-01-21 17:53 Ulrich Drepper <drepper@cygnus.com> * sysdeps/generic/_strerror.c: Handle BUFLEN == 0. Reported by Andreas Jaeger. 1998-01-20 18:13 Ulrich Drepper <drepper@cygnus.com> * locale/programs/ld-collate.c: Little optimizations. * stdio-common/xbug.c: Unset LD_LIBRRARY_PATH variable. * string/Makefile (tests): Add tst-inlcall. * string/tst-inlcall.c: New file. * string/strsignal.c: Add support for real-time signals. * sysdeps/generic/_strerror.c: Fix Handling of unknown error in presense of small buffer. * sysdeps/i386/bits/string.h: Define _HAVE_STRING_ARCH_* macros. * sysdeps/i386/i486/bits/string.h: Correct strrchr implementation for i686. * sysdeps/unix/sysv/linux/siglist.c: Change length of arrays to _NSIG + 1. 1998-01-02 15:10 Matthias Urlichs <urlichs@noris.de> * Rules: Add explicit rule for dummy.o; at least one library needs it and it isn't autogenerated by the default rules. 1997-12-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * math/libm-test.c: Tweak epsilons. 1997-12-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * math/test-fenv.c (feenv_nomask_test): Avoid dumping core in the child. (feenv_mask_test): Likewise. 1998-01-01 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig: Don't export CPPFLAGS. 1998-01-01 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sunrpc/rpc_main.c (parseargs): Use perror to print error message. 1998-01-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * nss/nss_db/db-alias.c (_nss_db_getaliasent_r): Don't include terminating null in key size. 1998-01-13 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * nss/nss_files/files-service.c: Fix allocation size to include length of PROTO. * nss/nss_db/db-XXX.c (lookup): Always set errno and h_errno if applicable. Fix return value and error checking. (CONCAT(_nss_db_get,ENTNAME_r)): Loop around to skip over unparsable lines. (DB_LOOKUP): Allocate space for terminating null byte. * nss/db-Makefile ($(VAR_DB)/passwd.db): Don't handle duplicate uids specially. * db2/makedb.c (process_input): Continue processing if a duplicate key is encountered. 1998-01-19 15:20 Ulrich Drepper <drepper@cygnus.com> * time/tzfile.h: Updated from tzcode1998b. * time/zdump.c: Likewise. * time/zic.c: Likewise. * time/africa: Update from tzdata1998b. * time/antarctica: Likewise. * time/asia: Likewise. * time/australasia: Likewise. * time/etcetera: Likewise. * time/europe: Likewise. * time/leapseconds: Likewise. * time/northamerica: Likewise. * time/southamerica: Likewise. 1998-01-12 Andreas Jaeger <aj@arthur.rhein-neckar.de> * nss/nss_files/files-alias.c (get_next_alias): Do mail alias lookups ignoring case. * nss/nss_files/files-network.c: Do network lookups ignoring case. * nss/nss_files/files-hosts.c: Do hostname lookups ignoring case. * nss/nss_files/files-parse.c (LOOKUP_NAME_CASE): New macro for case insensitive comparing. Patches by Cristian Gafton <gafton@redhat.com>. 1998-01-09 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/net/if.h: Add IFF_*defines. Suggested by Roland McGrath. [PR libc/395] 1998-01-08 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/arith.texi (Parsing of Integers): Correct description of strtoul. Pointed out by Scott Snyder <snyder@fnald0.fnal.gov>. [PR libc/396] 1997-12-30 14:14 Matthias Urlichs <urlichs@noris.de> * misc/lsearch.c (lsearch): Return a pointer to the new element if one was "allocated". 1997-12-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * string/strsignal.c: NSIG is not a valid index into _sys_siglist. Don't zap the last character of the "Unknown signal" message. 1998-01-19 15:08 Ulrich Drepper <drepper@cygnus.com> * locale/programs/charmap.c (parse_charmap): Correct parsing of ellipsis expressions. * locale/programs/charset.c (insert_char): Correctly insert value of eliipsis expression.
373 lines
8.2 KiB
C
373 lines
8.2 KiB
C
#ifndef lint
|
|
#ifndef NOID
|
|
static char elsieid[] = "@(#)zdump.c 7.27";
|
|
#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 UTC = ", 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;
|
|
}
|