Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time bring in the 2011i changes.



details:   https://anonhg.NetBSD.org/src/rev/4c209149263f
branches:  trunk
changeset: 769224:4c209149263f
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 04 10:10:26 2011 +0000

description:
bring in the 2011i changes.

diffstat:

 lib/libc/time/Makefile    |   12 +-
 lib/libc/time/Theory      |   43 +++++++++++--
 lib/libc/time/asctime.c   |   17 +++--
 lib/libc/time/localtime.c |  140 +++++++++++++++++++++++++--------------------
 lib/libc/time/tz-art.htm  |   84 ++++++++++++++++++++++++++-
 lib/libc/time/tz-link.htm |   51 +++++++++++++++-
 lib/libc/time/tzfile.5    |    4 +-
 lib/libc/time/zdump.c     |   12 +-
 lib/libc/time/zic.8       |    7 +-
 lib/libc/time/zic.c       |   73 +++++++++++++++++++++--
 10 files changed, 334 insertions(+), 109 deletions(-)

diffs (truncated from 983 to 300 lines):

diff -r e7c82dd5b9a3 -r 4c209149263f lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Sun Sep 04 10:02:33 2011 +0000
+++ b/lib/libc/time/Makefile    Sun Sep 04 10:10:26 2011 +0000
@@ -1,5 +1,5 @@
 # <pre>
-# @(#)Makefile 8.8
+# @(#)Makefile 8.11
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -12,7 +12,7 @@
 #      make zonenames
 # to get a list of the values you can use for LOCALTIME.
 
-LOCALTIME=     Factory
+LOCALTIME=     GMT
 
 # If you want something other than Eastern United States time as a template
 # for handling POSIX-style time zone environment variables,
@@ -116,7 +116,7 @@
 #  -DZIC_MAX_ABBR_LEN_WO_WARN=3
 #      (or some other number) to set the maximum time zone abbreviation length
 #      that zic will accept without a warning (the default is 6)
-GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
+GCC_DEBUG_FLAGS = -Dlint -g -O3 -fno-common \
        -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
        -Wnested-externs -Wpointer-arith -Wshadow \
        -Wtraditional # -Wstrict-prototypes -Wwrite-strings
@@ -262,15 +262,15 @@
 DOCS=          README Theory $(MANS) date.1 Makefile
 PRIMARY_YDATA= africa antarctica asia australasia \
                europe northamerica southamerica
-YDATA=         $(PRIMARY_YDATA) pacificnew etcetera factory backward
-NDATA=         systemv
+YDATA=         $(PRIMARY_YDATA) pacificnew etcetera backward
+NDATA=         systemv factory
 SDATA=         solar87 solar88 solar89
 TDATA=         $(YDATA) $(NDATA) $(SDATA)
 TABDATA=       iso3166.tab zone.tab
 DATA=          $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
 WEB_PAGES=     tz-art.htm tz-link.htm
 MISC=          usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
-                       itca.jpg $(WEB_PAGES) checktab.awk workman.sh \
+                       $(WEB_PAGES) checktab.awk workman.sh \
                        zoneinfo2tdf.pl
 ENCHILADA=     $(DOCS) $(SOURCES) $(DATA) $(MISC)
 
