svn commit: r185209 - in user/keramida/tzcode: libc/stdtime zic
zic/zdump zic/zic
Giorgos Keramidas
keramida at FreeBSD.org
Sun Nov 23 08:06:42 PST 2008
Author: keramida (doc committer)
Date: Sun Nov 23 16:06:41 2008
New Revision: 185209
URL: http://svn.freebsd.org/changeset/base/185209
Log:
Merge FreeBSD-specific changes and bootstrap mergeinfo from /head.
Added:
user/keramida/tzcode/libc/stdtime/Makefile.inc
- copied unchanged from r185208, head/lib/libc/stdtime/Makefile.inc
user/keramida/tzcode/libc/stdtime/Symbol.map
- copied unchanged from r185208, head/lib/libc/stdtime/Symbol.map
user/keramida/tzcode/libc/stdtime/ctime.3
- copied unchanged from r185208, head/lib/libc/stdtime/ctime.3
user/keramida/tzcode/libc/stdtime/strftime.3
- copied unchanged from r185208, head/lib/libc/stdtime/strftime.3
user/keramida/tzcode/libc/stdtime/strptime.3
- copied unchanged from r185208, head/lib/libc/stdtime/strptime.3
user/keramida/tzcode/libc/stdtime/strptime.c
- copied unchanged from r185208, head/lib/libc/stdtime/strptime.c
user/keramida/tzcode/libc/stdtime/time32.c
- copied unchanged from r185208, head/lib/libc/stdtime/time32.c
user/keramida/tzcode/libc/stdtime/timelocal.c
- copied unchanged from r185208, head/lib/libc/stdtime/timelocal.c
user/keramida/tzcode/libc/stdtime/timelocal.h
- copied unchanged from r185208, head/lib/libc/stdtime/timelocal.h
user/keramida/tzcode/zic/Arts.htm
- copied unchanged from r185208, head/usr.sbin/zic/Arts.htm
user/keramida/tzcode/zic/Makefile
- copied unchanged from r185208, head/usr.sbin/zic/Makefile
user/keramida/tzcode/zic/Makefile.inc
- copied unchanged from r185208, head/usr.sbin/zic/Makefile.inc
user/keramida/tzcode/zic/zdump/
- copied from r185208, head/usr.sbin/zic/zdump/
user/keramida/tzcode/zic/zic/
- copied from r185208, head/usr.sbin/zic/zic/
Modified:
user/keramida/tzcode/libc/stdtime/ (props changed)
user/keramida/tzcode/libc/stdtime/asctime.c
user/keramida/tzcode/libc/stdtime/difftime.c
user/keramida/tzcode/libc/stdtime/localtime.c
user/keramida/tzcode/libc/stdtime/private.h
user/keramida/tzcode/libc/stdtime/strftime.c
user/keramida/tzcode/libc/stdtime/tzfile.h
user/keramida/tzcode/zic/ (props changed)
user/keramida/tzcode/zic/ialloc.c
user/keramida/tzcode/zic/private.h
user/keramida/tzcode/zic/scheck.c
user/keramida/tzcode/zic/zdump.8
user/keramida/tzcode/zic/zdump.c
user/keramida/tzcode/zic/zic.8
user/keramida/tzcode/zic/zic.c
Copied: user/keramida/tzcode/libc/stdtime/Makefile.inc (from r185208, head/lib/libc/stdtime/Makefile.inc)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/keramida/tzcode/libc/stdtime/Makefile.inc Sun Nov 23 16:06:41 2008 (r185209, copy of r185208, head/lib/libc/stdtime/Makefile.inc)
@@ -0,0 +1,18 @@
+# Makefile.inc,v 1.2 1994/09/13 21:26:01 wollman Exp
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/stdtime ${.CURDIR}/../locale
+
+SRCS+= asctime.c difftime.c localtime.c strftime.c strptime.c timelocal.c \
+ time32.c
+
+SYM_MAPS+= ${.CURDIR}/stdtime/Symbol.map
+
+MAN+= ctime.3 strftime.3 strptime.3 time2posix.3
+MAN+= tzfile.5
+
+MLINKS+=ctime.3 asctime.3 ctime.3 difftime.3 ctime.3 gmtime.3 \
+ ctime.3 localtime.3 ctime.3 mktime.3 ctime.3 timegm.3 \
+ ctime.3 ctime_r.3 ctime.3 localtime_r.3 ctime.3 gmtime_r.3 \
+ ctime.3 asctime_r.3
+MLINKS+=time2posix.3 posix2time.3
Copied: user/keramida/tzcode/libc/stdtime/Symbol.map (from r185208, head/lib/libc/stdtime/Symbol.map)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/keramida/tzcode/libc/stdtime/Symbol.map Sun Nov 23 16:06:41 2008 (r185209, copy of r185208, head/lib/libc/stdtime/Symbol.map)
@@ -0,0 +1,35 @@
+/*
+ * $FreeBSD$
+ */
+
+FBSD_1.0 {
+ _time32_to_time;
+ _time_to_time32;
+ _time64_to_time;
+ _time_to_time64;
+ _time_to_long;
+ _long_to_time;
+ _time_to_int;
+ _int_to_time;
+ strptime;
+ strftime;
+ tzname;
+ tzsetwall;
+ tzset;
+ localtime;
+ localtime_r;
+ gmtime;
+ gmtime_r;
+ offtime;
+ ctime;
+ ctime_r;
+ mktime;
+ timelocal;
+ timegm;
+ timeoff;
+ time2posix;
+ posix2time;
+ difftime;
+ asctime_r;
+ asctime;
+};
Modified: user/keramida/tzcode/libc/stdtime/asctime.c
==============================================================================
--- user/keramida/tzcode/libc/stdtime/asctime.c Sun Nov 23 15:26:59 2008 (r185208)
+++ user/keramida/tzcode/libc/stdtime/asctime.c Sun Nov 23 16:06:41 2008 (r185209)
@@ -3,15 +3,19 @@
** 1996-06-05 by Arthur David Olson (arthur_david_olson at nih.gov).
*/
+#include <sys/cdefs.h>
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)asctime.c 7.9";
+static char elsieid[] __unused = "@(#)asctime.c 7.9";
#endif /* !defined NOID */
#endif /* !defined lint */
+__FBSDID("$FreeBSD$");
/*LINTLIBRARY*/
+#include "namespace.h"
#include "private.h"
+#include "un-namespace.h"
#include "tzfile.h"
/*
@@ -20,8 +24,8 @@ static char elsieid[] = "@(#)asctime.c 7
char *
asctime_r(timeptr, buf)
-register const struct tm * timeptr;
-char * buf;
+const struct tm * timeptr;
+char * buf;
{
static const char wday_name[][3] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
@@ -30,8 +34,8 @@ char * buf;
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
- register const char * wn;
- register const char * mn;
+ const char * wn;
+ const char * mn;
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
@@ -58,7 +62,7 @@ char * buf;
char *
asctime(timeptr)
-register const struct tm * timeptr;
+const struct tm * timeptr;
{
/*
** Big enough for something such as
Copied: user/keramida/tzcode/libc/stdtime/ctime.3 (from r185208, head/lib/libc/stdtime/ctime.3)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/keramida/tzcode/libc/stdtime/ctime.3 Sun Nov 23 16:06:41 2008 (r185209, copy of r185208, head/lib/libc/stdtime/ctime.3)
@@ -0,0 +1,374 @@
+.\" Copyright (c) 1989, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Arthur Olson.
+.\" 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.
+.\" 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.
+.\"
+.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93
+.\" $FreeBSD$
+.\"
+.Dd January 2, 1999
+.Dt CTIME 3
+.Os
+.Sh NAME
+.Nm asctime ,
+.Nm asctime_r ,
+.Nm ctime ,
+.Nm ctime_r ,
+.Nm difftime ,
+.Nm gmtime ,
+.Nm gmtime_r ,
+.Nm localtime ,
+.Nm localtime_r ,
+.Nm mktime ,
+.Nm timegm
+.Nd transform binary date and time values
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Vt extern char *tzname[2] ;
+.Ft char *
+.Fn ctime "const time_t *clock"
+.Ft double
+.Fn difftime "time_t time1" "time_t time0"
+.Ft char *
+.Fn asctime "const struct tm *tm"
+.Ft struct tm *
+.Fn localtime "const time_t *clock"
+.Ft struct tm *
+.Fn gmtime "const time_t *clock"
+.Ft time_t
+.Fn mktime "struct tm *tm"
+.Ft time_t
+.Fn timegm "struct tm *tm"
+.Ft char *
+.Fn ctime_r "const time_t *clock" "char *buf"
+.Ft struct tm *
+.Fn localtime_r "const time_t *clock" "struct tm *result"
+.Ft struct tm *
+.Fn gmtime_r "const time_t *clock" "struct tm *result"
+.Ft char *
+.Fn asctime_r "const struct tm *tm" "char *buf"
+.Sh DESCRIPTION
+The functions
+.Fn ctime ,
+.Fn gmtime
+and
+.Fn localtime
+all take as an argument a time value representing the time in seconds since
+the Epoch (00:00:00
+.Tn UTC ,
+January 1, 1970; see
+.Xr time 3 ) .
+.Pp
+The function
+.Fn localtime
+converts the time value pointed at by
+.Fa clock ,
+and returns a pointer to a
+.Dq Fa struct tm
+(described below) which contains
+the broken-out time information for the value after adjusting for the current
+time zone (and any other factors such as Daylight Saving Time).
+Time zone adjustments are performed as specified by the
+.Ev TZ
+environment variable (see
+.Xr tzset 3 ) .
+The function
+.Fn localtime
+uses
+.Xr tzset 3
+to initialize time conversion information if
+.Xr tzset 3
+has not already been called by the process.
+.Pp
+After filling in the tm structure,
+.Fn localtime
+sets the
+.Fa tm_isdst Ns 'th
+element of
+.Fa tzname
+to a pointer to an
+.Tn ASCII
+string that is the time zone abbreviation to be
+used with
+.Fn localtime Ns 's
+return value.
+.Pp
+The function
+.Fn gmtime
+similarly converts the time value, but without any time zone adjustment,
+and returns a pointer to a tm structure (described below).
+.Pp
+The
+.Fn ctime
+function
+adjusts the time value for the current time zone in the same manner as
+.Fn localtime ,
+and returns a pointer to a 26-character string of the form:
+.Bd -literal -offset indent
+Thu Nov 24 18:22:48 1986\en\e0
+.Ed
+.Pp
+All the fields have constant width.
+.Pp
+The
+.Fn ctime_r
+function
+provides the same functionality as
+.Fn ctime
+except the caller must provide the output buffer
+.Fa buf
+to store the result, which must be at least 26 characters long.
+The
+.Fn localtime_r
+and
+.Fn gmtime_r
+functions
+provide the same functionality as
+.Fn localtime
+and
+.Fn gmtime
+respectively, except the caller must provide the output buffer
+.Fa result .
+.Pp
+The
+.Fn asctime
+function
+converts the broken down time in the structure
+.Fa tm
+pointed at by
+.Fa *tm
+to the form
+shown in the example above.
+.Pp
+The
+.Fn asctime_r
+function
+provides the same functionality as
+.Fn asctime
+except the caller provide the output buffer
+.Fa buf
+to store the result, which must be at least 26 characters long.
+.Pp
+The functions
+.Fn mktime
+and
+.Fn timegm
+convert the broken-down time in the structure
+pointed to by tm into a time value with the same encoding as that of the
+values returned by the
+.Xr time 3
+function (that is, seconds from the Epoch,
+.Tn UTC ) .
+The
+.Fn mktime
+function
+interprets the input structure according to the current timezone setting
+(see
+.Xr tzset 3 ) .
+The
+.Fn timegm
+function
+interprets the input structure as representing Universal Coordinated Time
+.Pq Tn UTC .
+.Pp
+The original values of the
+.Fa tm_wday
+and
+.Fa tm_yday
+components of the structure are ignored, and the original values of the
+other components are not restricted to their normal ranges, and will be
+normalized if needed.
+For example,
+October 40 is changed into November 9,
+a
+.Fa tm_hour
+of \-1 means 1 hour before midnight,
+.Fa tm_mday
+of 0 means the day preceding the current month, and
+.Fa tm_mon
+of \-2 means 2 months before January of
+.Fa tm_year .
+(A positive or zero value for
+.Fa tm_isdst
+causes
+.Fn mktime
+to presume initially that summer time (for example, Daylight Saving Time)
+is or is not in effect for the specified time, respectively.
+A negative value for
+.Fa tm_isdst
+causes the
+.Fn mktime
+function to attempt to divine whether summer time is in effect for the
+specified time.
+The
+.Fa tm_isdst
+and
+.Fa tm_gmtoff
+members are forced to zero by
+.Fn timegm . )
+.Pp
+On successful completion, the values of the
+.Fa tm_wday
+and
+.Fa tm_yday
+components of the structure are set appropriately, and the other components
+are set to represent the specified calendar time, but with their values
+forced to their normal ranges; the final value of
+.Fa tm_mday
+is not set until
+.Fa tm_mon
+and
+.Fa tm_year
+are determined.
+The
+.Fn mktime
+function
+returns the specified calendar time; if the calendar time cannot be
+represented, it returns \-1;
+.Pp
+The
+.Fn difftime
+function
+returns the difference between two calendar times,
+.Pf ( Fa time1
+-
+.Fa time0 ) ,
+expressed in seconds.
+.Pp
+External declarations as well as the tm structure definition are in the
+.In time.h
+include file.
+The tm structure includes at least the following fields:
+.Bd -literal -offset indent
+int tm_sec; /\(** seconds (0 - 60) \(**/
+int tm_min; /\(** minutes (0 - 59) \(**/
+int tm_hour; /\(** hours (0 - 23) \(**/
+int tm_mday; /\(** day of month (1 - 31) \(**/
+int tm_mon; /\(** month of year (0 - 11) \(**/
+int tm_year; /\(** year \- 1900 \(**/
+int tm_wday; /\(** day of week (Sunday = 0) \(**/
+int tm_yday; /\(** day of year (0 - 365) \(**/
+int tm_isdst; /\(** is summer time in effect? \(**/
+char \(**tm_zone; /\(** abbreviation of timezone name \(**/
+long tm_gmtoff; /\(** offset from UTC in seconds \(**/
+.Ed
+.Pp
+The
+field
+.Fa tm_isdst
+is non-zero if summer time is in effect.
+.Pp
+The field
+.Fa tm_gmtoff
+is the offset (in seconds) of the time represented from
+.Tn UTC ,
+with positive
+values indicating east of the Prime Meridian.
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr gettimeofday 2 ,
+.Xr getenv 3 ,
+.Xr time 3 ,
+.Xr tzset 3 ,
+.Xr tzfile 5
+.Sh STANDARDS
+The
+.Fn asctime ,
+.Fn ctime ,
+.Fn difftime ,
+.Fn gmtime ,
+.Fn localtime ,
+and
+.Fn mktime
+functions conform to
+.St -isoC ,
+and conform to
+.St -p1003.1-96
+provided the selected local timezone does not contain a leap-second table
+(see
+.Xr zic 8 ) .
+.Pp
+The
+.Fn asctime_r ,
+.Fn ctime_r ,
+.Fn gmtime_r ,
+and
+.Fn localtime_r
+functions are expected to conform to
+.St -p1003.1-96
+(again provided the selected local timezone does not contain a leap-second
+table).
+.Pp
+The
+.Fn timegm
+function is not specified by any standard; its function cannot be
+completely emulated using the standard functions described above.
+.Sh HISTORY
+This manual page is derived from
+the time package contributed to Berkeley by
+.An Arthur Olson
+and which appeared in
+.Bx 4.3 .
+.Sh BUGS
+Except for
+.Fn difftime ,
+.Fn mktime ,
+and the
+.Fn \&_r
+variants of the other functions,
+these functions leaves their result in an internal static object and return
+a pointer to that object.
+Subsequent calls to these
+function will modify the same object.
+.Pp
+The C Standard provides no mechanism for a program to modify its current
+local timezone setting, and the
+.Tn POSIX Ns No \&-standard
+method is not reentrant.
+(However, thread-safe implementations are provided
+in the
+.Tn POSIX
+threaded environment.)
+.Pp
+The
+.Va tm_zone
+field of a returned
+.Vt tm
+structure points to a static array of characters,
+which will also be overwritten by any subsequent calls (as well as by
+subsequent calls to
+.Xr tzset 3
+and
+.Xr tzsetwall 3 ) .
+.Pp
+Use of the external variable
+.Fa tzname
+is discouraged; the
+.Fa tm_zone
+entry in the tm structure is preferred.
Modified: user/keramida/tzcode/libc/stdtime/difftime.c
==============================================================================
--- user/keramida/tzcode/libc/stdtime/difftime.c Sun Nov 23 15:26:59 2008 (r185208)
+++ user/keramida/tzcode/libc/stdtime/difftime.c Sun Nov 23 16:06:41 2008 (r185209)
@@ -3,15 +3,19 @@
** June 5, 1996 by Arthur David Olson (arthur_david_olson at nih.gov).
*/
+#include <sys/cdefs.h>
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)difftime.c 7.9";
+static char elsieid[] __unused = "@(#)difftime.c 7.9";
#endif /* !defined NOID */
#endif /* !defined lint */
+__FBSDID("$FreeBSD$");
/*LINTLIBRARY*/
+#include "namespace.h"
#include "private.h"
+#include "un-namespace.h"
/*
** Algorithm courtesy Paul Eggert (eggert at twinsun.com).
Modified: user/keramida/tzcode/libc/stdtime/localtime.c
==============================================================================
--- user/keramida/tzcode/libc/stdtime/localtime.c Sun Nov 23 15:26:59 2008 (r185208)
+++ user/keramida/tzcode/libc/stdtime/localtime.c Sun Nov 23 16:06:41 2008 (r185209)
@@ -3,11 +3,13 @@
** 1996-06-05 by Arthur David Olson (arthur_david_olson at nih.gov).
*/
+#include <sys/cdefs.h>
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)localtime.c 7.78";
+static char elsieid[] __unused = "@(#)localtime.c 7.78";
#endif /* !defined NOID */
#endif /* !defined lint */
+__FBSDID("$FreeBSD$");
/*
** Leap second handling from Bradley White (bww at k.gp.cs.cmu.edu).
@@ -17,9 +19,35 @@ static char elsieid[] = "@(#)localtime.c
/*LINTLIBRARY*/
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <pthread.h>
#include "private.h"
+#include "un-namespace.h"
+
#include "tzfile.h"
-#include "fcntl.h"
+
+#include "libc_private.h"
+
+#define _MUTEX_LOCK(x) if (__isthreaded) _pthread_mutex_lock(x)
+#define _MUTEX_UNLOCK(x) if (__isthreaded) _pthread_mutex_unlock(x)
+
+#define _RWLOCK_RDLOCK(x) \
+ do { \
+ if (__isthreaded) _pthread_rwlock_rdlock(x); \
+ } while (0)
+
+#define _RWLOCK_WRLOCK(x) \
+ do { \
+ if (__isthreaded) _pthread_rwlock_wrlock(x); \
+ } while (0)
+
+#define _RWLOCK_UNLOCK(x) \
+ do { \
+ if (__isthreaded) _pthread_rwlock_unlock(x); \
+ } while (0)
/*
** SunOS 4.1.1 headers lack O_BINARY.
@@ -57,7 +85,12 @@ static char elsieid[] = "@(#)localtime.c
static char wildabbr[] = "WILDABBR";
-static const char gmt[] = "GMT";
+/*
+ * In June 2004 it was decided UTC was a more appropriate default time
+ * zone than GMT.
+ */
+
+static const char gmt[] = "UTC";
/*
** The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
@@ -121,43 +154,43 @@ struct rule {
** Prototypes for static functions.
*/
-static long detzcode P((const char * codep));
-static const char * getzname P((const char * strp));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
-static const char * getsecs P((const char * strp, long * secsp));
-static const char * getoffset P((const char * strp, long * offsetp));
-static const char * getrule P((const char * strp, struct rule * rulep));
-static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static int increment_overflow P((int * number, int delta));
-static int normalize_overflow P((int * tensptr, int * unitsptr,
- int base));
-static void settzname P((void));
-static time_t time1 P((struct tm * tmp,
- void(*funcp) P((const time_t *,
- long, struct tm *)),
- long offset));
-static time_t time2 P((struct tm *tmp,
- void(*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp));
-static time_t time2sub P((struct tm *tmp,
- void(*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp, int do_norm_secs));
-static void timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
-static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
+static long detzcode(const char * codep);
+static const char * getzname(const char * strp);
+static const char * getnum(const char * strp, int * nump, int min,
+ int max);
+static const char * getsecs(const char * strp, long * secsp);
+static const char * getoffset(const char * strp, long * offsetp);
+static const char * getrule(const char * strp, struct rule * rulep);
+static void gmtload(struct state * sp);
+static void gmtsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static void localsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static int increment_overflow(int * number, int delta);
+static int normalize_overflow(int * tensptr, int * unitsptr,
+ int base);
+static void settzname(void);
+static time_t time1(struct tm * tmp,
+ void(*funcp) (const time_t *,
+ long, struct tm *),
+ long offset);
+static time_t time2(struct tm *tmp,
+ void(*funcp) (const time_t *,
+ long, struct tm*),
+ long offset, int * okayp);
+static time_t time2sub(struct tm *tmp,
+ void(*funcp) (const time_t *,
+ long, struct tm*),
+ long offset, int * okayp, int do_norm_secs);
+static void timesub(const time_t * timep, long offset,
+ const struct state * sp, struct tm * tmp);
+static int tmcomp(const struct tm * atmp,
+ const struct tm * btmp);
+static time_t transtime(time_t janfirst, int year,
+ const struct rule * rulep, long offset);
+static int tzload(const char * name, struct state * sp);
+static int tzparse(const char * name, struct state * sp,
+ int lastditch);
#ifdef ALL_STATE
static struct state * lclptr;
@@ -178,6 +211,8 @@ static struct state gmtmem;
static char lcl_TZname[TZ_STRLEN_MAX + 1];
static int lcl_is_set;
static int gmt_is_set;
+static pthread_rwlock_t lcl_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_mutex_t gmt_mutex = PTHREAD_MUTEX_INITIALIZER;
char * tzname[2] = {
wildabbr,
@@ -207,8 +242,8 @@ static long
detzcode(codep)
const char * const codep;
{
- register long result;
- register int i;
+ long result;
+ int i;
result = (codep[0] & 0x80) ? ~0L : 0L;
for (i = 0; i < 4; ++i)
@@ -217,10 +252,10 @@ const char * const codep;
}
static void
-settzname P((void))
+settzname(void)
{
- register struct state * const sp = lclptr;
- register int i;
+ struct state * sp = lclptr;
+ int i;
tzname[0] = wildabbr;
tzname[1] = wildabbr;
@@ -238,7 +273,7 @@ settzname P((void))
}
#endif /* defined ALL_STATE */
for (i = 0; i < sp->typecnt; ++i) {
- register const struct ttinfo * const ttisp = &sp->ttis[i];
+ const struct ttinfo * const ttisp = &sp->ttis[i];
tzname[ttisp->tt_isdst] =
&sp->chars[ttisp->tt_abbrind];
@@ -257,7 +292,7 @@ settzname P((void))
** And to get the latest zone names into tzname. . .
*/
for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * const ttisp =
+ const struct ttinfo * const ttisp =
&sp->ttis[
sp->types[i]];
@@ -268,17 +303,23 @@ settzname P((void))
static int
tzload(name, sp)
-register const char * name;
-register struct state * const sp;
+const char * name;
+struct state * const sp;
{
- register const char * p;
- register int i;
- register int fid;
-
+ const char * p;
+ int i;
+ int fid;
+
+ /* XXX The following is from OpenBSD, and I'm not sure it is correct */
+ if (name != NULL && issetugid() != 0)
+ if ((name[0] == ':' && name[1] == '/') ||
+ name[0] == '/' || strchr(name, '.'))
+ name = NULL;
if (name == NULL && (name = TZDEFAULT) == NULL)
return -1;
{
- register int doaccess;
+ int doaccess;
+ struct stat stab;
/*
** Section 4.9.1 of the C standard says that
** "FILENAME_MAX expands to an integral constant expression
@@ -294,7 +335,7 @@ register struct state * const sp;
if (!doaccess) {
if ((p = TZDIR) == NULL)
return -1;
- if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
+ if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname)
return -1;
(void) strcpy(fullname, p);
(void) strcat(fullname, "/");
@@ -307,9 +348,13 @@ register struct state * const sp;
name = fullname;
}
if (doaccess && access(name, R_OK) != 0)
+ return -1;
+ if ((fid = _open(name, OPEN_MODE)) == -1)
return -1;
- if ((fid = open(name, OPEN_MODE)) == -1)
+ if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) {
+ _close(fid);
return -1;
+ }
}
{
struct tzhead * tzhp;
@@ -320,8 +365,8 @@ register struct state * const sp;
int ttisstdcnt;
int ttisgmtcnt;
- i = read(fid, u.buf, sizeof u.buf);
- if (close(fid) != 0)
+ i = _read(fid, u.buf, sizeof u.buf);
+ if (_close(fid) != 0)
return -1;
ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
@@ -355,7 +400,7 @@ register struct state * const sp;
return -1;
}
for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
+ struct ttinfo * ttisp;
ttisp = &sp->ttis[i];
ttisp->tt_gmtoff = detzcode(p);
@@ -372,7 +417,7 @@ register struct state * const sp;
sp->chars[i] = *p++;
sp->chars[i] = '\0'; /* ensure '\0' at end */
for (i = 0; i < sp->leapcnt; ++i) {
- register struct lsinfo * lsisp;
+ struct lsinfo * lsisp;
lsisp = &sp->lsis[i];
lsisp->ls_trans = detzcode(p);
@@ -381,7 +426,7 @@ register struct state * const sp;
p += 4;
}
for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
+ struct ttinfo * ttisp;
ttisp = &sp->ttis[i];
if (ttisstdcnt == 0)
@@ -394,7 +439,7 @@ register struct state * const sp;
}
}
for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
+ struct ttinfo * ttisp;
ttisp = &sp->ttis[i];
if (ttisgmtcnt == 0)
@@ -427,9 +472,9 @@ static const int year_lengths[2] = {
static const char *
getzname(strp)
-register const char * strp;
+const char * strp;
{
- register char c;
+ char c;
while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
c != '+')
@@ -446,13 +491,13 @@ register const char * strp;
static const char *
getnum(strp, nump, min, max)
-register const char * strp;
+const char * strp;
int * const nump;
const int min;
const int max;
{
- register char c;
- register int num;
+ char c;
+ int num;
if (strp == NULL || !is_digit(c = *strp))
return NULL;
@@ -479,7 +524,7 @@ const int max;
static const char *
getsecs(strp, secsp)
-register const char * strp;
+const char * strp;
long * const secsp;
{
int num;
@@ -521,10 +566,10 @@ long * const secsp;
static const char *
getoffset(strp, offsetp)
-register const char * strp;
+const char * strp;
long * const offsetp;
{
- register int neg = 0;
+ int neg = 0;
if (*strp == '-') {
neg = 1;
@@ -549,7 +594,7 @@ long * const offsetp;
static const char *
getrule(strp, rulep)
const char * strp;
-register struct rule * const rulep;
+struct rule * const rulep;
{
if (*strp == 'J') {
/*
@@ -604,12 +649,12 @@ static time_t
transtime(janfirst, year, rulep, offset)
const time_t janfirst;
const int year;
-register const struct rule * const rulep;
+const struct rule * const rulep;
const long offset;
{
- register int leapyear;
- register time_t value;
- register int i;
+ int leapyear;
+ time_t value;
+ int i;
int d, m1, yy0, yy1, yy2, dow;
INITIALIZE(value);
@@ -698,7 +743,7 @@ const long offset;
static int
tzparse(name, sp, lastditch)
const char * name;
-register struct state * const sp;
+struct state * const sp;
const int lastditch;
{
const char * stdname;
@@ -707,10 +752,10 @@ const int lastditch;
size_t dstlen;
long stdoffset;
long dstoffset;
- register time_t * atp;
- register unsigned char * typep;
- register char * cp;
- register int load_result;
+ time_t * atp;
+ unsigned char * typep;
+ char * cp;
+ int load_result;
INITIALIZE(dstname);
stdname = name;
@@ -726,10 +771,12 @@ const int lastditch;
if (stdlen < 3)
return -1;
if (*name == '\0')
- return -1;
- name = getoffset(name, &stdoffset);
- if (name == NULL)
- return -1;
+ return -1; /* was "stdoffset = 0;" */
+ else {
+ name = getoffset(name, &stdoffset);
+ if (name == NULL)
+ return -1;
+ }
}
load_result = tzload(TZDEFRULES, sp);
if (load_result != 0)
@@ -750,8 +797,8 @@ const int lastditch;
if (*name == ',' || *name == ';') {
struct rule start;
struct rule end;
- register int year;
- register time_t janfirst;
+ int year;
+ time_t janfirst;
time_t starttime;
time_t endtime;
@@ -800,12 +847,12 @@ const int lastditch;
SECSPERDAY;
}
} else {
- register long theirstdoffset;
- register long theirdstoffset;
- register long theiroffset;
- register int isdst;
- register int i;
- register int j;
+ long theirstdoffset;
+ long theirdstoffset;
+ long theiroffset;
+ int isdst;
+ int i;
+ int j;
if (*name != '\0')
return -1;
@@ -916,18 +963,19 @@ struct state * const sp;
(void) tzparse(gmt, sp, TRUE);
}
-#ifndef STD_INSPIRED
-/*
-** A non-static declaration of tzsetwall in a system header file
-** may cause a warning about this upcoming static declaration...
-*/
-static
-#endif /* !defined STD_INSPIRED */
-void
-tzsetwall P((void))
+static void
+tzsetwall_basic(int rdlocked)
{
- if (lcl_is_set < 0)
+ if (!rdlocked)
+ _RWLOCK_RDLOCK(&lcl_rwlock);
+ if (lcl_is_set < 0) {
+ if (!rdlocked)
+ _RWLOCK_UNLOCK(&lcl_rwlock);
return;
+ }
+ _RWLOCK_UNLOCK(&lcl_rwlock);
+
+ _RWLOCK_WRLOCK(&lcl_rwlock);
lcl_is_set = -1;
#ifdef ALL_STATE
@@ -935,6 +983,9 @@ tzsetwall P((void))
lclptr = (struct state *) malloc(sizeof *lclptr);
if (lclptr == NULL) {
settzname(); /* all we can do */
+ _RWLOCK_UNLOCK(&lcl_rwlock);
+ if (rdlocked)
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list