From 7d013f9724346e48d5aa3e501e0bc081c73878d6 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Fri, 16 Jan 2009 10:52:59 -0500 Subject: [PATCH] Remove the timezone() function. It conflicts with an XSI extension where timezone and daylight are variables representing: timezone: the difference, in seconds, between Coordinated Universal Time (UTC) and local standard time. daylight: set to 0 if Daylight Savings Time conversions should never be applied for the timezone in use; otherwise, non-zero. --- Makefile_upgrade.inc | 2 + include/time.h | 3 +- lib/libc/gen/Makefile.inc | 4 +- lib/libc/gen/timezone.3 | 72 ------------------- lib/libc/gen/timezone.c | 130 ----------------------------------- lib/libc/stdtime/localtime.c | 9 +++ 6 files changed, 15 insertions(+), 205 deletions(-) delete mode 100644 lib/libc/gen/timezone.3 delete mode 100644 lib/libc/gen/timezone.c diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 4fc0234f3d..38904dca19 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -1062,3 +1062,5 @@ TO_REMOVE+=/usr/share/man/man8/iwicontrol.8.gz TO_REMOVE+=/usr/share/man/cat8/iwicontrol.8.gz TO_REMOVE+=/usr/share/man/man9/objcache_reclaim_list.9.gz TO_REMOVE+=/usr/share/man/cat9/objcache_reclaim_list.9.gz +TO_REMOVE+=/usr/share/man/cat3/timezone.3.gz +TO_REMOVE+=/usr/share/man/man3/timezone.3.gz diff --git a/include/time.h b/include/time.h index e1e8f4f2d9..26ededc8ba 100644 --- a/include/time.h +++ b/include/time.h @@ -167,11 +167,12 @@ int nanosleep (const struct timespec *, struct timespec *); #endif /* __POSIX_VISIBLE >= 199309 */ #if __XSI_VISIBLE +extern int daylight; +extern long timezone; char *strptime (const char *, const char *, struct tm *); #endif #if __BSD_VISIBLE -char *timezone (int, int); void tzsetwall (void); time_t timelocal (struct tm * const); time_t timegm (struct tm * const); diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index de4986056d..ec339c7a23 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -33,7 +33,7 @@ SRCS+= _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \ signbitd.c signbitf.c sigsetops.c sigwait.c sleep.c srand48.c \ stringlist.c strtofflags.c sysconf.c sysctl.c sysctlbyname.c \ sysctlnametomib.c syslog.c telldir.c termios.c time.c times.c \ - timezone.c toascii.c tolower.c toupper.c ttyname.c ttyslot.c \ + toascii.c tolower.c toupper.c ttyname.c ttyslot.c \ ualarm.c ucontext.c ulimit.c uname.c unvis.c usleep.c utime.c \ valloc.c vis.c wait.c wait3.c waitpid.c wordexp.c @@ -72,7 +72,7 @@ MAN+= alarm.3 arc4random.3 clock.3 \ scandir.3 setjmp.3 setmode.3 setproctitle.3 shm_open.3 \ siginterrupt.3 signal.3 signbit.3 sigsetops.3 sleep.3 stringlist.3 \ strtofflags.3 sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 \ - tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 timezone.3 \ + tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 \ toascii.3 tolower.3 toupper.3 ttyname.3 tzset.3 ualarm.3 \ ucontext.3 ulimit.3 uname.3 unvis.3 usleep.3 utime.3 \ valloc.3 vis.3 wordexp.3 diff --git a/lib/libc/gen/timezone.3 b/lib/libc/gen/timezone.3 deleted file mode 100644 index bba427ad30..0000000000 --- a/lib/libc/gen/timezone.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94 -.\" $FreeBSD: src/lib/libc/gen/timezone.3,v 1.4.2.3 2000/12/08 13:49:24 ru Exp $ -.\" $DragonFly: src/lib/libc/gen/timezone.3,v 1.2 2003/06/17 04:26:42 dillon Exp $ -.\" -.Dd April 19, 1994 -.Dt TIMEZONE 3 -.Os -.Sh NAME -.Nm timezone -.Nd return the timezone abbreviation -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.Ft char * -.Fn timezone "int zone" "int dst" -.Sh DESCRIPTION -.Bf Sy -This interface is for compatibility only; it is impossible to reliably -map timezone's arguments to a time zone abbreviation. -See -.Xr ctime 3 . -.Ef -.Pp -The -.Fn timezone -function returns a pointer to a time zone abbreviation for the specified -.Ar zone -and -.Ar dst -values. -.Ar Zone -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 -.Sh HISTORY -A -.Fn timezone -function appeared in -.At v7 . diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c deleted file mode 100644 index 963cfc0318..0000000000 --- a/lib/libc/gen/timezone.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)timezone.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/timezone.c,v 1.5 2005/11/19 22:32:53 swildner Exp $ - */ - -#include -#include -#include -#include -#include -#define TZ_MAX_CHARS 255 - -char *_tztab(int, int); - -/* - * timezone -- - * The arguments are the number of minutes of time you are westward - * from Greenwich and whether DST is in effect. It returns a string - * giving the name of the local timezone. Should be replaced, in the - * application code, by a call to localtime. - */ - -static char czone[TZ_MAX_CHARS]; /* space for zone name */ - -char * -timezone(int zone, int dst) -{ - char *beg, - *end; - - if ( (beg = getenv("TZNAME")) ) { /* set in environment */ - if ( (end = index(beg, ',')) ) {/* "PST,PDT" */ - if (dst) - return(++end); - *end = '\0'; - strncpy(czone,beg,sizeof(czone) - 1); - czone[sizeof(czone) - 1] = '\0'; - *end = ','; - return(czone); - } - return(beg); - } - return(_tztab(zone,dst)); /* default: table or created zone */ -} - -static struct zone { - int offset; - char *stdzone; - char *dlzone; -} zonetab[] = { - {-1*60, "MET", "MET DST"}, /* Middle European */ - {-2*60, "EET", "EET DST"}, /* Eastern European */ - {4*60, "AST", "ADT"}, /* Atlantic */ - {5*60, "EST", "EDT"}, /* Eastern */ - {6*60, "CST", "CDT"}, /* Central */ - {7*60, "MST", "MDT"}, /* Mountain */ - {8*60, "PST", "PDT"}, /* Pacific */ -#ifdef notdef - /* there's no way to distinguish this from WET */ - {0, "GMT", 0}, /* Greenwich */ -#endif - {0*60, "WET", "WET DST"}, /* Western European */ - {-10*60,"EST", "EST"}, /* Aust: Eastern */ - {-10*60+30,"CST", "CST"}, /* Aust: Central */ - {-8*60, "WST", 0}, /* Aust: Western */ - {-1, NULL, NULL} -}; - -/* - * _tztab -- - * check static tables or create a new zone name; broken out so that - * we can make a guess as to what the zone is if the standard tables - * aren't in place in /etc. DO NOT USE THIS ROUTINE OUTSIDE OF THE - * STANDARD LIBRARY. - */ -char * -_tztab(int zone, int dst) -{ - struct zone *zp; - char sign; - - for (zp = zonetab; zp->offset != -1;++zp) /* static tables */ - if (zp->offset == zone) { - if (dst && zp->dlzone) - return(zp->dlzone); - if (!dst && zp->stdzone) - return(zp->stdzone); - } - - if (zone < 0) { /* create one */ - zone = -zone; - sign = '+'; - } - else - sign = '-'; - snprintf(czone, sizeof(czone), - "GMT%c%d:%02d",sign,zone / 60,zone % 60); - return(czone); -} diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index b698f0869a..baf8a20607 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -211,6 +211,9 @@ char * tzname[2] = { static struct tm tm; +time_t timezone = 0; +int daylight = 0; + static long detzcode(const char * const codep) { @@ -243,12 +246,18 @@ settzname(void) tzname[0] = wildabbr; tzname[1] = wildabbr; + daylight = 0; + timezone = 0; for (i = 0; i < sp->typecnt; ++i) { const struct ttinfo * const ttisp = &sp->ttis[i]; tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; + if (ttisp->tt_isdst) + daylight = 1; + if (i == 0 || !ttisp->tt_isdst) + timezone = -(ttisp->tt_gmtoff); } /* ** And to get the latest zone names into tzname. . . -- 2.41.0