diff -r e7c82dd5b9a3 -r 4c209149263f lib/libc/time/Theory
--- a/lib/libc/time/Theory      Sun Sep 04 10:02:33 2011 +0000
+++ b/lib/libc/time/Theory      Sun Sep 04 10:10:26 2011 +0000
@@ -1,12 +1,13 @@
-#      $NetBSD: Theory,v 1.9 2009/12/31 22:49:15 mlelstv Exp $
-@(#)Theory     8.3
+#      $NetBSD: Theory,v 1.10 2011/09/04 10:10:26 christos Exp $
+@(#)Theory     8.6
 This file is in the public domain, so clarified as of
 2009-05-17 by Arthur David Olson.
 
 ----- Outline -----
 
        Time and date functions
-       Names of time zone regions
+       Scope of the tz database
+       Names of time zone rule files
        Time zone abbreviations
        Calendrical issues
        Time and time zones on Mars
@@ -193,6 +194,31 @@
 better.
 
 
+----- Scope of the tz database -----
+
+The tz database attempts to record the history and predicted future of 
+all computer-based clocks that track civil time.  To represent this 
+data, the world is partitioned into regions whose clocks all agree 
+about time stamps that occur after the somewhat-arbitrary cutoff point 
+of the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region, 
+the database records all known clock transitions, and labels the region 
+with a notable location.
+
+Clock transitions before 1970 are recorded for each such location, 
+because most POSIX-compatible systems support negative time stamps and 
+could misbehave if data were omitted for pre-1970 transitions.
+However, the database is not designed for and does not suffice for 
+applications requiring accurate handling of all past times everywhere, 
+as it would take far too much effort and guesswork to record all 
+details of pre-1970 civil timekeeping.
+
+As noted in the README file, the tz database is not authoritative 
+(particularly not for pre-1970 time stamps), and it surely has errors.
+Corrections are welcome and encouraged.  Users requiring authoritative 
+data should consult national standards bodies and the references cited 
+in the database's comments.
+
+
 ----- Names of time zone rule files -----
 
 The time zone rule file naming conventions attempt to strike a balance
@@ -288,8 +314,7 @@
 See the file `backward' for most of these older names
 (e.g. `US/Eastern' instead of `America/New_York').
 The other old-fashioned names still supported are
-`WET', `CET', `MET', `EET' (see the file `europe'),
-and `Factory' (see the file `factory').
++`WET', `CET', `MET', and `EET' (see the file `europe').
 
 
 ----- Time zone abbreviations -----
@@ -361,10 +386,10 @@
 Calendrical issues are a bit out of scope for a time zone database,
 but they indicate the sort of problems that we would run into if we
 extended the time zone database further into the past.  An excellent
-resource in this area is Edward M. Reingold and Nachum Dershowitz,
-<a href="http://emr.cs.uiuc.edu/home/reingold/calendar-book/second-edition/";>
-Calendrical Calculations: The Millennium Edition
-</a>, Cambridge University Press (2001).  Other information and
+resource in this area is Nachum Dershowitz and Edward M. Reingold,
+<a href="http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/";>
+Calendrical Calculations: Third Edition
+</a>, Cambridge University Press (2008).  Other information and
 sources are given below.  They sometimes disagree.
 
 
diff -r e7c82dd5b9a3 -r 4c209149263f lib/libc/time/asctime.c
--- a/lib/libc/time/asctime.c   Sun Sep 04 10:02:33 2011 +0000
+++ b/lib/libc/time/asctime.c   Sun Sep 04 10:10:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: asctime.c,v 1.13 2009/12/31 22:49:16 mlelstv Exp $     */
+/*     $NetBSD: asctime.c,v 1.14 2011/09/04 10:10:26 christos Exp $    */
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -14,9 +14,9 @@
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
-static char    elsieid[] = "@(#)asctime.c      8.2";
+static char    elsieid[] = "@(#)asctime.c      8.5";
 #else
-__RCSID("$NetBSD: asctime.c,v 1.13 2009/12/31 22:49:16 mlelstv Exp $");
+__RCSID("$NetBSD: asctime.c,v 1.14 2011/09/04 10:10:26 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -110,6 +110,10 @@
        char                    year[INT_STRLEN_MAXIMUM(int) + 2];
        char                    result[MAX_ASCTIME_BUF_SIZE];
 
+       if (timeptr == NULL) {
+               errno = EINVAL;
+               return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
+       }
        if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
                wn = "???";
        else    wn = wday_name[timeptr->tm_wday];
@@ -130,10 +134,9 @@
                timeptr->tm_mday, timeptr->tm_hour,
                timeptr->tm_min, timeptr->tm_sec,
                year);
-       if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
-               (void) strcpy(buf, result);
-               return buf;
-       } else {
+       if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
+               return strcpy(buf, result);
+       else {
 #ifdef EOVERFLOW
                errno = EOVERFLOW;
 #else /* !defined EOVERFLOW */
diff -r e7c82dd5b9a3 -r 4c209149263f lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sun Sep 04 10:02:33 2011 +0000
+++ b/lib/libc/time/localtime.c Sun Sep 04 10:10:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.57 2011/06/16 22:40:17 christos Exp $  */
+/*     $NetBSD: localtime.c,v 1.58 2011/09/04 10:10:26 christos Exp $  */
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -8,9 +8,9 @@
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
-static char    elsieid[] = "@(#)localtime.c    8.9";
+static char    elsieid[] = "@(#)localtime.c    8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.57 2011/06/16 22:40:17 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.58 2011/09/04 10:10:26 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -331,6 +331,9 @@
                tzname[0] = tzname[1] = (__aconst char *)__UNCONST(gmt);
                return;
        }
+       /*
+       ** And to get the latest zone names into tzname. . .
+       */
        for (i = 0; i < sp->typecnt; ++i) {
                const struct ttinfo * const     ttisp = &sp->ttis[i];
 
@@ -339,7 +342,7 @@
 #ifdef USG_COMPAT
                if (ttisp->tt_isdst)
                        daylight = 1;
-               if (i == 0 || !ttisp->tt_isdst)
+               if (!ttisp->tt_isdst)
                        timezone = -(ttisp->tt_gmtoff);
 #endif /* defined USG_COMPAT */
 #ifdef ALTZONE
@@ -347,17 +350,6 @@
                        altzone = -(ttisp->tt_gmtoff);
 #endif /* defined ALTZONE */
        }
-       /*
-       ** And to get the latest zone names into tzname. . .
-       */
-       for (i = 0; i < sp->timecnt; ++i) {
-               register const struct ttinfo * const    ttisp =
-                                                       &sp->ttis[
-                                                               sp->types[i]];
-
-               tzname[ttisp->tt_isdst] =
-                       &sp->chars[ttisp->tt_abbrind];
-       }
        settzname_z(sp);
 }
 
