From a495a577a0093c9504493be3c5c9f5c9df68969a Mon Sep 17 00:00:00 2001 From: kleink Date: Sat, 31 Mar 2001 18:29:20 +0000 Subject: [PATCH] Finally deprecate the old timezone() interface in favor of an XSH5 timezone/daytime pair; as proposed by J.T. in September, 1996. Fixes PR standards/11807 by Nick Hudson. --- include/time.h | 8 +++++++- lib/libc/gen/timezone.3 | 13 +++++++++---- lib/libc/gen/timezone.c | 12 ++++-------- lib/libc/time/Makefile.inc | 7 ++++--- lib/libc/time/_daylight.c | 13 +++++++++++++ lib/libc/time/localtime.c | 5 +++-- lib/libc/time/tzset.3 | 14 +++++++++++++- 7 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 lib/libc/time/_daylight.c diff --git a/include/time.h b/include/time.h index 1e02cb2fae63..fd7c8a3bc892 100644 --- a/include/time.h +++ b/include/time.h @@ -1,4 +1,4 @@ -/* $NetBSD: time.h,v 1.26 2001/03/29 19:06:39 kleink Exp $ */ +/* $NetBSD: time.h,v 1.27 2001/03/31 18:29:20 kleink Exp $ */ /* * Copyright (c) 1989, 1993 @@ -113,6 +113,10 @@ void tzset __P((void)); */ #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \ (_XOPEN_SOURCE - 0) >= 4 +extern int daylight; +#ifndef __LIBC12_SOURCE__ +extern long int timezone __RENAME(__timezone13); +#endif char *strptime __P((const char * __restrict, const char * __restrict, struct tm * __restrict)); #endif @@ -149,7 +153,9 @@ time_t posix2time __P((time_t)); time_t timegm __P((struct tm *const)); time_t timeoff __P((struct tm *const, const long)); time_t timelocal __P((struct tm *const)); +#ifdef __LIBC12_SOURCE__ char *timezone __P((int, int)); +#endif void tzsetwall __P((void)); struct tm *offtime __P((const time_t *const, const long)); #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ diff --git a/lib/libc/gen/timezone.3 b/lib/libc/gen/timezone.3 index b6a442247050..2f6948e8f12e 100644 --- a/lib/libc/gen/timezone.3 +++ b/lib/libc/gen/timezone.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: timezone.3,v 1.10 1998/08/02 03:20:41 jeremy Exp $ +.\" $NetBSD: timezone.3,v 1.11 2001/03/31 18:29:21 kleink Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -47,11 +47,15 @@ .Sh DESCRIPTION .Bf -symbolic .\" This interface is available from the compatibility library, libcompat; -This interface is available for compatibility; +This interface is available for compatibility only and will disappear in a +future software release; it is impossible to reliably map timezone's arguments to a time zone abbreviation. See -.Xr ctime 3 . +.Xr ctime 3 ; +see +.Xr tzset 3 +for the new definition of this interface. .Ef .Pp The @@ -66,7 +70,8 @@ is the number of minutes west of GMT and .Ar dst is non-zero if daylight savings time is in effect. .Sh SEE ALSO -.Xr ctime 3 +.Xr ctime 3 , +.Xr tzset 3 .Sh HISTORY A .Fn timezone diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c index e2c683122250..51ab6baa7d38 100644 --- a/lib/libc/gen/timezone.c +++ b/lib/libc/gen/timezone.c @@ -1,4 +1,4 @@ -/* $NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $ */ +/* $NetBSD: timezone.c,v 1.15 2001/03/31 18:29:21 kleink Exp $ */ /* * Copyright (c) 1987, 1993 @@ -38,10 +38,12 @@ #if 0 static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $"); +__RCSID("$NetBSD: timezone.c,v 1.15 2001/03/31 18:29:21 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ +#define __LIBC12_SOURCE__ + #include "namespace.h" #include #include @@ -50,12 +52,6 @@ __RCSID("$NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $"); #include #include -#if 0 -#ifdef __weak_alias -__weak_alias(timezone,_timezone) -#endif -#endif - /* * timezone -- * The arguments are the number of minutes of time you are westward diff --git a/lib/libc/time/Makefile.inc b/lib/libc/time/Makefile.inc index b35daee76735..3a17c15ee571 100644 --- a/lib/libc/time/Makefile.inc +++ b/lib/libc/time/Makefile.inc @@ -1,10 +1,11 @@ -# $NetBSD: Makefile.inc,v 1.7 1999/05/04 15:34:50 kleink Exp $ +# $NetBSD: Makefile.inc,v 1.8 2001/03/31 18:29:21 kleink Exp $ .PATH: ${.CURDIR}/time -SRCS+= asctime.c difftime.c localtime.c strftime.c strptime.c +SRCS+= _daylight.c \ + asctime.c difftime.c localtime.c strftime.c strptime.c MAN+= ctime.3 time2posix.3 tzfile.5 tzset.3 strftime.3 strptime.3 -CFLAGS+=-DALL_STATE +CFLAGS+=-DALL_STATE -DUSG_COMPAT MLINKS+=ctime.3 ctime_r.3 \ ctime.3 asctime.3 \ diff --git a/lib/libc/time/_daylight.c b/lib/libc/time/_daylight.c new file mode 100644 index 000000000000..65c5485d4ce2 --- /dev/null +++ b/lib/libc/time/_daylight.c @@ -0,0 +1,13 @@ +/* $NetBSD: _daylight.c,v 1.1 2001/03/31 18:29:21 kleink Exp $ */ + +/* + * Written by Klaus Klein, December 27, 2000. + * Public domain. + */ + +#include + +#ifdef __indr_reference +__indr_reference(_daylight, daylight) +#endif +/* LINTED empty translation unit */ diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index f83662839cd1..64b4f5315317 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $ */ +/* $NetBSD: localtime.c,v 1.25 2001/03/31 18:29:21 kleink Exp $ */ /* ** This file is in the public domain, so clarified as of @@ -10,7 +10,7 @@ #if 0 static char elsieid[] = "@(#)localtime.c 7.70"; #else -__RCSID("$NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $"); +__RCSID("$NetBSD: localtime.c,v 1.25 2001/03/31 18:29:21 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -30,6 +30,7 @@ __RCSID("$NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $"); #ifdef __weak_alias __weak_alias(ctime_r,_ctime_r) +__weak_alias(daylight,_daylight) __weak_alias(gmtime_r,_gmtime_r) __weak_alias(localtime_r,_localtime_r) __weak_alias(offtime,_offtime) diff --git a/lib/libc/time/tzset.3 b/lib/libc/time/tzset.3 index cdc1d23c9b2b..d17c519691d9 100644 --- a/lib/libc/time/tzset.3 +++ b/lib/libc/time/tzset.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: tzset.3,v 1.12 2001/03/29 20:56:30 kleink Exp $ +.\" $NetBSD: tzset.3,v 1.13 2001/03/31 18:29:21 kleink Exp $ .TH TZSET 3 .SH NAME tzset \- initialize time conversion information @@ -8,6 +8,8 @@ Standard C Library (libc, -lc) .nf .B void tzset(void); .PP +.B extern long int timezone; +.B extern int daylight; .fi .SH DESCRIPTION .I Tzset @@ -215,6 +217,16 @@ environment variable does not specify a .IR tzfile (5)-format and cannot be interpreted as a direct specification, UTC is used. +.PP +.I Tzset +sets the external variable +.I timezone +to the difference, in seconds, between Coordinated Universal Time (UTC) +and local standard time. +The external variable +.I daylight +is set to 0 if Daylight Savings Time conversions should never be applied +for the time zone in use; otherwise non-zero. .SH FILES .ta \w'/usr/share/zoneinfo/posixrules\0\0'u /etc/localtime local time zone file