Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/time merge tzcode2015e:



details:   https://anonhg.NetBSD.org/src/rev/5993a72ffb01
branches:  trunk
changeset: 339000:5993a72ffb01
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jun 21 16:06:51 2015 +0000

description:
merge tzcode2015e:

  Changes affecting code

    When displaying data, tzselect converts it to the current locale's
    encoding if the iconv command works.  (Problem reported by random832.)

    tzselect no longer mishandles Dominica, fixing a bug introduced
    in Release 2014f.  (Problem reported by Owen Leibman.)

    zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
    This fixes a bug introduced in Release 2014f.
    (Problem reported by Leonardo Chiquitto.)

diffstat:

 lib/libc/time/Makefile     |  54 +++++++++++++++---------------
 lib/libc/time/NEWS         |  29 ++++++++++++++++
 lib/libc/time/localtime.c  |  42 +++++++++++++++++-----
 lib/libc/time/private.h    |  27 ++++++++------
 lib/libc/time/tzselect.ksh |  64 ++++++++++++++++++++++++-----------
 lib/libc/time/zdump.c      |  10 +++--
 lib/libc/time/zic.8        |   5 +-
 lib/libc/time/zic.c        |  82 ++++++++++++++++++++++++---------------------
 8 files changed, 199 insertions(+), 114 deletions(-)

diffs (truncated from 691 to 300 lines):

diff -r e86c7aaff7db -r 5993a72ffb01 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Sun Jun 21 15:32:52 2015 +0000
+++ b/lib/libc/time/Makefile    Sun Jun 21 16:06:51 2015 +0000
@@ -5,7 +5,7 @@
 PACKAGE=       tzcode
 
 # Version numbers of the code and data distributions.
-VERSION=       2015d
+VERSION=       2015e
 
 # Email address for bug reports.
 BUGEMAIL=      tz%iana.org@localhost