@@ -379,16 +371,21 @@
        int                     fid;
        int                     stored;
        int                     nread;
-       union {
+       typedef union {
                struct tzhead   tzhead;
                char            buf[2 * sizeof(struct tzhead) +
                                        2 * sizeof *sp +
                                        4 * TZ_MAX_TIMES];
-       } u;
+       } u_t;
+       u_t *                   up;
+
+       up = calloc(1, sizeof *up);
+       if (up == NULL)
+               return -1;
 
        sp->goback = sp->goahead = FALSE;
        if (name == NULL && (name = TZDEFAULT) == NULL)
-               return -1;
+               goto oops;
        {
                int     doaccess;
                /*
@@ -405,9 +402,9 @@
                doaccess = name[0] == '/';
                if (!doaccess) {
                        if ((p = TZDIR) == NULL)
-                               return -1;
+                               goto oops;
                        if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
-                               return -1;
+                               goto oops;
                        (void) strcpy(fullname, p);     /* XXX strcpy is safe */
                        (void) strcat(fullname, "/");   /* XXX strcat is safe */
                        (void) strcat(fullname, name);  /* XXX strcat is safe */
@@ -419,7 +416,7 @@
                        name = fullname;
                }
                if (doaccess && access(name, R_OK) != 0)
-                       return -1;
+                       goto oops;
                /*
                 * XXX potential security problem here if user of a set-id
                 * program has set TZ (which is passed in as name) here,
@@ -427,30 +424,30 @@
                 * above.
                 */
                if ((fid = open(name, OPEN_MODE)) == -1)
-                       return -1;
+                       goto oops;
        }
-       nread = read(fid, u.buf, sizeof u.buf);
+       nread = read(fid, up->buf, sizeof up->buf);
        if (close(fid) < 0 || nread <= 0)
-               return -1;
+               goto oops;
        for (stored = 4; stored <= 8; stored *= 2) {
                int             ttisstdcnt;
                int             ttisgmtcnt;
 
-               ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
-               ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
-               sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
-               sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt);
-               sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt);
-               sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt);
-               p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt;
+               ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt);
+               ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt);
+               sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt);



Home | Main Index | Thread Index | Old Index