@@ -293,23 +293,24 @@
 SAFE_CHARSET1= $(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
 SAFE_CHARSET2= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
 SAFE_CHARSET3= 'abcdefghijklmnopqrstuvwxyz{|}~'
-SAFE_CHARSET=  ]$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)-
-SAFE_CHAR=     '['$(SAFE_CHARSET)']'
-# NONSYM_CHAR is a regular expression that matches any character
-# except for a small number of symbols, where we prefer to stick with
+SAFE_CHARSET=  $(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
+SAFE_CHAR=     '[]'$(SAFE_CHARSET)'-]'
+
+# OK_CHAR matches any character allowed in the distributed files.
+# This is the same as SAFE_CHAR, except that multibyte letters are
+# also allowed so that commentary can contain people's names and quote
+# non-English sources.  For non-letters the sources are limited to
 # ASCII renderings for the convenience of maintainers whose text editors
 # mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
-NONSYM_CHAR=   '[^â??â??°â?²â?³â??â? â?¤â?¥Â±â??Ã?÷â??â??â??â??·â?¢Â§Â¶Â«Â»â??â??â??â??â??â??â??â??â?¹â?ºã??ã??ã??ã??ã??ã??ã??]'
+OK_CHAR=       '[][:alpha:]'$(SAFE_CHARSET)'-]'
 
 # SAFE_LINE matches a line of safe characters.
-# SAFE_SHARP_LINE is similar, except any character can follow '#';
+# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
 # this is so that comments can contain non-ASCII characters.
-# NONSYM_LINE matches a line of non-symbols.
-# VALID_LINE matches a line of any validly-encoded characters.
+# OK_LINE matches a line of OK characters.
 SAFE_LINE=     '^'$(SAFE_CHAR)'*$$'
-SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(NONSYM_CHAR)'*)?$$'
-NONSYM_LINE=   '^'$(NONSYM_CHAR)'*$$'
-VALID_LINE=    '^.*$$'
+SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
+OK_LINE=       '^'$(OK_CHAR)'*$$'
 
 # Flags to give 'tar' when making a distribution.
 # Try to use flags appropriate for GNU tar.
@@ -324,6 +325,8 @@
 
 ###############################################################################
 
+#MAKE=         make
+
 cc=            cc
 CC=            $(cc) -DTZDIR=\"$(TZDIR)\"
 
@@ -372,7 +375,7 @@
 
 all:           tzselect zic zdump libtz.a $(TABDATA)
 
-ALL:           all date
+ALL:           all date $(ENCHILADA)
 
 install:       all $(DATA) $(REDO) $(MANS)
                mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \
@@ -476,14 +479,11 @@
 check_character_set: $(ENCHILADA)
                LC_ALL=en_US.utf8 && export LC_ALL && \
                sharp='#' && \
-               ! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
+               ! grep -Env $(SAFE_LINE) Makefile $(MANS) date.1 $(MANTXTS) \
                        $(MISC) $(SOURCES) $(WEB_PAGES) && \
                ! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \
-                       iso3166.tab leapseconds yearistype.sh zone.tab && \
-               test $$(grep -Ecv $(SAFE_SHARP_LINE) Makefile) -eq 1 && \
-               ! grep -Env $(NONSYM_LINE) CONTRIBUTING NEWS README Theory \
-                       $(MANS) date.1 zone1970.tab && \
-               ! grep -Env $(VALID_LINE) $(ENCHILADA)
+                       leapseconds yearistype.sh zone.tab && \
+               ! grep -Env $(OK_LINE) $(ENCHILADA)
 
 check_white_space: $(ENCHILADA)
                ! grep -En ' '$(TAB_CHAR)"|$$(printf '[\f\r\v]')" $(ENCHILADA)
@@ -574,9 +574,9 @@
 # The zics below ensure that each data file can stand on its own.
 # We also do an all-files run to catch links to links.
 
-check_public:  $(ENCHILADA)
-               make maintainer-clean
-               make "CFLAGS=$(GCC_DEBUG_FLAGS)" $(ENCHILADA) all
+check_public:
+               $(MAKE) maintainer-clean
+               $(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL
                mkdir tzpublic
                for i in $(TDATA) ; do \
                  $(zic) -v -d tzpublic $$i 2>&1 || exit; \
@@ -595,8 +595,8 @@
                zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
                for type in $(TIME_T_ALTERNATIVES); do \
                  mkdir -p tzpublic/$$type && \
-                 make clean_misc && \
-                 make TOPDIR=`pwd`/tzpublic/$$type \
+                 $(MAKE) clean_misc && \
+                 $(MAKE) TOPDIR=`pwd`/tzpublic/$$type \
                    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
                    REDO='$(REDO)' \
                    install && \
@@ -642,12 +642,12 @@
                gpg --armor --detach-sign $?
 
 typecheck:
-               make clean
+               $(MAKE) clean
                for i in "long long" unsigned; \
                do \
-                       make CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
+                       $(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
                        ./zdump -v Europe/Rome ; \
-                       make clean ; \
+                       $(MAKE) clean ; \
                done
 
 zonenames:     $(TDATA)
diff -r e86c7aaff7db -r 5993a72ffb01 lib/libc/time/NEWS
--- a/lib/libc/time/NEWS        Sun Jun 21 15:32:52 2015 +0000
+++ b/lib/libc/time/NEWS        Sun Jun 21 16:06:51 2015 +0000
@@ -1,5 +1,34 @@
 News for the tz database
 
+
+Release 2015e - 2015-06-13 10:56:02 -0700
+
+  Changes affecting future time stamps
+
+    Morocco will suspend DST from 2015-06-14 03:00 through 2015-07-19 02:00,
+    not 06-13 and 07-18 as we had guessed.  (Thanks to Milamber.)
+
+    Assume Cayman Islands will observe DST starting next year, using US rules.
+    Although it isn't guaranteed, it is the most likely.
+
+  Changes affecting data format
+
+    The file 'iso3166.tab' now uses UTF-8, so that its entries can better
+    spell the names of �land Islands, Côte d'Ivoire, and Réunion.
+
+  Changes affecting code
+
+    When displaying data, tzselect converts it to the current locale's
+    encoding if the iconv command works.  (Problem reported by random832.)
+
+    tzselect no longer mishandles Dominica, fixing a bug introduced
+    in Release 2014f.  (Problem reported by Owen Leibman.)
+
+    zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
+    This fixes a bug introduced in Release 2014f.
+    (Problem reported by Leonardo Chiquitto.)
+
+
 Release 2015d - 2015-04-24 08:09:46 -0700
 
   Changes affecting future time stamps
diff -r e86c7aaff7db -r 5993a72ffb01 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sun Jun 21 15:32:52 2015 +0000
+++ b/lib/libc/time/localtime.c Sun Jun 21 16:06:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.94 2015/03/24 20:01:18 christos Exp $  */
+/*     $NetBSD: localtime.c,v 1.95 2015/06/21 16:06:51 christos Exp $  */
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
 #if 0
 static char    elsieid[] = "@(#)localtime.c    8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.94 2015/03/24 20:01:18 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.95 2015/06/21 16:06:51 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -230,13 +230,24 @@
 static int_fast32_t
 detzcode(const char *const codep)
 {
-       int_fast32_t    result;
-       int             i;
+       int_fast32_t result;
+       int     i;
+       int_fast32_t one = 1;
+       int_fast32_t halfmaxval = one << (32 - 2);
+       int_fast32_t maxval = halfmaxval - 1 + halfmaxval;
+       int_fast32_t minval = -1 - maxval;
 
-       result = (codep[0] & 0x80) ? -1 : 0;
-       for (i = 0; i < 4; ++i)
+       result = codep[0] & 0x7f;
+       for (i = 1; i < 4; ++i)
                result = (result << 8) | (codep[i] & 0xff);
-       return result;
+
+       if (codep[0] & 0x80) {
+         /* Do two's-complement negation even on non-two's-complement machines.
+            If the result would be minval - 1, return minval.  */
+           result -= !TWOS_COMPLEMENT(int_fast32_t) && result != 0;
+           result += minval;
+       }
+       return result;
 }
 
 static int_fast64_t
@@ -244,11 +255,22 @@
 {
        int_fast64_t result;
        int     i;
+       int_fast64_t one = 1;
+       int_fast64_t halfmaxval = one << (64 - 2);
+       int_fast64_t maxval = halfmaxval - 1 + halfmaxval;
+       int_fast64_t minval = -TWOS_COMPLEMENT(int_fast64_t) - maxval;
 
-       result = (codep[0] & 0x80) ? -1 : 0;
-       for (i = 0; i < 8; ++i)
+       result = codep[0] & 0x7f;
+       for (i = 1; i < 8; ++i)
                result = (result << 8) | (codep[i] & 0xff);
-       return result;
+
+       if (codep[0] & 0x80) {
+         /* Do two's-complement negation even on non-two's-complement machines.
+            If the result would be minval - 1, return minval.  */
+         result -= !TWOS_COMPLEMENT(int_fast64_t) && result != 0;
+         result += minval;
+       }
+       return result;
 }
 
 const char *
diff -r e86c7aaff7db -r 5993a72ffb01 lib/libc/time/private.h
--- a/lib/libc/time/private.h   Sun Jun 21 15:32:52 2015 +0000
+++ b/lib/libc/time/private.h   Sun Jun 21 16:06:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: private.h,v 1.40 2015/04/28 17:00:24 christos Exp $    */
+/*     $NetBSD: private.h,v 1.41 2015/06/21 16:06:51 christos Exp $    */
 
 #ifndef PRIVATE_H
 #define PRIVATE_H
@@ -490,17 +490,20 @@
 #define TYPE_SIGNED(type) (/*CONSTCOND*/((type) -1) < 0)
 #endif /* !defined TYPE_SIGNED */
 
-#ifdef LOCALTIME_IMPLEMENTATION
-/* The minimum and maximum finite time values.  */
-static time_t const time_t_min =
-  (TYPE_SIGNED(time_t)
-   ? (time_t) -1 << (int)(CHAR_BIT * sizeof (time_t) - 1)
-   : 0);
-static time_t const time_t_max =
-  (TYPE_SIGNED(time_t)
-   ? - (~ 0 < 0) - ((time_t) -1 << (int)(CHAR_BIT * sizeof (time_t) - 1))
-   : -1);
-#endif
+#define TWOS_COMPLEMENT(t) (/*CONSTCOND*/(t) ~ (t) 0 < 0)
+
+/* Max and min values of the integer type T, of which only the bottom
+   B bits are used, and where the highest-order used bit is considered
+   to be a sign bit if T is signed.  */
+#define MAXVAL(t, b) /*LINTED*/                                        \
+  ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))                  \
+       - 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
+#define MINVAL(t, b)                                           \
+  ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
+
+/* The minimum and maximum finite time values.  This assumes no padding.  */
+static time_t const time_t_min = MINVAL(time_t, TYPE_BIT(time_t));
+static time_t const time_t_max = MAXVAL(time_t, TYPE_BIT(time_t));
 
 #ifndef INT_STRLEN_MAXIMUM
 /*
diff -r e86c7aaff7db -r 5993a72ffb01 lib/libc/time/tzselect.ksh
--- a/lib/libc/time/tzselect.ksh        Sun Jun 21 15:32:52 2015 +0000
+++ b/lib/libc/time/tzselect.ksh        Sun Jun 21 16:06:51 2015 +0000
@@ -1,6 +1,6 @@
 #! /bin/bash
 #
-#      $NetBSD: tzselect.ksh,v 1.13 2015/01/31 18:55:17 christos Exp $
+#      $NetBSD: tzselect.ksh,v 1.14 2015/06/21 16:06:51 christos Exp $
 #
 PKGVERSION='(tzcode) '
 TZVERSION=see_Makefile
@@ -39,10 +39,16 @@
 : ${AWK=awk}
 : ${TZDIR=`pwd`}
 
+# Output one argument as-is to standard output.
+# Safer than 'echo', which can mishandle '\' or leading '-'.
+say() {
+    printf '%s\n' "$1"
+}
+
 # Check for awk Posix compliance.
 ($AWK -v x=y 'BEGIN { exit 123 }') </dev/null >/dev/null 2>&1



Home | Main Index | Thread Index | Old Index